Add has_entity_name attribute to LCN entities (#145045)

* Add _attr_has_entity_name

* Fix tests
This commit is contained in:
Andre Lengwenus 2025-05-18 16:48:44 +02:00 committed by GitHub
parent 3eb0c8ddff
commit 2aba4f261f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 208 additions and 191 deletions

View File

@ -23,6 +23,7 @@ class LcnEntity(Entity):
"""Parent class for all entities associated with the LCN component."""
_attr_should_poll = False
_attr_has_entity_name = True
device_connection: DeviceConnectionType
def __init__(

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_binary_sensor[binary_sensor.binary_sensor1-entry]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_binary_sensor1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -12,8 +12,8 @@
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.binary_sensor1',
'has_entity_name': False,
'entity_id': 'binary_sensor.testmodule_binary_sensor1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -33,20 +33,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_binary_sensor[binary_sensor.binary_sensor1-state]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_binary_sensor1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Binary_Sensor1',
'friendly_name': 'TestModule Binary_Sensor1',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.binary_sensor1',
'entity_id': 'binary_sensor.testmodule_binary_sensor1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_binary_sensor[binary_sensor.sensor_keylock-entry]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_sensor_keylock-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -59,8 +59,8 @@
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.sensor_keylock',
'has_entity_name': False,
'entity_id': 'binary_sensor.testmodule_sensor_keylock',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -80,20 +80,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_binary_sensor[binary_sensor.sensor_keylock-state]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_sensor_keylock-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Sensor_KeyLock',
'friendly_name': 'TestModule Sensor_KeyLock',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.sensor_keylock',
'entity_id': 'binary_sensor.testmodule_sensor_keylock',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_binary_sensor[binary_sensor.sensor_lockregulator1-entry]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_sensor_lockregulator1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -106,8 +106,8 @@
'disabled_by': None,
'domain': 'binary_sensor',
'entity_category': None,
'entity_id': 'binary_sensor.sensor_lockregulator1',
'has_entity_name': False,
'entity_id': 'binary_sensor.testmodule_sensor_lockregulator1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -127,13 +127,13 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_binary_sensor[binary_sensor.sensor_lockregulator1-state]
# name: test_setup_lcn_binary_sensor[binary_sensor.testmodule_sensor_lockregulator1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Sensor_LockRegulator1',
'friendly_name': 'TestModule Sensor_LockRegulator1',
}),
'context': <ANY>,
'entity_id': 'binary_sensor.sensor_lockregulator1',
'entity_id': 'binary_sensor.testmodule_sensor_lockregulator1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_climate[climate.climate1-entry]
# name: test_setup_lcn_climate[climate.testmodule_climate1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -19,8 +19,8 @@
'disabled_by': None,
'domain': 'climate',
'entity_category': None,
'entity_id': 'climate.climate1',
'has_entity_name': False,
'entity_id': 'climate.testmodule_climate1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -40,11 +40,11 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_climate[climate.climate1-state]
# name: test_setup_lcn_climate[climate.testmodule_climate1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'current_temperature': None,
'friendly_name': 'Climate1',
'friendly_name': 'TestModule Climate1',
'hvac_modes': list([
<HVACMode.HEAT: 'heat'>,
<HVACMode.OFF: 'off'>,
@ -55,7 +55,7 @@
'temperature': None,
}),
'context': <ANY>,
'entity_id': 'climate.climate1',
'entity_id': 'climate.testmodule_climate1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_cover[cover.cover_outputs-entry]
# name: test_setup_lcn_cover[cover.testmodule_cover_outputs-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -12,8 +12,8 @@
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.cover_outputs',
'has_entity_name': False,
'entity_id': 'cover.testmodule_cover_outputs',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -33,22 +33,22 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_cover[cover.cover_outputs-state]
# name: test_setup_lcn_cover[cover.testmodule_cover_outputs-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'assumed_state': True,
'friendly_name': 'Cover_Outputs',
'friendly_name': 'TestModule Cover_Outputs',
'supported_features': <CoverEntityFeature: 11>,
}),
'context': <ANY>,
'entity_id': 'cover.cover_outputs',
'entity_id': 'cover.testmodule_cover_outputs',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays-entry]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -61,8 +61,8 @@
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.cover_relays',
'has_entity_name': False,
'entity_id': 'cover.testmodule_cover_relays',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -82,22 +82,22 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays-state]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'assumed_state': True,
'friendly_name': 'Cover_Relays',
'friendly_name': 'TestModule Cover_Relays',
'supported_features': <CoverEntityFeature: 11>,
}),
'context': <ANY>,
'entity_id': 'cover.cover_relays',
'entity_id': 'cover.testmodule_cover_relays',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays_bs4-entry]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays_bs4-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -110,8 +110,8 @@
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.cover_relays_bs4',
'has_entity_name': False,
'entity_id': 'cover.testmodule_cover_relays_bs4',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -131,22 +131,22 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays_bs4-state]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays_bs4-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'assumed_state': True,
'friendly_name': 'Cover_Relays_BS4',
'friendly_name': 'TestModule Cover_Relays_BS4',
'supported_features': <CoverEntityFeature: 15>,
}),
'context': <ANY>,
'entity_id': 'cover.cover_relays_bs4',
'entity_id': 'cover.testmodule_cover_relays_bs4',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'open',
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays_module-entry]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays_module-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -159,8 +159,8 @@
'disabled_by': None,
'domain': 'cover',
'entity_category': None,
'entity_id': 'cover.cover_relays_module',
'has_entity_name': False,
'entity_id': 'cover.testmodule_cover_relays_module',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -180,15 +180,15 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_cover[cover.cover_relays_module-state]
# name: test_setup_lcn_cover[cover.testmodule_cover_relays_module-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'assumed_state': True,
'friendly_name': 'Cover_Relays_Module',
'friendly_name': 'TestModule Cover_Relays_Module',
'supported_features': <CoverEntityFeature: 15>,
}),
'context': <ANY>,
'entity_id': 'cover.cover_relays_module',
'entity_id': 'cover.testmodule_cover_relays_module',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_light[light.light_output1-entry]
# name: test_setup_lcn_light[light.testmodule_light_output1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -16,8 +16,8 @@
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.light_output1',
'has_entity_name': False,
'entity_id': 'light.testmodule_light_output1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -37,26 +37,26 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_light[light.light_output1-state]
# name: test_setup_lcn_light[light.testmodule_light_output1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'brightness': None,
'color_mode': None,
'friendly_name': 'Light_Output1',
'friendly_name': 'TestModule Light_Output1',
'supported_color_modes': list([
<ColorMode.BRIGHTNESS: 'brightness'>,
]),
'supported_features': <LightEntityFeature: 32>,
}),
'context': <ANY>,
'entity_id': 'light.light_output1',
'entity_id': 'light.testmodule_light_output1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_light[light.light_output2-entry]
# name: test_setup_lcn_light[light.testmodule_light_output2-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -73,8 +73,8 @@
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.light_output2',
'has_entity_name': False,
'entity_id': 'light.testmodule_light_output2',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -94,25 +94,25 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_light[light.light_output2-state]
# name: test_setup_lcn_light[light.testmodule_light_output2-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'color_mode': None,
'friendly_name': 'Light_Output2',
'friendly_name': 'TestModule Light_Output2',
'supported_color_modes': list([
<ColorMode.ONOFF: 'onoff'>,
]),
'supported_features': <LightEntityFeature: 32>,
}),
'context': <ANY>,
'entity_id': 'light.light_output2',
'entity_id': 'light.testmodule_light_output2',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_light[light.light_relay1-entry]
# name: test_setup_lcn_light[light.testmodule_light_relay1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -129,8 +129,8 @@
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.light_relay1',
'has_entity_name': False,
'entity_id': 'light.testmodule_light_relay1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -150,18 +150,18 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_light[light.light_relay1-state]
# name: test_setup_lcn_light[light.testmodule_light_relay1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'color_mode': None,
'friendly_name': 'Light_Relay1',
'friendly_name': 'TestModule Light_Relay1',
'supported_color_modes': list([
<ColorMode.ONOFF: 'onoff'>,
]),
'supported_features': <LightEntityFeature: 0>,
}),
'context': <ANY>,
'entity_id': 'light.light_relay1',
'entity_id': 'light.testmodule_light_relay1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_scene[scene.romantic-entry]
# name: test_setup_lcn_scene[scene.testmodule_romantic-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -12,8 +12,8 @@
'disabled_by': None,
'domain': 'scene',
'entity_category': None,
'entity_id': 'scene.romantic',
'has_entity_name': False,
'entity_id': 'scene.testmodule_romantic',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -33,20 +33,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_scene[scene.romantic-state]
# name: test_setup_lcn_scene[scene.testmodule_romantic-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Romantic',
'friendly_name': 'TestModule Romantic',
}),
'context': <ANY>,
'entity_id': 'scene.romantic',
'entity_id': 'scene.testmodule_romantic',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_scene[scene.romantic_transition-entry]
# name: test_setup_lcn_scene[scene.testmodule_romantic_transition-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -59,8 +59,8 @@
'disabled_by': None,
'domain': 'scene',
'entity_category': None,
'entity_id': 'scene.romantic_transition',
'has_entity_name': False,
'entity_id': 'scene.testmodule_romantic_transition',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -80,13 +80,13 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_scene[scene.romantic_transition-state]
# name: test_setup_lcn_scene[scene.testmodule_romantic_transition-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Romantic Transition',
'friendly_name': 'TestModule Romantic Transition',
}),
'context': <ANY>,
'entity_id': 'scene.romantic_transition',
'entity_id': 'scene.testmodule_romantic_transition',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_sensor[sensor.sensor_led6-entry]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_led6-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -12,8 +12,8 @@
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.sensor_led6',
'has_entity_name': False,
'entity_id': 'sensor.testmodule_sensor_led6',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -33,20 +33,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_led6-state]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_led6-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Sensor_Led6',
'friendly_name': 'TestModule Sensor_Led6',
}),
'context': <ANY>,
'entity_id': 'sensor.sensor_led6',
'entity_id': 'sensor.testmodule_sensor_led6',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_logicop1-entry]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_logicop1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -59,8 +59,8 @@
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.sensor_logicop1',
'has_entity_name': False,
'entity_id': 'sensor.testmodule_sensor_logicop1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -80,20 +80,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_logicop1-state]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_logicop1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Sensor_LogicOp1',
'friendly_name': 'TestModule Sensor_LogicOp1',
}),
'context': <ANY>,
'entity_id': 'sensor.sensor_logicop1',
'entity_id': 'sensor.testmodule_sensor_logicop1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_setpoint1-entry]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_setpoint1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -106,8 +106,8 @@
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.sensor_setpoint1',
'has_entity_name': False,
'entity_id': 'sensor.testmodule_sensor_setpoint1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -127,22 +127,22 @@
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_setpoint1-state]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_setpoint1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'Sensor_Setpoint1',
'friendly_name': 'TestModule Sensor_Setpoint1',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.sensor_setpoint1',
'entity_id': 'sensor.testmodule_sensor_setpoint1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'unknown',
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_var1-entry]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_var1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -155,8 +155,8 @@
'disabled_by': None,
'domain': 'sensor',
'entity_category': None,
'entity_id': 'sensor.sensor_var1',
'has_entity_name': False,
'entity_id': 'sensor.testmodule_sensor_var1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -176,15 +176,15 @@
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
})
# ---
# name: test_setup_lcn_sensor[sensor.sensor_var1-state]
# name: test_setup_lcn_sensor[sensor.testmodule_sensor_var1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'device_class': 'temperature',
'friendly_name': 'Sensor_Var1',
'friendly_name': 'TestModule Sensor_Var1',
'unit_of_measurement': <UnitOfTemperature.CELSIUS: '°C'>,
}),
'context': <ANY>,
'entity_id': 'sensor.sensor_var1',
'entity_id': 'sensor.testmodule_sensor_var1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -1,5 +1,5 @@
# serializer version: 1
# name: test_setup_lcn_switch[switch.switch_group5-entry]
# name: test_setup_lcn_switch[switch.testgroup_switch_group5-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -12,8 +12,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_group5',
'has_entity_name': False,
'entity_id': 'switch.testgroup_switch_group5',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -33,20 +33,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_group5-state]
# name: test_setup_lcn_switch[switch.testgroup_switch_group5-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Group5',
'friendly_name': 'TestGroup Switch_Group5',
}),
'context': <ANY>,
'entity_id': 'switch.switch_group5',
'entity_id': 'switch.testgroup_switch_group5',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_keylock1-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_keylock1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -59,8 +59,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_keylock1',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_keylock1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -80,20 +80,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_keylock1-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_keylock1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_KeyLock1',
'friendly_name': 'TestModule Switch_KeyLock1',
}),
'context': <ANY>,
'entity_id': 'switch.switch_keylock1',
'entity_id': 'switch.testmodule_switch_keylock1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_output1-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_output1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -106,8 +106,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_output1',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_output1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -127,20 +127,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_output1-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_output1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Output1',
'friendly_name': 'TestModule Switch_Output1',
}),
'context': <ANY>,
'entity_id': 'switch.switch_output1',
'entity_id': 'switch.testmodule_switch_output1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_output2-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_output2-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -153,8 +153,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_output2',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_output2',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -174,20 +174,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_output2-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_output2-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Output2',
'friendly_name': 'TestModule Switch_Output2',
}),
'context': <ANY>,
'entity_id': 'switch.switch_output2',
'entity_id': 'switch.testmodule_switch_output2',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_regulator1-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_regulator1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -200,8 +200,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_regulator1',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_regulator1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -221,20 +221,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_regulator1-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_regulator1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Regulator1',
'friendly_name': 'TestModule Switch_Regulator1',
}),
'context': <ANY>,
'entity_id': 'switch.switch_regulator1',
'entity_id': 'switch.testmodule_switch_regulator1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_relay1-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_relay1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -247,8 +247,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_relay1',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_relay1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -268,20 +268,20 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_relay1-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_relay1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Relay1',
'friendly_name': 'TestModule Switch_Relay1',
}),
'context': <ANY>,
'entity_id': 'switch.switch_relay1',
'entity_id': 'switch.testmodule_switch_relay1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'off',
})
# ---
# name: test_setup_lcn_switch[switch.switch_relay2-entry]
# name: test_setup_lcn_switch[switch.testmodule_switch_relay2-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
@ -294,8 +294,8 @@
'disabled_by': None,
'domain': 'switch',
'entity_category': None,
'entity_id': 'switch.switch_relay2',
'has_entity_name': False,
'entity_id': 'switch.testmodule_switch_relay2',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
@ -315,13 +315,13 @@
'unit_of_measurement': None,
})
# ---
# name: test_setup_lcn_switch[switch.switch_relay2-state]
# name: test_setup_lcn_switch[switch.testmodule_switch_relay2-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Switch_Relay2',
'friendly_name': 'TestModule Switch_Relay2',
}),
'context': <ANY>,
'entity_id': 'switch.switch_relay2',
'entity_id': 'switch.testmodule_switch_relay2',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,

View File

@ -22,9 +22,9 @@ from .conftest import MockConfigEntry, init_integration
from tests.common import snapshot_platform
BINARY_SENSOR_LOCKREGULATOR1 = "binary_sensor.sensor_lockregulator1"
BINARY_SENSOR_SENSOR1 = "binary_sensor.binary_sensor1"
BINARY_SENSOR_KEYLOCK = "binary_sensor.sensor_keylock"
BINARY_SENSOR_LOCKREGULATOR1 = "binary_sensor.testmodule_sensor_lockregulator1"
BINARY_SENSOR_SENSOR1 = "binary_sensor.testmodule_binary_sensor1"
BINARY_SENSOR_KEYLOCK = "binary_sensor.testmodule_sensor_keylock"
async def test_setup_lcn_binary_sensor(
@ -140,7 +140,11 @@ async def test_unload_config_entry(hass: HomeAssistant, entry: MockConfigEntry)
@pytest.mark.parametrize(
"entity_id", ["binary_sensor.sensor_lockregulator1", "binary_sensor.sensor_keylock"]
"entity_id",
[
"binary_sensor.testmodule_sensor_lockregulator1",
"binary_sensor.testmodule_sensor_keylock",
],
)
async def test_create_issue(
hass: HomeAssistant,

View File

@ -52,7 +52,7 @@ async def test_set_hvac_mode_heat(hass: HomeAssistant, entry: MockConfigEntry) -
await init_integration(hass, entry)
with patch.object(MockModuleConnection, "lock_regulator") as lock_regulator:
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
state.state = HVACMode.OFF
# command failed
@ -61,13 +61,16 @@ async def test_set_hvac_mode_heat(hass: HomeAssistant, entry: MockConfigEntry) -
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_HVAC_MODE: HVACMode.HEAT},
{
ATTR_ENTITY_ID: "climate.testmodule_climate1",
ATTR_HVAC_MODE: HVACMode.HEAT,
},
blocking=True,
)
lock_regulator.assert_awaited_with(0, False)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state != HVACMode.HEAT
@ -78,13 +81,16 @@ async def test_set_hvac_mode_heat(hass: HomeAssistant, entry: MockConfigEntry) -
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_HVAC_MODE: HVACMode.HEAT},
{
ATTR_ENTITY_ID: "climate.testmodule_climate1",
ATTR_HVAC_MODE: HVACMode.HEAT,
},
blocking=True,
)
lock_regulator.assert_awaited_with(0, False)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state == HVACMode.HEAT
@ -94,7 +100,7 @@ async def test_set_hvac_mode_off(hass: HomeAssistant, entry: MockConfigEntry) ->
await init_integration(hass, entry)
with patch.object(MockModuleConnection, "lock_regulator") as lock_regulator:
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
state.state = HVACMode.HEAT
# command failed
@ -103,13 +109,16 @@ async def test_set_hvac_mode_off(hass: HomeAssistant, entry: MockConfigEntry) ->
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_HVAC_MODE: HVACMode.OFF},
{
ATTR_ENTITY_ID: "climate.testmodule_climate1",
ATTR_HVAC_MODE: HVACMode.OFF,
},
blocking=True,
)
lock_regulator.assert_awaited_with(0, True, -1)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state != HVACMode.OFF
@ -120,13 +129,16 @@ async def test_set_hvac_mode_off(hass: HomeAssistant, entry: MockConfigEntry) ->
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_HVAC_MODE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_HVAC_MODE: HVACMode.OFF},
{
ATTR_ENTITY_ID: "climate.testmodule_climate1",
ATTR_HVAC_MODE: HVACMode.OFF,
},
blocking=True,
)
lock_regulator.assert_awaited_with(0, True, -1)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state == HVACMode.OFF
@ -136,7 +148,7 @@ async def test_set_temperature(hass: HomeAssistant, entry: MockConfigEntry) -> N
await init_integration(hass, entry)
with patch.object(MockModuleConnection, "var_abs") as var_abs:
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
state.state = HVACMode.HEAT
# wrong temperature set via service call with high/low attributes
@ -147,7 +159,7 @@ async def test_set_temperature(hass: HomeAssistant, entry: MockConfigEntry) -> N
DOMAIN_CLIMATE,
SERVICE_SET_TEMPERATURE,
{
ATTR_ENTITY_ID: "climate.climate1",
ATTR_ENTITY_ID: "climate.testmodule_climate1",
ATTR_TARGET_TEMP_LOW: 24.5,
ATTR_TARGET_TEMP_HIGH: 25.5,
},
@ -163,13 +175,13 @@ async def test_set_temperature(hass: HomeAssistant, entry: MockConfigEntry) -> N
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_TEMPERATURE: 25.5},
{ATTR_ENTITY_ID: "climate.testmodule_climate1", ATTR_TEMPERATURE: 25.5},
blocking=True,
)
var_abs.assert_awaited_with(Var.R1VARSETPOINT, 25.5, VarUnit.CELSIUS)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.attributes[ATTR_TEMPERATURE] != 25.5
@ -180,13 +192,13 @@ async def test_set_temperature(hass: HomeAssistant, entry: MockConfigEntry) -> N
await hass.services.async_call(
DOMAIN_CLIMATE,
SERVICE_SET_TEMPERATURE,
{ATTR_ENTITY_ID: "climate.climate1", ATTR_TEMPERATURE: 25.5},
{ATTR_ENTITY_ID: "climate.testmodule_climate1", ATTR_TEMPERATURE: 25.5},
blocking=True,
)
var_abs.assert_awaited_with(Var.R1VARSETPOINT, 25.5, VarUnit.CELSIUS)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.attributes[ATTR_TEMPERATURE] == 25.5
@ -207,7 +219,7 @@ async def test_pushed_current_temperature_status_change(
await device_connection.async_process_input(inp)
await hass.async_block_till_done()
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_CURRENT_TEMPERATURE] == 25.5
@ -230,7 +242,7 @@ async def test_pushed_setpoint_status_change(
await device_connection.async_process_input(inp)
await hass.async_block_till_done()
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state == HVACMode.HEAT
assert state.attributes[ATTR_CURRENT_TEMPERATURE] is None
@ -253,7 +265,7 @@ async def test_pushed_lock_status_change(
await device_connection.async_process_input(inp)
await hass.async_block_till_done()
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state is not None
assert state.state == HVACMode.OFF
assert state.attributes[ATTR_CURRENT_TEMPERATURE] is None
@ -272,7 +284,7 @@ async def test_pushed_wrong_input(
await device_connection.async_process_input(Unknown("input"))
await hass.async_block_till_done()
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state.attributes[ATTR_CURRENT_TEMPERATURE] is None
assert state.attributes[ATTR_TEMPERATURE] is None
@ -285,5 +297,5 @@ async def test_unload_config_entry(
await init_integration(hass, entry)
await hass.config_entries.async_unload(entry.entry_id)
state = hass.states.get("climate.climate1")
state = hass.states.get("climate.testmodule_climate1")
assert state.state == STATE_UNAVAILABLE

View File

@ -36,10 +36,10 @@ from .conftest import MockConfigEntry, MockModuleConnection, init_integration
from tests.common import snapshot_platform
COVER_OUTPUTS = "cover.cover_outputs"
COVER_RELAYS = "cover.cover_relays"
COVER_RELAYS_BS4 = "cover.cover_relays_bs4"
COVER_RELAYS_MODULE = "cover.cover_relays_MODULE"
COVER_OUTPUTS = "cover.testmodule_cover_outputs"
COVER_RELAYS = "cover.testmodule_cover_relays"
COVER_RELAYS_BS4 = "cover.testmodule_cover_relays_bs4"
COVER_RELAYS_MODULE = "cover.testmodule_cover_relays_module"
async def test_setup_lcn_cover(

View File

@ -178,8 +178,8 @@ async def test_migrate_2_1(hass: HomeAssistant, snapshot: SnapshotAssertion) ->
@pytest.mark.parametrize(
("entity_id", "replace"),
[
("climate.climate1", ("-r1varsetpoint", "-var1.r1varsetpoint")),
("scene.romantic", ("-00", "-0.0")),
("climate.testmodule_climate1", ("-r1varsetpoint", "-var1.r1varsetpoint")),
("scene.testmodule_romantic", ("-00", "-0.0")),
],
)
@patch("homeassistant.components.lcn.PchkConnectionManager", MockPchkConnectionManager)

View File

@ -29,9 +29,9 @@ from .conftest import MockConfigEntry, MockModuleConnection, init_integration
from tests.common import snapshot_platform
LIGHT_OUTPUT1 = "light.light_output1"
LIGHT_OUTPUT2 = "light.light_output2"
LIGHT_RELAY1 = "light.light_relay1"
LIGHT_OUTPUT1 = "light.testmodule_light_output1"
LIGHT_OUTPUT2 = "light.testmodule_light_output2"
LIGHT_RELAY1 = "light.testmodule_light_relay1"
async def test_setup_lcn_light(

View File

@ -43,11 +43,11 @@ async def test_scene_activate(
await hass.services.async_call(
DOMAIN_SCENE,
SERVICE_TURN_ON,
{ATTR_ENTITY_ID: "scene.romantic"},
{ATTR_ENTITY_ID: "scene.testmodule_romantic"},
blocking=True,
)
state = hass.states.get("scene.romantic")
state = hass.states.get("scene.testmodule_romantic")
assert state is not None
activate_scene.assert_awaited_with(
@ -60,5 +60,5 @@ async def test_unload_config_entry(hass: HomeAssistant, entry: MockConfigEntry)
await init_integration(hass, entry)
await hass.config_entries.async_unload(entry.entry_id)
state = hass.states.get("scene.romantic")
state = hass.states.get("scene.testmodule_romantic")
assert state.state == STATE_UNAVAILABLE

View File

@ -16,10 +16,10 @@ from .conftest import MockConfigEntry, init_integration
from tests.common import snapshot_platform
SENSOR_VAR1 = "sensor.sensor_var1"
SENSOR_SETPOINT1 = "sensor.sensor_setpoint1"
SENSOR_LED6 = "sensor.sensor_led6"
SENSOR_LOGICOP1 = "sensor.sensor_logicop1"
SENSOR_VAR1 = "sensor.testmodule_sensor_var1"
SENSOR_SETPOINT1 = "sensor.testmodule_sensor_setpoint1"
SENSOR_LED6 = "sensor.testmodule_sensor_led6"
SENSOR_LOGICOP1 = "sensor.testmodule_sensor_logicop1"
async def test_setup_lcn_sensor(

View File

@ -30,12 +30,12 @@ from .conftest import MockConfigEntry, MockModuleConnection, init_integration
from tests.common import snapshot_platform
SWITCH_OUTPUT1 = "switch.switch_output1"
SWITCH_OUTPUT2 = "switch.switch_output2"
SWITCH_RELAY1 = "switch.switch_relay1"
SWITCH_RELAY2 = "switch.switch_relay2"
SWITCH_REGULATOR1 = "switch.switch_regulator1"
SWITCH_KEYLOCKK1 = "switch.switch_keylock1"
SWITCH_OUTPUT1 = "switch.testmodule_switch_output1"
SWITCH_OUTPUT2 = "switch.testmodule_switch_output2"
SWITCH_RELAY1 = "switch.testmodule_switch_relay1"
SWITCH_RELAY2 = "switch.testmodule_switch_relay2"
SWITCH_REGULATOR1 = "switch.testmodule_switch_regulator1"
SWITCH_KEYLOCKK1 = "switch.testmodule_switch_keylock1"
async def test_setup_lcn_switch(