mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 02:28:21 +00:00
First review fixes
This commit is contained in:
parent
d8bb74c4b6
commit
526b344456
@ -26,10 +26,14 @@ class HomeeEntity(Entity):
|
||||
f"{entry.runtime_data.settings.uid}-{attribute.node_id}-{attribute.id}"
|
||||
)
|
||||
self._entry = entry
|
||||
node = entry.runtime_data.get_node_by_id(attribute.node_id)
|
||||
self._attr_device_info = DeviceInfo(
|
||||
identifiers={
|
||||
(DOMAIN, f"{entry.runtime_data.settings.uid}-{attribute.node_id}")
|
||||
}
|
||||
},
|
||||
name=node.name,
|
||||
model=get_name_for_enum(NodeProfile, node.profile),
|
||||
via_device=(DOMAIN, entry.runtime_data.settings.uid),
|
||||
)
|
||||
|
||||
self._host_connected = entry.runtime_data.connected
|
||||
|
@ -153,57 +153,24 @@
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"automatic_mode_impulse": {
|
||||
"name": "Automatic Mode Impulse"
|
||||
},
|
||||
"briefly_open_impulse": {
|
||||
"name": "Briefly Open Impulse"
|
||||
},
|
||||
"external_binary_input": {
|
||||
"name": "Child Lock"
|
||||
},
|
||||
"identification_mode": {
|
||||
"name": "Identification Mode"
|
||||
},
|
||||
"impulse": {
|
||||
"name": "Impulse"
|
||||
},
|
||||
"impulse_instance": {
|
||||
"name": "Impulse {instance}"
|
||||
},
|
||||
"light_impulse": {
|
||||
"name": "Light Impulse"
|
||||
},
|
||||
"light_impulse_instance": {
|
||||
"name": "Light Impulse {instance}"
|
||||
},
|
||||
"manual_operation": {
|
||||
"name": "Manual Operation"
|
||||
},
|
||||
"motor_rotation": {
|
||||
"name": "Motor rotation direction"
|
||||
},
|
||||
"open_partial_impulse": {
|
||||
"name": "Open Partial Impulse"
|
||||
},
|
||||
"permanently_open_impulse": {
|
||||
"name": "Permanently Open Impulse"
|
||||
},
|
||||
"reset_meter": {
|
||||
"name": "Reset Meter"
|
||||
},
|
||||
"reset_meter_instance": {
|
||||
"name": "Reset Meter {instance}"
|
||||
},
|
||||
"restore_last_known_state": {
|
||||
"name": "Restore last known state"
|
||||
},
|
||||
"switch_type": {
|
||||
"name": "Switch Type"
|
||||
},
|
||||
"ventilate_impulse": {
|
||||
"name": "Ventilate Impulse"
|
||||
},
|
||||
"watchdog_on_off": {
|
||||
"name": "Watchdog"
|
||||
}
|
||||
|
@ -47,47 +47,27 @@ class HomeeSwitchEntityDescription(SwitchEntityDescription):
|
||||
|
||||
|
||||
SWITCH_DESCRIPTIONS: dict[AttributeType, HomeeSwitchEntityDescription] = {
|
||||
AttributeType.AUTOMATIC_MODE_IMPULSE: HomeeSwitchEntityDescription(
|
||||
key="automatic_mode_impulse"
|
||||
),
|
||||
AttributeType.BRIEFLY_OPEN_IMPULSE: HomeeSwitchEntityDescription(
|
||||
key="briefly_open_impulse"
|
||||
),
|
||||
AttributeType.EXTERNAL_BINARY_INPUT: HomeeSwitchEntityDescription(
|
||||
key="external_binary_input", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
AttributeType.IDENTIFICATION_MODE: HomeeSwitchEntityDescription(
|
||||
key="identification_mode", entity_category=EntityCategory.DIAGNOSTIC
|
||||
),
|
||||
AttributeType.IMPULSE: HomeeSwitchEntityDescription(key="impulse"),
|
||||
AttributeType.LIGHT_IMPULSE: HomeeSwitchEntityDescription(key="light_impulse"),
|
||||
AttributeType.MANUAL_OPERATION: HomeeSwitchEntityDescription(
|
||||
key="manual_operation"
|
||||
),
|
||||
AttributeType.MOTOR_ROTATION: HomeeSwitchEntityDescription(
|
||||
key="motor_rotation", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
AttributeType.OPEN_PARTIAL_IMPULSE: HomeeSwitchEntityDescription(
|
||||
key="open_partial_impulse"
|
||||
),
|
||||
AttributeType.ON_OFF: HomeeSwitchEntityDescription(
|
||||
key="on_off", device_class_fn=get_device_class, name=None
|
||||
),
|
||||
AttributeType.PERMANENTLY_OPEN_IMPULSE: HomeeSwitchEntityDescription(
|
||||
key="permanently_open_impulse"
|
||||
),
|
||||
AttributeType.RESET_METER: HomeeSwitchEntityDescription(
|
||||
key="reset_meter", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
AttributeType.RESTORE_LAST_KNOWN_STATE: HomeeSwitchEntityDescription(
|
||||
key="restore_last_known_state", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
AttributeType.SWITCH_TYPE: HomeeSwitchEntityDescription(
|
||||
key="switch_type", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
AttributeType.VENTILATE_IMPULSE: HomeeSwitchEntityDescription(
|
||||
key="ventilate_impulse"
|
||||
),
|
||||
AttributeType.WATCHDOG_ON_OFF: HomeeSwitchEntityDescription(
|
||||
key="watchdog_on_off", entity_category=EntityCategory.CONFIG
|
||||
),
|
||||
@ -99,7 +79,7 @@ async def async_setup_entry(
|
||||
config_entry: HomeeConfigEntry,
|
||||
async_add_devices: AddEntitiesCallback,
|
||||
) -> None:
|
||||
"""Add the homee platform for the switch component."""
|
||||
"""Add the Homee platform for the switch component."""
|
||||
|
||||
devices: list[HomeeSwitch] = []
|
||||
for node in config_entry.runtime_data.nodes:
|
||||
@ -126,7 +106,7 @@ async def async_setup_entry(
|
||||
|
||||
|
||||
class HomeeSwitch(HomeeEntity, SwitchEntity):
|
||||
"""Representation of a homee switch."""
|
||||
"""Representation of a Homee switch."""
|
||||
|
||||
entity_description: HomeeSwitchEntityDescription
|
||||
|
||||
@ -136,14 +116,11 @@ class HomeeSwitch(HomeeEntity, SwitchEntity):
|
||||
entry: HomeeConfigEntry,
|
||||
description: HomeeSwitchEntityDescription,
|
||||
) -> None:
|
||||
"""Initialize a homee switch entity."""
|
||||
"""Initialize a Homee switch entity."""
|
||||
super().__init__(attribute, entry)
|
||||
self.entity_description = description
|
||||
self._attr_is_on = bool(attribute.current_value)
|
||||
if not (
|
||||
(attribute.type in [AttributeType.ON_OFF, AttributeType.IMPULSE])
|
||||
and (attribute.instance == 0)
|
||||
):
|
||||
if not ((attribute.type == AttributeType.ON_OFF) and (attribute.instance == 0)):
|
||||
self._attr_translation_key = description.key
|
||||
if attribute.instance > 0:
|
||||
self._attr_translation_key = f"{self._attr_translation_key}_instance"
|
||||
@ -155,9 +132,9 @@ class HomeeSwitch(HomeeEntity, SwitchEntity):
|
||||
return self.entity_description.device_class_fn(self._attribute, self._entry)
|
||||
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity on."""
|
||||
"""Turn the switch on."""
|
||||
await self.async_set_value(1)
|
||||
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the entity off."""
|
||||
"""Turn the switch off."""
|
||||
await self.async_set_value(0)
|
||||
|
@ -67,5 +67,6 @@ def mock_homee() -> Generator[AsyncMock]:
|
||||
homee.connected = True
|
||||
|
||||
homee.get_access_token.return_value = "test_token"
|
||||
homee.get_node_by_id.return_value = None
|
||||
|
||||
yield homee
|
||||
|
@ -18,6 +18,27 @@
|
||||
"owner": 2,
|
||||
"security": 0,
|
||||
"attributes": [
|
||||
{
|
||||
"id": 3,
|
||||
"node_id": 1,
|
||||
"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": 309,
|
||||
"state": 1,
|
||||
"last_changed": 1677692134,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"node_id": 1,
|
||||
@ -60,48 +81,6 @@
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"node_id": 1,
|
||||
"instance": 2,
|
||||
"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": 304,
|
||||
"state": 1,
|
||||
"last_changed": 1738679948,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 4,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"node_id": 1,
|
||||
"instance": 0,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 1.0,
|
||||
"unit": "n/a",
|
||||
"step_value": 1.0,
|
||||
"editable": 1,
|
||||
"type": 305,
|
||||
"state": 1,
|
||||
"last_changed": 1677692134,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"node_id": 1,
|
||||
@ -144,27 +123,6 @@
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"node_id": 1,
|
||||
"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": 306,
|
||||
"state": 1,
|
||||
"last_changed": 1677692134,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"node_id": 1,
|
||||
@ -186,27 +144,6 @@
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"node_id": 1,
|
||||
"instance": 1,
|
||||
"minimum": 0,
|
||||
"maximum": 1,
|
||||
"current_value": 0.0,
|
||||
"target_value": 0.0,
|
||||
"last_value": 0.0,
|
||||
"unit": "",
|
||||
"step_value": 1.0,
|
||||
"editable": 1,
|
||||
"type": 347,
|
||||
"state": 1,
|
||||
"last_changed": 1682166449,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"node_id": 1,
|
||||
@ -270,27 +207,6 @@
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"node_id": 1,
|
||||
"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": 378,
|
||||
"state": 1,
|
||||
"last_changed": 1677692134,
|
||||
"changed_by": 1,
|
||||
"changed_by_id": 0,
|
||||
"based_on": 1,
|
||||
"data": "",
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"node_id": 1,
|
||||
|
@ -1,5 +1,5 @@
|
||||
# serializer version: 1
|
||||
# name: test_switch_snapshot[switch.homee_00055511eecc_1_11-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -11,7 +11,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.homee_00055511eecc_1_11',
|
||||
'entity_id': 'switch.test_switch',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -32,20 +32,68 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.homee_00055511eecc_1_11-state]
|
||||
# name: test_switch_snapshot[switch.test_switch-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'outlet',
|
||||
'friendly_name': 'Test Switch',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.homee_00055511eecc_1_11',
|
||||
'entity_id': 'switch.test_switch',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_identification_mode-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch_child_lock-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.test_switch_child_lock',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Child Lock',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'external_binary_input',
|
||||
'unique_id': '00055511EECC-1-3',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.test_switch_child_lock-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Test Switch Child Lock',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.test_switch_child_lock',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.test_switch_identification_mode-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -57,7 +105,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.DIAGNOSTIC: 'diagnostic'>,
|
||||
'entity_id': 'switch.none_identification_mode',
|
||||
'entity_id': 'switch.test_switch_identification_mode',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -78,21 +126,21 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_identification_mode-state]
|
||||
# name: test_switch_snapshot[switch.test_switch_identification_mode-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Identification Mode',
|
||||
'friendly_name': 'Test Switch Identification Mode',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_identification_mode',
|
||||
'entity_id': 'switch.test_switch_identification_mode',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_impulse_1-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch_manual_operation-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -104,148 +152,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_impulse_1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Impulse 1',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'impulse_instance',
|
||||
'unique_id': '00055511EECC-1-5',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_impulse_1-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Impulse 1',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_impulse_1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_impulse_2-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_impulse_2',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Impulse 2',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'impulse_instance',
|
||||
'unique_id': '00055511EECC-1-6',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_impulse_2-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Impulse 2',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_impulse_2',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_light_impulse-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_light_impulse',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Light Impulse',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'light_impulse',
|
||||
'unique_id': '00055511EECC-1-7',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_light_impulse-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Light Impulse',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_light_impulse',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_manual_operation-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_manual_operation',
|
||||
'entity_id': 'switch.test_switch_manual_operation',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -266,21 +173,21 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_manual_operation-state]
|
||||
# name: test_switch_snapshot[switch.test_switch_manual_operation-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Manual Operation',
|
||||
'friendly_name': 'Test Switch Manual Operation',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_manual_operation',
|
||||
'entity_id': 'switch.test_switch_manual_operation',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_motor_rotation_direction-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch_motor_rotation_direction-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -292,7 +199,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.none_motor_rotation_direction',
|
||||
'entity_id': 'switch.test_switch_motor_rotation_direction',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -313,68 +220,21 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_motor_rotation_direction-state]
|
||||
# name: test_switch_snapshot[switch.test_switch_motor_rotation_direction-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Motor rotation direction',
|
||||
'friendly_name': 'Test Switch Motor rotation direction',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_motor_rotation_direction',
|
||||
'entity_id': 'switch.test_switch_motor_rotation_direction',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_open_partial_impulse-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_open_partial_impulse',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Open Partial Impulse',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'open_partial_impulse',
|
||||
'unique_id': '00055511EECC-1-10',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_open_partial_impulse-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Open Partial Impulse',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_open_partial_impulse',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_reset_meter_1-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch_restore_last_known_state-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -386,54 +246,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.none_reset_meter_1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Reset Meter 1',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'reset_meter_instance',
|
||||
'unique_id': '00055511EECC-1-13',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_reset_meter_1-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Reset Meter 1',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_reset_meter_1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_restore_last_known_state-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.none_restore_last_known_state',
|
||||
'entity_id': 'switch.test_switch_restore_last_known_state',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -454,68 +267,21 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_restore_last_known_state-state]
|
||||
# name: test_switch_snapshot[switch.test_switch_restore_last_known_state-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Restore last known state',
|
||||
'friendly_name': 'Test Switch Restore last known state',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_restore_last_known_state',
|
||||
'entity_id': 'switch.test_switch_restore_last_known_state',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'on',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_ventilate_impulse-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': None,
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': None,
|
||||
'entity_id': 'switch.none_ventilate_impulse',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SwitchDeviceClass.SWITCH: 'switch'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Ventilate Impulse',
|
||||
'platform': 'homee',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': 'ventilate_impulse',
|
||||
'unique_id': '00055511EECC-1-17',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_ventilate_impulse-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Ventilate Impulse',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_ventilate_impulse',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'off',
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_watchdog-entry]
|
||||
# name: test_switch_snapshot[switch.test_switch_watchdog-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
@ -527,7 +293,7 @@
|
||||
'disabled_by': None,
|
||||
'domain': 'switch',
|
||||
'entity_category': <EntityCategory.CONFIG: 'config'>,
|
||||
'entity_id': 'switch.none_watchdog',
|
||||
'entity_id': 'switch.test_switch_watchdog',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
@ -548,14 +314,14 @@
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_switch_snapshot[switch.none_watchdog-state]
|
||||
# name: test_switch_snapshot[switch.test_switch_watchdog-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'switch',
|
||||
'friendly_name': 'Watchdog',
|
||||
'friendly_name': 'Test Switch Watchdog',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'switch.none_watchdog',
|
||||
'entity_id': 'switch.test_switch_watchdog',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
|
@ -27,6 +27,7 @@ async def test_switch_on(
|
||||
) -> None:
|
||||
"""Test turn-on service."""
|
||||
mock_homee.nodes = [build_mock_node("switches.json")]
|
||||
mock_homee.get_node_by_id.return_value = mock_homee.nodes[0]
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert hass.states.get("switch.test_switch").state is not STATE_ON
|
||||
@ -47,6 +48,7 @@ async def test_switch_off(
|
||||
) -> None:
|
||||
"""Test turn-off service."""
|
||||
mock_homee.nodes = [build_mock_node("switches.json")]
|
||||
mock_homee.get_node_by_id.return_value = mock_homee.nodes[0]
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
assert hass.states.get("switch.test_switch_identification_mode").state is STATE_ON
|
||||
@ -74,7 +76,7 @@ async def test_switch_device_class(
|
||||
== SwitchDeviceClass.OUTLET
|
||||
)
|
||||
assert (
|
||||
hass.states.get("switch.test_switch_impulse_2").attributes["device_class"]
|
||||
hass.states.get("switch.test_switch_watchdog").attributes["device_class"]
|
||||
== SwitchDeviceClass.SWITCH
|
||||
)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user