diff --git a/homeassistant/components/homee/alarm_control_panel.py b/homeassistant/components/homee/alarm_control_panel.py index fd7371b31e4..74aa6e36884 100644 --- a/homeassistant/components/homee/alarm_control_panel.py +++ b/homeassistant/components/homee/alarm_control_panel.py @@ -3,7 +3,7 @@ from dataclasses import dataclass from pyHomee.const import AttributeChangedBy, AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.alarm_control_panel import ( AlarmControlPanelEntity, @@ -17,7 +17,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import DOMAIN, HomeeConfigEntry from .entity import HomeeEntity -from .helpers import get_name_for_enum +from .helpers import get_name_for_enum, setup_homee_platform PARALLEL_UPDATES = 0 @@ -60,18 +60,29 @@ def get_supported_features( return supported_features +async def add_alarm_control_panel_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee alarm control panel entities.""" + async_add_entities( + HomeeAlarmPanel(attribute, config_entry, ALARM_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in ALARM_DESCRIPTIONS and attribute.editable + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the alarm control panel component.""" + """Add the homee platform for the alarm control panel component.""" - async_add_entities( - HomeeAlarmPanel(attribute, config_entry, ALARM_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in ALARM_DESCRIPTIONS and attribute.editable + await setup_homee_platform( + add_alarm_control_panel_entities, async_add_entities, config_entry ) diff --git a/homeassistant/components/homee/binary_sensor.py b/homeassistant/components/homee/binary_sensor.py index 3f5f5c46a29..10eb5ea9121 100644 --- a/homeassistant/components/homee/binary_sensor.py +++ b/homeassistant/components/homee/binary_sensor.py @@ -1,7 +1,7 @@ """The Homee binary sensor platform.""" from pyHomee.const import AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.binary_sensor import ( BinarySensorDeviceClass, @@ -14,6 +14,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -152,23 +153,34 @@ BINARY_SENSOR_DESCRIPTIONS: dict[AttributeType, BinarySensorEntityDescription] = } -async def async_setup_entry( - hass: HomeAssistant, +async def add_binary_sensor_entities( config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], ) -> None: - """Add the Homee platform for the binary sensor component.""" - - async_add_devices( + """Add homee binary sensor entities.""" + async_add_entities( HomeeBinarySensor( attribute, config_entry, BINARY_SENSOR_DESCRIPTIONS[attribute.type] ) - for node in config_entry.runtime_data.nodes + for node in nodes for attribute in node.attributes if attribute.type in BINARY_SENSOR_DESCRIPTIONS and not attribute.editable ) +async def async_setup_entry( + hass: HomeAssistant, + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, +) -> None: + """Add the homee platform for the binary sensor component.""" + + await setup_homee_platform( + add_binary_sensor_entities, async_add_entities, config_entry + ) + + class HomeeBinarySensor(HomeeEntity, BinarySensorEntity): """Representation of a Homee binary sensor.""" diff --git a/homeassistant/components/homee/button.py b/homeassistant/components/homee/button.py index 33a8b5f23c8..41dd111cf84 100644 --- a/homeassistant/components/homee/button.py +++ b/homeassistant/components/homee/button.py @@ -1,7 +1,7 @@ """The homee button platform.""" from pyHomee.const import AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.button import ( ButtonDeviceClass, @@ -14,6 +14,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -39,19 +40,28 @@ BUTTON_DESCRIPTIONS: dict[AttributeType, ButtonEntityDescription] = { } +async def add_button_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee button entities.""" + async_add_entities( + HomeeButton(attribute, config_entry, BUTTON_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in BUTTON_DESCRIPTIONS and attribute.editable + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the button component.""" + """Add the homee platform for the button component.""" - async_add_entities( - HomeeButton(attribute, config_entry, BUTTON_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in BUTTON_DESCRIPTIONS and attribute.editable - ) + await setup_homee_platform(add_button_entities, async_add_entities, config_entry) class HomeeButton(HomeeEntity, ButtonEntity): diff --git a/homeassistant/components/homee/climate.py b/homeassistant/components/homee/climate.py index f6027522243..0aa3467f760 100644 --- a/homeassistant/components/homee/climate.py +++ b/homeassistant/components/homee/climate.py @@ -21,6 +21,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .const import CLIMATE_PROFILES, DOMAIN, HOMEE_UNIT_TO_HA_UNIT, PRESET_MANUAL from .entity import HomeeNodeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -31,18 +32,27 @@ ROOM_THERMOSTATS = { } +async def add_climate_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee climate entities.""" + async_add_entities( + HomeeClimate(node, config_entry) + for node in nodes + if node.profile in CLIMATE_PROFILES + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Add the Homee platform for the climate component.""" - async_add_devices( - HomeeClimate(node, config_entry) - for node in config_entry.runtime_data.nodes - if node.profile in CLIMATE_PROFILES - ) + await setup_homee_platform(add_climate_entities, async_add_entities, config_entry) class HomeeClimate(HomeeNodeEntity, ClimateEntity): diff --git a/homeassistant/components/homee/cover.py b/homeassistant/components/homee/cover.py index 79a9b00ffba..b48d965512e 100644 --- a/homeassistant/components/homee/cover.py +++ b/homeassistant/components/homee/cover.py @@ -18,6 +18,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeNodeEntity +from .helpers import setup_homee_platform _LOGGER = logging.getLogger(__name__) @@ -77,18 +78,25 @@ def get_device_class(node: HomeeNode) -> CoverDeviceClass | None: return COVER_DEVICE_PROFILES.get(node.profile) +async def add_cover_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee cover entities.""" + async_add_entities( + HomeeCover(node, config_entry) for node in nodes if is_cover_node(node) + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Add the homee platform for the cover integration.""" - async_add_devices( - HomeeCover(node, config_entry) - for node in config_entry.runtime_data.nodes - if is_cover_node(node) - ) + await setup_homee_platform(add_cover_entities, async_add_entities, config_entry) def is_cover_node(node: HomeeNode) -> bool: diff --git a/homeassistant/components/homee/event.py b/homeassistant/components/homee/event.py index 73c315e8695..5c4fa0af380 100644 --- a/homeassistant/components/homee/event.py +++ b/homeassistant/components/homee/event.py @@ -1,7 +1,7 @@ """The homee event platform.""" from pyHomee.const import AttributeType, NodeProfile -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.event import ( EventDeviceClass, @@ -13,6 +13,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -49,6 +50,22 @@ EVENT_DESCRIPTIONS: dict[AttributeType, EventEntityDescription] = { } +async def add_event_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee event entities.""" + async_add_entities( + HomeeEvent(attribute, config_entry, EVENT_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in EVENT_DESCRIPTIONS + and node.profile in REMOTE_PROFILES + and not attribute.editable + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, @@ -56,14 +73,7 @@ async def async_setup_entry( ) -> None: """Add event entities for homee.""" - async_add_entities( - HomeeEvent(attribute, config_entry, EVENT_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in EVENT_DESCRIPTIONS - and node.profile in REMOTE_PROFILES - and not attribute.editable - ) + await setup_homee_platform(add_event_entities, async_add_entities, config_entry) class HomeeEvent(HomeeEntity, EventEntity): diff --git a/homeassistant/components/homee/fan.py b/homeassistant/components/homee/fan.py index d4694ee8d66..7904f008742 100644 --- a/homeassistant/components/homee/fan.py +++ b/homeassistant/components/homee/fan.py @@ -19,22 +19,32 @@ from homeassistant.util.scaling import int_states_in_range from . import HomeeConfigEntry from .const import DOMAIN, PRESET_AUTO, PRESET_MANUAL, PRESET_SUMMER from .entity import HomeeNodeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 +async def add_fan_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee fan entities.""" + async_add_entities( + HomeeFan(node, config_entry) + for node in nodes + if node.profile == NodeProfile.VENTILATION_CONTROL + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up the Homee fan platform.""" - async_add_devices( - HomeeFan(node, config_entry) - for node in config_entry.runtime_data.nodes - if node.profile == NodeProfile.VENTILATION_CONTROL - ) + await setup_homee_platform(add_fan_entities, async_add_entities, config_entry) class HomeeFan(HomeeNodeEntity, FanEntity): diff --git a/homeassistant/components/homee/helpers.py b/homeassistant/components/homee/helpers.py index b73b1ae2bc9..f9f675a631d 100644 --- a/homeassistant/components/homee/helpers.py +++ b/homeassistant/components/homee/helpers.py @@ -1,11 +1,42 @@ """Helper functions for the homee custom component.""" +from collections.abc import Callable, Coroutine from enum import IntEnum import logging +from typing import Any + +from pyHomee.model import HomeeNode + +from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback + +from . import HomeeConfigEntry _LOGGER = logging.getLogger(__name__) +async def setup_homee_platform( + add_platform_entities: Callable[ + [HomeeConfigEntry, AddConfigEntryEntitiesCallback, list[HomeeNode]], + Coroutine[Any, Any, None], + ], + async_add_entities: AddConfigEntryEntitiesCallback, + config_entry: HomeeConfigEntry, +) -> None: + """Set up a homee platform.""" + await add_platform_entities( + config_entry, async_add_entities, config_entry.runtime_data.nodes + ) + + async def add_device(node: HomeeNode, add: bool) -> None: + """Dynamically add entities.""" + if add: + await add_platform_entities(config_entry, async_add_entities, [node]) + + config_entry.async_on_unload( + config_entry.runtime_data.add_nodes_listener(add_device) + ) + + def get_name_for_enum(att_class: type[IntEnum], att_id: int) -> str | None: """Return the enum item name for a given integer.""" try: diff --git a/homeassistant/components/homee/light.py b/homeassistant/components/homee/light.py index 9c66764760e..3fbfcbeba22 100644 --- a/homeassistant/components/homee/light.py +++ b/homeassistant/components/homee/light.py @@ -24,6 +24,7 @@ from homeassistant.util.color import ( from . import HomeeConfigEntry from .const import LIGHT_PROFILES from .entity import HomeeNodeEntity +from .helpers import setup_homee_platform LIGHT_ATTRIBUTES = [ AttributeType.COLOR, @@ -85,19 +86,28 @@ def decimal_to_rgb_list(color: float) -> list[int]: ] +async def add_light_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee light entities.""" + async_add_entities( + HomeeLight(node, light, config_entry) + for node in nodes + for light in get_light_attribute_sets(node) + if is_light_node(node) + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the light entity.""" + """Add the homee platform for the light entity.""" - async_add_entities( - HomeeLight(node, light, config_entry) - for node in config_entry.runtime_data.nodes - for light in get_light_attribute_sets(node) - if is_light_node(node) - ) + await setup_homee_platform(add_light_entities, async_add_entities, config_entry) class HomeeLight(HomeeNodeEntity, LightEntity): diff --git a/homeassistant/components/homee/lock.py b/homeassistant/components/homee/lock.py index 8b3bf58040d..f061e2eefae 100644 --- a/homeassistant/components/homee/lock.py +++ b/homeassistant/components/homee/lock.py @@ -3,6 +3,7 @@ from typing import Any from pyHomee.const import AttributeChangedBy, AttributeType +from pyHomee.model import HomeeNode from homeassistant.components.lock import LockEntity from homeassistant.core import HomeAssistant @@ -10,24 +11,33 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity -from .helpers import get_name_for_enum +from .helpers import get_name_for_enum, setup_homee_platform PARALLEL_UPDATES = 0 +async def add_lock_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee lock entities.""" + async_add_entities( + HomeeLock(attribute, config_entry) + for node in nodes + for attribute in node.attributes + if (attribute.type == AttributeType.LOCK_STATE and attribute.editable) + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the lock component.""" + """Add the homee platform for the lock component.""" - async_add_devices( - HomeeLock(attribute, config_entry) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if (attribute.type == AttributeType.LOCK_STATE and attribute.editable) - ) + await setup_homee_platform(add_lock_entities, async_add_entities, config_entry) class HomeeLock(HomeeEntity, LockEntity): diff --git a/homeassistant/components/homee/number.py b/homeassistant/components/homee/number.py index 5b824f18851..2015f9953fb 100644 --- a/homeassistant/components/homee/number.py +++ b/homeassistant/components/homee/number.py @@ -4,7 +4,7 @@ from collections.abc import Callable from dataclasses import dataclass from pyHomee.const import AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.number import ( NumberDeviceClass, @@ -18,6 +18,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .const import HOMEE_UNIT_TO_HA_UNIT from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -136,19 +137,28 @@ NUMBER_DESCRIPTIONS = { } +async def add_number_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee number entities.""" + async_add_entities( + HomeeNumber(attribute, config_entry, NUMBER_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in NUMBER_DESCRIPTIONS and attribute.data != "fixed_value" + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the number component.""" + """Add the homee platform for the number component.""" - async_add_entities( - HomeeNumber(attribute, config_entry, NUMBER_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in NUMBER_DESCRIPTIONS and attribute.data != "fixed_value" - ) + await setup_homee_platform(add_number_entities, async_add_entities, config_entry) class HomeeNumber(HomeeEntity, NumberEntity): diff --git a/homeassistant/components/homee/quality_scale.yaml b/homeassistant/components/homee/quality_scale.yaml index 5a8f987c1f9..f27876b1725 100644 --- a/homeassistant/components/homee/quality_scale.yaml +++ b/homeassistant/components/homee/quality_scale.yaml @@ -54,7 +54,7 @@ rules: docs-supported-functions: todo docs-troubleshooting: done docs-use-cases: todo - dynamic-devices: todo + dynamic-devices: done entity-category: done entity-device-class: done entity-disabled-by-default: done diff --git a/homeassistant/components/homee/select.py b/homeassistant/components/homee/select.py index 694d1bc7456..9466305c275 100644 --- a/homeassistant/components/homee/select.py +++ b/homeassistant/components/homee/select.py @@ -1,7 +1,7 @@ """The Homee select platform.""" from pyHomee.const import AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.select import SelectEntity, SelectEntityDescription from homeassistant.const import EntityCategory @@ -10,6 +10,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -27,19 +28,28 @@ SELECT_DESCRIPTIONS: dict[AttributeType, SelectEntityDescription] = { } +async def add_select_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee select entities.""" + async_add_entities( + HomeeSelect(attribute, config_entry, SELECT_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in SELECT_DESCRIPTIONS and attribute.editable + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the select component.""" + """Add the homee platform for the select component.""" - async_add_entities( - HomeeSelect(attribute, config_entry, SELECT_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in SELECT_DESCRIPTIONS and attribute.editable - ) + await setup_homee_platform(add_select_entities, async_add_entities, config_entry) class HomeeSelect(HomeeEntity, SelectEntity): diff --git a/homeassistant/components/homee/sensor.py b/homeassistant/components/homee/sensor.py index f977f705eb8..71508c5d669 100644 --- a/homeassistant/components/homee/sensor.py +++ b/homeassistant/components/homee/sensor.py @@ -35,7 +35,7 @@ from .const import ( WINDOW_MAP_REVERSED, ) from .entity import HomeeEntity, HomeeNodeEntity -from .helpers import get_name_for_enum +from .helpers import get_name_for_enum, setup_homee_platform PARALLEL_UPDATES = 0 @@ -304,16 +304,16 @@ def entity_used_in(hass: HomeAssistant, entity_id: str) -> list[str]: async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Add the homee platform for the sensor components.""" ent_reg = er.async_get(hass) - devices: list[HomeeSensor | HomeeNodeSensor] = [] def add_deprecated_entity( attribute: HomeeAttribute, description: HomeeSensorEntityDescription - ) -> None: + ) -> list[HomeeSensor]: """Add deprecated entities.""" + deprecated_entities: list[HomeeSensor] = [] entity_uid = f"{config_entry.runtime_data.settings.uid}-{attribute.node_id}-{attribute.id}" if entity_id := ent_reg.async_get_entity_id(SENSOR_DOMAIN, DOMAIN, entity_uid): entity_entry = ent_reg.async_get(entity_id) @@ -325,7 +325,9 @@ async def async_setup_entry( f"deprecated_entity_{entity_uid}", ) elif entity_entry: - devices.append(HomeeSensor(attribute, config_entry, description)) + deprecated_entities.append( + HomeeSensor(attribute, config_entry, description) + ) if entity_used_in(hass, entity_id): async_create_issue( hass, @@ -342,27 +344,42 @@ async def async_setup_entry( "entity": entity_id, }, ) + return deprecated_entities - for node in config_entry.runtime_data.nodes: - # Node properties that are sensors. - devices.extend( - HomeeNodeSensor(node, config_entry, description) - for description in NODE_SENSOR_DESCRIPTIONS - ) + async def add_sensor_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], + ) -> None: + """Add homee sensor entities.""" + entities: list[HomeeSensor | HomeeNodeSensor] = [] - # Node attributes that are sensors. - for attribute in node.attributes: - if attribute.type == AttributeType.CURRENT_VALVE_POSITION: - add_deprecated_entity(attribute, SENSOR_DESCRIPTIONS[attribute.type]) - elif attribute.type in SENSOR_DESCRIPTIONS and not attribute.editable: - devices.append( - HomeeSensor( - attribute, config_entry, SENSOR_DESCRIPTIONS[attribute.type] + for node in nodes: + # Node properties that are sensors. + entities.extend( + HomeeNodeSensor(node, config_entry, description) + for description in NODE_SENSOR_DESCRIPTIONS + ) + + # Node attributes that are sensors. + for attribute in node.attributes: + if attribute.type == AttributeType.CURRENT_VALVE_POSITION: + entities.extend( + add_deprecated_entity( + attribute, SENSOR_DESCRIPTIONS[attribute.type] + ) + ) + elif attribute.type in SENSOR_DESCRIPTIONS and not attribute.editable: + entities.append( + HomeeSensor( + attribute, config_entry, SENSOR_DESCRIPTIONS[attribute.type] + ) ) - ) - if devices: - async_add_devices(devices) + if entities: + async_add_entities(entities) + + await setup_homee_platform(add_sensor_entities, async_add_entities, config_entry) class HomeeSensor(HomeeEntity, SensorEntity): diff --git a/homeassistant/components/homee/siren.py b/homeassistant/components/homee/siren.py index da158c82f46..9970f396ef9 100644 --- a/homeassistant/components/homee/siren.py +++ b/homeassistant/components/homee/siren.py @@ -3,6 +3,7 @@ from typing import Any from pyHomee.const import AttributeType +from pyHomee.model import HomeeNode from homeassistant.components.siren import SirenEntity, SirenEntityFeature from homeassistant.core import HomeAssistant @@ -10,23 +11,33 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 +async def add_siren_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee siren entities.""" + async_add_entities( + HomeeSiren(attribute, config_entry) + for node in nodes + for attribute in node.attributes + if attribute.type == AttributeType.SIREN + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Add siren entities for homee.""" - async_add_devices( - HomeeSiren(attribute, config_entry) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type == AttributeType.SIREN - ) + await setup_homee_platform(add_siren_entities, async_add_entities, config_entry) class HomeeSiren(HomeeEntity, SirenEntity): diff --git a/homeassistant/components/homee/switch.py b/homeassistant/components/homee/switch.py index 5e87a1b4002..b620cb55c26 100644 --- a/homeassistant/components/homee/switch.py +++ b/homeassistant/components/homee/switch.py @@ -5,7 +5,7 @@ from dataclasses import dataclass from typing import Any from pyHomee.const import AttributeType, NodeProfile -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.switch import ( SwitchDeviceClass, @@ -19,6 +19,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .const import CLIMATE_PROFILES, LIGHT_PROFILES from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -65,27 +66,35 @@ SWITCH_DESCRIPTIONS: dict[AttributeType, HomeeSwitchEntityDescription] = { } +async def add_switch_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee switch entities.""" + async_add_entities( + HomeeSwitch(attribute, config_entry, SWITCH_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if (attribute.type in SWITCH_DESCRIPTIONS and attribute.editable) + and not ( + attribute.type == AttributeType.ON_OFF and node.profile in LIGHT_PROFILES + ) + and not ( + attribute.type == AttributeType.MANUAL_OPERATION + and node.profile in CLIMATE_PROFILES + ) + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, - async_add_devices: AddConfigEntryEntitiesCallback, + async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up the switch platform for the Homee component.""" - for node in config_entry.runtime_data.nodes: - async_add_devices( - HomeeSwitch(attribute, config_entry, SWITCH_DESCRIPTIONS[attribute.type]) - for attribute in node.attributes - if (attribute.type in SWITCH_DESCRIPTIONS and attribute.editable) - and not ( - attribute.type == AttributeType.ON_OFF - and node.profile in LIGHT_PROFILES - ) - and not ( - attribute.type == AttributeType.MANUAL_OPERATION - and node.profile in CLIMATE_PROFILES - ) - ) + await setup_homee_platform(add_switch_entities, async_add_entities, config_entry) class HomeeSwitch(HomeeEntity, SwitchEntity): diff --git a/homeassistant/components/homee/valve.py b/homeassistant/components/homee/valve.py index 995716d7ef8..64b1eac0efc 100644 --- a/homeassistant/components/homee/valve.py +++ b/homeassistant/components/homee/valve.py @@ -1,7 +1,7 @@ """The Homee valve platform.""" from pyHomee.const import AttributeType -from pyHomee.model import HomeeAttribute +from pyHomee.model import HomeeAttribute, HomeeNode from homeassistant.components.valve import ( ValveDeviceClass, @@ -14,6 +14,7 @@ from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback from . import HomeeConfigEntry from .entity import HomeeEntity +from .helpers import setup_homee_platform PARALLEL_UPDATES = 0 @@ -25,19 +26,28 @@ VALVE_DESCRIPTIONS = { } +async def add_valve_entities( + config_entry: HomeeConfigEntry, + async_add_entities: AddConfigEntryEntitiesCallback, + nodes: list[HomeeNode], +) -> None: + """Add homee valve entities.""" + async_add_entities( + HomeeValve(attribute, config_entry, VALVE_DESCRIPTIONS[attribute.type]) + for node in nodes + for attribute in node.attributes + if attribute.type in VALVE_DESCRIPTIONS + ) + + async def async_setup_entry( hass: HomeAssistant, config_entry: HomeeConfigEntry, async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: - """Add the Homee platform for the valve component.""" + """Add the homee platform for the valve component.""" - async_add_entities( - HomeeValve(attribute, config_entry, VALVE_DESCRIPTIONS[attribute.type]) - for node in config_entry.runtime_data.nodes - for attribute in node.attributes - if attribute.type in VALVE_DESCRIPTIONS - ) + await setup_homee_platform(add_valve_entities, async_add_entities, config_entry) class HomeeValve(HomeeEntity, ValveEntity): diff --git a/tests/components/homee/fixtures/add_device.json b/tests/components/homee/fixtures/add_device.json new file mode 100644 index 00000000000..e0876c30732 --- /dev/null +++ b/tests/components/homee/fixtures/add_device.json @@ -0,0 +1,176 @@ +{ + "id": 3, + "name": "Added Device", + "profile": 4010, + "image": "default", + "favorite": 0, + "order": 20, + "protocol": 1, + "routing": 0, + "state": 1, + "state_changed": 1709379826, + "added": 1676199446, + "history": 1, + "cube_type": 1, + "note": "", + "services": 5, + "phonetic_name": "", + "owner": 2, + "security": 0, + "attributes": [ + { + "id": 21, + "node_id": 3, + "instance": 1, + "minimum": 0, + "maximum": 200000, + "current_value": 555.591, + "target_value": 555.591, + "last_value": 555.586, + "unit": "kWh", + "step_value": 1.0, + "editable": 0, + "type": 4, + "state": 1, + "last_changed": 1694175270, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "" + }, + { + "id": 22, + "node_id": 3, + "instance": 0, + "minimum": 0, + "maximum": 1, + "current_value": 0.0, + "target_value": 0.0, + "last_value": 0.0, + "unit": "", + "step_value": 1.0, + "editable": 0, + "type": 17, + "state": 1, + "last_changed": 1691668428, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "", + "options": { + "automations": ["reset"], + "history": { + "day": 182, + "week": 26, + "month": 6, + "stepped": true + } + } + }, + { + "id": 27, + "node_id": 3, + "instance": 0, + "minimum": 0, + "maximum": 100, + "current_value": 100.0, + "target_value": 100.0, + "last_value": 100.0, + "unit": "%", + "step_value": 0.5, + "editable": 1, + "type": 349, + "state": 1, + "last_changed": 1624446307, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "" + }, + { + "id": 28, + "node_id": 3, + "instance": 0, + "minimum": 0, + "maximum": 1, + "current_value": 0.0, + "target_value": 0.0, + "last_value": 0.0, + "unit": "", + "step_value": 1.0, + "editable": 1, + "type": 346, + "state": 1, + "last_changed": 1624806728, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "" + }, + { + "id": 29, + "node_id": 3, + "instance": 0, + "minimum": 0, + "maximum": 1, + "current_value": 0.0, + "target_value": 0.0, + "last_value": 0.0, + "unit": "n/a", + "step_value": 1.0, + "editable": 1, + "type": 13, + "state": 1, + "last_changed": 1736003985, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "", + "options": { + "automations": ["toggle"], + "history": { + "day": 35, + "week": 5, + "month": 1, + "stepped": true + } + } + }, + { + "id": 30, + "node_id": 3, + "instance": 0, + "minimum": 0, + "maximum": 1, + "current_value": 1.0, + "target_value": 0.0, + "last_value": 0.0, + "unit": "n/a", + "step_value": 1.0, + "editable": 1, + "type": 1, + "state": 1, + "last_changed": 1736743294, + "changed_by": 1, + "changed_by_id": 0, + "based_on": 1, + "data": "", + "name": "", + "options": { + "can_observe": [300], + "automations": ["toggle"], + "history": { + "day": 35, + "week": 5, + "month": 1, + "stepped": true + } + } + } + ] +} diff --git a/tests/components/homee/snapshots/test_binary_sensor.ambr b/tests/components/homee/snapshots/test_binary_sensor.ambr index 0e9f02edf6c..f9f905bfc44 100644 --- a/tests/components/homee/snapshots/test_binary_sensor.ambr +++ b/tests/components/homee/snapshots/test_binary_sensor.ambr @@ -1,4 +1,1473 @@ # serializer version: 1 +# name: test_add_device[binary_sensor.added_device_blackout-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.added_device_blackout', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Blackout', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'blackout_alarm', + 'unique_id': '00055511EECC-3-22', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.added_device_blackout-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Added Device Blackout', + }), + 'context': , + 'entity_id': 'binary_sensor.added_device_blackout', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'battery', + 'unique_id': '00055511EECC-1-1', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'battery', + 'friendly_name': 'Test Binary Sensor Battery', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_blackout-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_blackout', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Blackout', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'blackout_alarm', + 'unique_id': '00055511EECC-1-2', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_blackout-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Blackout', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_blackout', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_carbon_dioxide-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_carbon_dioxide', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Carbon dioxide', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'carbon_dioxide', + 'unique_id': '00055511EECC-1-4', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_carbon_dioxide-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Carbon dioxide', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_carbon_dioxide', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_carbon_monoxide-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_carbon_monoxide', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Carbon monoxide', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'carbon_monoxide', + 'unique_id': '00055511EECC-1-3', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_carbon_monoxide-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'carbon_monoxide', + 'friendly_name': 'Test Binary Sensor Carbon monoxide', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_carbon_monoxide', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_flood-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_flood', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Flood', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'flood', + 'unique_id': '00055511EECC-1-5', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_flood-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'moisture', + 'friendly_name': 'Test Binary Sensor Flood', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_flood', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_high_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_high_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'High temperature', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'high_temperature', + 'unique_id': '00055511EECC-1-6', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_high_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'heat', + 'friendly_name': 'Test Binary Sensor High temperature', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_high_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_leak-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_leak', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Leak', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'leak_alarm', + 'unique_id': '00055511EECC-1-7', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_leak-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Leak', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_leak', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_load-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_load', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Load', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'load_alarm', + 'unique_id': '00055511EECC-1-8', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_load-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'friendly_name': 'Test Binary Sensor Load', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_load', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_lock-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_lock', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Lock', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'lock', + 'unique_id': '00055511EECC-1-9', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_lock-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'lock', + 'friendly_name': 'Test Binary Sensor Lock', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_lock', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_low_temperature-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_low_temperature', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Low temperature', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'low_temperature', + 'unique_id': '00055511EECC-1-10', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_low_temperature-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'cold', + 'friendly_name': 'Test Binary Sensor Low temperature', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_low_temperature', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_malfunction-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_malfunction', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Malfunction', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'malfunction', + 'unique_id': '00055511EECC-1-11', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_malfunction-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Malfunction', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_malfunction', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_maximum_level-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_maximum_level', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Maximum level', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'maximum', + 'unique_id': '00055511EECC-1-12', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_maximum_level-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Maximum level', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_maximum_level', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_minimum_level-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_minimum_level', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Minimum level', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'minimum', + 'unique_id': '00055511EECC-1-13', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_minimum_level-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Minimum level', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_minimum_level', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_motion-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_motion', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Motion', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'motion', + 'unique_id': '00055511EECC-1-14', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_motion-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'motion', + 'friendly_name': 'Test Binary Sensor Motion', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_motion', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_motor_blocked-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_motor_blocked', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Motor blocked', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'motor_blocked', + 'unique_id': '00055511EECC-1-15', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_motor_blocked-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Motor blocked', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_motor_blocked', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'on', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_opening-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_opening', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Opening', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'opening', + 'unique_id': '00055511EECC-1-17', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_opening-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'opening', + 'friendly_name': 'Test Binary Sensor Opening', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_opening', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_overcurrent-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_overcurrent', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Overcurrent', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'overcurrent', + 'unique_id': '00055511EECC-1-18', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_overcurrent-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Overcurrent', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_overcurrent', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_overload-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_overload', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Overload', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'overload', + 'unique_id': '00055511EECC-1-19', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_overload-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Overload', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_overload', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_plug-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_plug', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Plug', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'plug', + 'unique_id': '00055511EECC-1-16', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_plug-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'plug', + 'friendly_name': 'Test Binary Sensor Plug', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_plug', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_power-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_power', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Power', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'power', + 'unique_id': '00055511EECC-1-21', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_power-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'power', + 'friendly_name': 'Test Binary Sensor Power', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_power', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_presence-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_presence', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Presence', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'presence', + 'unique_id': '00055511EECC-1-20', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_presence-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'presence', + 'friendly_name': 'Test Binary Sensor Presence', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_presence', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_rain-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_rain', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Rain', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'rain', + 'unique_id': '00055511EECC-1-22', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_rain-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'moisture', + 'friendly_name': 'Test Binary Sensor Rain', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_rain', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_replace_filter-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_replace_filter', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Replace filter', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'replace_filter', + 'unique_id': '00055511EECC-1-23', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_replace_filter-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Replace filter', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_replace_filter', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_smoke-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': None, + 'entity_id': 'binary_sensor.test_binary_sensor_smoke', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Smoke', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'smoke', + 'unique_id': '00055511EECC-1-24', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_smoke-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'smoke', + 'friendly_name': 'Test Binary Sensor Smoke', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_smoke', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_storage-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_storage', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Storage', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'storage', + 'unique_id': '00055511EECC-1-25', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_storage-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Storage', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_storage', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_surge-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_surge', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Surge', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'surge', + 'unique_id': '00055511EECC-1-26', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_surge-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Surge', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_surge', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_tamper-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_tamper', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Tamper', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'tamper', + 'unique_id': '00055511EECC-1-27', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_tamper-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'tamper', + 'friendly_name': 'Test Binary Sensor Tamper', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_tamper', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_voltage_drop-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_voltage_drop', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Voltage drop', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'voltage_drop', + 'unique_id': '00055511EECC-1-28', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_voltage_drop-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'problem', + 'friendly_name': 'Test Binary Sensor Voltage drop', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_voltage_drop', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_water-entry] + EntityRegistryEntrySnapshot({ + 'aliases': set({ + }), + 'area_id': None, + 'capabilities': None, + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'binary_sensor', + 'entity_category': , + 'entity_id': 'binary_sensor.test_binary_sensor_water', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Water', + 'platform': 'homee', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'water', + 'unique_id': '00055511EECC-1-29', + 'unit_of_measurement': None, + }) +# --- +# name: test_add_device[binary_sensor.test_binary_sensor_water-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + 'device_class': 'moisture', + 'friendly_name': 'Test Binary Sensor Water', + }), + 'context': , + 'entity_id': 'binary_sensor.test_binary_sensor_water', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': 'off', + }) +# --- # name: test_sensor_snapshot[binary_sensor.test_binary_sensor_battery-entry] EntityRegistryEntrySnapshot({ 'aliases': set({ diff --git a/tests/components/homee/test_binary_sensor.py b/tests/components/homee/test_binary_sensor.py index 50662616379..ef3cf8ecee3 100644 --- a/tests/components/homee/test_binary_sensor.py +++ b/tests/components/homee/test_binary_sensor.py @@ -27,3 +27,26 @@ async def test_sensor_snapshot( await setup_integration(hass, mock_config_entry) await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id) + + +async def test_add_device( + hass: HomeAssistant, + mock_homee: MagicMock, + mock_config_entry: MockConfigEntry, + entity_registry: er.EntityRegistry, + snapshot: SnapshotAssertion, +) -> None: + """Test adding a device.""" + mock_homee.nodes = [build_mock_node("binary_sensors.json")] + mock_homee.get_node_by_id.return_value = mock_homee.nodes[0] + with patch("homeassistant.components.homee.PLATFORMS", [Platform.BINARY_SENSOR]): + await setup_integration(hass, mock_config_entry) + + # Add a new device + added_node = build_mock_node("add_device.json") + mock_homee.nodes.append(added_node) + mock_homee.get_node_by_id.return_value = mock_homee.nodes[1] + await mock_homee.add_nodes_listener.call_args_list[0][0][0](added_node, True) + await hass.async_block_till_done() + + await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)