Deprecate homekit_controller's air quality entity in favor of separate sensor entities (#54673)

This commit is contained in:
Jc2k 2021-08-17 15:29:52 +01:00 committed by GitHub
parent f39dc749bb
commit ea8061469c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 647 additions and 2 deletions

View file

@ -0,0 +1,84 @@
"""Make sure that an Arlo Baby can be setup."""
from homeassistant.helpers import device_registry as dr, entity_registry as er
from tests.components.homekit_controller.common import (
Helper,
setup_accessories_from_file,
setup_test_accessories,
)
async def test_arlo_baby_setup(hass):
"""Test that an Arlo Baby can be correctly setup in HA."""
accessories = await setup_accessories_from_file(hass, "arlo_baby.json")
config_entry, pairing = await setup_test_accessories(hass, accessories)
entity_registry = er.async_get(hass)
device_registry = dr.async_get(hass)
sensors = [
(
"camera.arlobabya0",
"homekit-00A0000000000-aid:1",
"ArloBabyA0",
),
(
"binary_sensor.arlobabya0",
"homekit-00A0000000000-500",
"ArloBabyA0",
),
(
"sensor.arlobabya0_battery",
"homekit-00A0000000000-700",
"ArloBabyA0 Battery",
),
(
"sensor.arlobabya0_humidity",
"homekit-00A0000000000-900",
"ArloBabyA0 Humidity",
),
(
"sensor.arlobabya0_temperature",
"homekit-00A0000000000-1000",
"ArloBabyA0 Temperature",
),
(
"sensor.arlobabya0_air_quality",
"homekit-00A0000000000-aid:1-sid:800-cid:802",
"ArloBabyA0 - Air Quality",
),
(
"light.arlobabya0",
"homekit-00A0000000000-1100",
"ArloBabyA0",
),
]
device_ids = set()
for (entity_id, unique_id, friendly_name) in sensors:
entry = entity_registry.async_get(entity_id)
assert entry.unique_id == unique_id
helper = Helper(
hass,
entity_id,
pairing,
accessories[0],
config_entry,
)
state = await helper.poll_and_get_state()
assert state.attributes["friendly_name"] == friendly_name
device = device_registry.async_get(entry.device_id)
assert device.manufacturer == "Netgear, Inc"
assert device.name == "ArloBabyA0"
assert device.model == "ABC1000"
assert device.sw_version == "1.10.931"
assert device.via_device_id is None
device_ids.add(entry.device_id)
# All entities should be part of same device
assert len(device_ids) == 1

View file

@ -2,6 +2,8 @@
from aiohomekit.model.characteristics import CharacteristicsTypes
from aiohomekit.model.services import ServicesTypes
from homeassistant.helpers import entity_registry as er
from tests.components.homekit_controller.common import setup_test_component
@ -35,6 +37,12 @@ async def test_air_quality_sensor_read_state(hass, utcnow):
"""Test reading the state of a HomeKit temperature sensor accessory."""
helper = await setup_test_component(hass, create_air_quality_sensor_service)
entity_registry = er.async_get(hass)
entity_registry.async_update_entity(
entity_id="air_quality.testdevice", disabled_by=None
)
await hass.async_block_till_done()
state = await helper.poll_and_get_state()
assert state.state == "4444"