Add friendly name to ZHA config entities (#79926)

* Add friendly name to ZHA config entities

* Follow HA capitalization conventions

* Change from "Start-up level" to "Start-up current level"

* Remove siren select friendly names (temporarily)

* Change tests to expect new entity ids

* Re-add siren select friendly names

* Change siren tests to expect new entity ids
pull/79937/head
TheJulianJES 2022-10-09 15:11:42 +02:00 committed by GitHub
parent 031370358c
commit 3126762707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 34 deletions

View File

@ -159,6 +159,7 @@ class FrostLockResetButton(ZHAAttributeButton, id_suffix="reset_frost_lock"):
"""Defines a ZHA frost lock reset button."""
_attribute_name = "frost_lock_reset"
_attr_name = "Frost lock reset"
_attribute_value = 0
_attr_device_class = ButtonDeviceClass.RESTART
_attr_entity_category = EntityCategory.CONFIG
@ -171,6 +172,7 @@ class NoPresenceStatusResetButton(
"""Defines a ZHA no presence status reset button."""
_attribute_name = "reset_no_presence_status"
_attr_name = "Presence status reset"
_attribute_value = 1
_attr_device_class = ButtonDeviceClass.RESTART
_attr_entity_category = EntityCategory.CONFIG

View File

@ -455,6 +455,7 @@ class AqaraMotionDetectionInterval(
_attr_native_min_value: float = 2
_attr_native_max_value: float = 65535
_zcl_attribute: str = "detection_interval"
_attr_name = "Detection interval"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -466,6 +467,7 @@ class OnOffTransitionTimeConfigurationEntity(
_attr_native_min_value: float = 0x0000
_attr_native_max_value: float = 0xFFFF
_zcl_attribute: str = "on_off_transition_time"
_attr_name = "On/Off transition time"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -475,6 +477,7 @@ class OnLevelConfigurationEntity(ZHANumberConfigurationEntity, id_suffix="on_lev
_attr_native_min_value: float = 0x00
_attr_native_max_value: float = 0xFF
_zcl_attribute: str = "on_level"
_attr_name = "On level"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -486,6 +489,7 @@ class OnTransitionTimeConfigurationEntity(
_attr_native_min_value: float = 0x0000
_attr_native_max_value: float = 0xFFFE
_zcl_attribute: str = "on_transition_time"
_attr_name = "On transition time"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -497,6 +501,7 @@ class OffTransitionTimeConfigurationEntity(
_attr_native_min_value: float = 0x0000
_attr_native_max_value: float = 0xFFFE
_zcl_attribute: str = "off_transition_time"
_attr_name = "Off transition time"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -508,6 +513,7 @@ class DefaultMoveRateConfigurationEntity(
_attr_native_min_value: float = 0x00
_attr_native_max_value: float = 0xFE
_zcl_attribute: str = "default_move_rate"
_attr_name = "Default move rate"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_LEVEL)
@ -519,6 +525,7 @@ class StartUpCurrentLevelConfigurationEntity(
_attr_native_min_value: float = 0x00
_attr_native_max_value: float = 0xFF
_zcl_attribute: str = "start_up_current_level"
_attr_name = "Start-up current level"
@CONFIG_DIAGNOSTIC_MATCH(
@ -536,6 +543,7 @@ class TimerDurationMinutes(ZHANumberConfigurationEntity, id_suffix="timer_durati
_attr_native_max_value: float = 0x257
_attr_native_unit_of_measurement: str | None = UNITS[72]
_zcl_attribute: str = "timer_duration"
_attr_name = "Timer duration"
@CONFIG_DIAGNOSTIC_MATCH(channel_names="ikea_airpurifier")
@ -548,6 +556,7 @@ class FilterLifeTime(ZHANumberConfigurationEntity, id_suffix="filter_life_time")
_attr_native_max_value: float = 0xFFFFFFFF
_attr_native_unit_of_measurement: str | None = UNITS[72]
_zcl_attribute: str = "filter_life_time"
_attr_name = "Filter life time"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_INOVELLI)

View File

@ -123,6 +123,7 @@ class ZHADefaultToneSelectEntity(
"""Representation of a ZHA default siren tone select entity."""
_enum = IasWd.Warning.WarningMode
_attr_name = "Default siren tone"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_IAS_WD)
@ -132,6 +133,7 @@ class ZHADefaultSirenLevelSelectEntity(
"""Representation of a ZHA default siren level select entity."""
_enum = IasWd.Warning.SirenLevel
_attr_name = "Default siren level"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_IAS_WD)
@ -141,6 +143,7 @@ class ZHADefaultStrobeLevelSelectEntity(
"""Representation of a ZHA default siren strobe level select entity."""
_enum = IasWd.StrobeLevel
_attr_name = "Default strobe level"
@CONFIG_DIAGNOSTIC_MATCH(channel_names=CHANNEL_IAS_WD)
@ -148,6 +151,7 @@ class ZHADefaultStrobeSelectEntity(ZHANonZCLSelectEntity, id_suffix=Strobe.__nam
"""Representation of a ZHA default siren strobe select entity."""
_enum = Strobe
_attr_name = "Default strobe"
class ZCLEnumSelectEntity(ZhaEntity, SelectEntity):
@ -220,6 +224,7 @@ class ZHAStartupOnOffSelectEntity(
_select_attr = "start_up_on_off"
_enum = OnOff.StartUpOnOff
_attr_name = "Start-up behavior"
class AqaraMotionSensitivities(types.enum8):
@ -238,6 +243,7 @@ class AqaraMotionSensitivity(ZCLEnumSelectEntity, id_suffix="motion_sensitivity"
_select_attr = "motion_sensitivity"
_enum = AqaraMotionSensitivities
_attr_name = "Motion sensitivity"
class AqaraMonitoringModess(types.enum8):
@ -253,6 +259,7 @@ class AqaraMonitoringMode(ZCLEnumSelectEntity, id_suffix="monitoring_mode"):
_select_attr = "monitoring_mode"
_enum = AqaraMonitoringModess
_attr_name = "Monitoring mode"
class AqaraApproachDistances(types.enum8):
@ -269,6 +276,7 @@ class AqaraApproachDistance(ZCLEnumSelectEntity, id_suffix="approach_distance"):
_select_attr = "approach_distance"
_enum = AqaraApproachDistances
_attr_name = "Approach distance"
class AqaraE1ReverseDirection(types.enum8):
@ -286,6 +294,7 @@ class AqaraCurtainMode(ZCLEnumSelectEntity, id_suffix="window_covering_mode"):
_select_attr = "window_covering_mode"
_enum = AqaraE1ReverseDirection
_attr_name = "Curtain mode"
class InovelliOutputMode(types.enum1):

View File

@ -290,6 +290,7 @@ class P1MotionTriggerIndicatorSwitch(
"""Representation of a ZHA motion triggering configuration entity."""
_zcl_attribute: str = "trigger_indicator"
_attr_name = "LED trigger indicator"
@CONFIG_DIAGNOSTIC_MATCH(
@ -300,6 +301,7 @@ class ChildLock(ZHASwitchConfigurationEntity, id_suffix="child_lock"):
"""ZHA BinarySensor."""
_zcl_attribute: str = "child_lock"
_attr_name = "Child lock"
@CONFIG_DIAGNOSTIC_MATCH(
@ -310,6 +312,7 @@ class DisableLed(ZHASwitchConfigurationEntity, id_suffix="disable_led"):
"""ZHA BinarySensor."""
_zcl_attribute: str = "disable_led"
_attr_name = "Disable LED"
@CONFIG_DIAGNOSTIC_MATCH(

View File

@ -125,28 +125,28 @@ async def test_get_actions(hass, device_ias):
"domain": Platform.SELECT,
"type": "select_option",
"device_id": reg_device.id,
"entity_id": "select.fakemanufacturer_fakemodel_defaulttoneselect",
"entity_id": "select.fakemanufacturer_fakemodel_default_siren_tone",
"metadata": {"secondary": True},
},
{
"domain": Platform.SELECT,
"type": "select_option",
"device_id": reg_device.id,
"entity_id": "select.fakemanufacturer_fakemodel_defaultsirenlevelselect",
"entity_id": "select.fakemanufacturer_fakemodel_default_siren_level",
"metadata": {"secondary": True},
},
{
"domain": Platform.SELECT,
"type": "select_option",
"device_id": reg_device.id,
"entity_id": "select.fakemanufacturer_fakemodel_defaultstrobelevelselect",
"entity_id": "select.fakemanufacturer_fakemodel_default_strobe_level",
"metadata": {"secondary": True},
},
{
"domain": Platform.SELECT,
"type": "select_option",
"device_id": reg_device.id,
"entity_id": "select.fakemanufacturer_fakemodel_defaultstrobeselect",
"entity_id": "select.fakemanufacturer_fakemodel_default_strobe",
"metadata": {"secondary": True},
},
]

View File

@ -211,7 +211,7 @@ async def test_level_control_number(
Platform.NUMBER,
zha_device,
hass,
qualifier=attr.replace("_", ""),
qualifier=attr,
)
assert entity_id is not None

View File

@ -163,7 +163,7 @@ async def test_select_restore_state(
):
"""Test zha select entity restore state."""
entity_id = "select.fakemanufacturer_fakemodel_defaulttoneselect"
entity_id = "select.fakemanufacturer_fakemodel_default_siren_tone"
core_rs(entity_id, state="Burglar")
zigpy_device = zigpy_device_mock(
@ -202,12 +202,12 @@ async def test_on_off_select_new_join(hass, light, zha_device_joined):
"start_up_on_off": general.OnOff.StartUpOnOff.On
}
zha_device = await zha_device_joined(light)
select_name = general.OnOff.StartUpOnOff.__name__
select_name = "start_up_behavior"
entity_id = await find_entity_id(
Platform.SELECT,
zha_device,
hass,
qualifier=select_name.lower(),
qualifier=select_name,
)
assert entity_id is not None
@ -285,12 +285,12 @@ async def test_on_off_select_restored(hass, light, zha_device_restored):
in on_off_cluster.read_attributes.call_args_list
)
select_name = general.OnOff.StartUpOnOff.__name__
select_name = "start_up_behavior"
entity_id = await find_entity_id(
Platform.SELECT,
zha_device,
hass,
qualifier=select_name.lower(),
qualifier=select_name,
)
assert entity_id is not None

View File

@ -649,10 +649,10 @@ DEVICES = [
"binary_sensor.climaxtechnology_sd8sc_00_00_03_12tc_iaszone",
"sensor.climaxtechnology_sd8sc_00_00_03_12tc_rssi",
"sensor.climaxtechnology_sd8sc_00_00_03_12tc_lqi",
"select.climaxtechnology_sd8sc_00_00_03_12tc_defaulttoneselect",
"select.climaxtechnology_sd8sc_00_00_03_12tc_defaultsirenlevelselect",
"select.climaxtechnology_sd8sc_00_00_03_12tc_defaultstrobelevelselect",
"select.climaxtechnology_sd8sc_00_00_03_12tc_defaultstrobeselect",
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_tone",
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_level",
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe_level",
"select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe",
"siren.climaxtechnology_sd8sc_00_00_03_12tc_siren",
],
DEV_SIG_ENT_MAP: {
@ -679,22 +679,22 @@ DEVICES = [
("select", "00:11:22:33:44:55:66:77-1-1282-WarningMode"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultToneSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_defaulttoneselect",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_tone",
},
("select", "00:11:22:33:44:55:66:77-1-1282-SirenLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultSirenLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_defaultsirenlevelselect",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_siren_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-StrobeLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_defaultstrobelevelselect",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-Strobe"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_defaultstrobeselect",
DEV_SIG_ENT_MAP_ID: "select.climaxtechnology_sd8sc_00_00_03_12tc_default_strobe",
},
("siren", "00:11:22:33:44:55:66:77-1-1282"): {
DEV_SIG_CHANNELS: ["ias_wd"],
@ -819,10 +819,10 @@ DEVICES = [
"binary_sensor.heiman_smokesensor_em_iaszone",
"sensor.heiman_smokesensor_em_rssi",
"sensor.heiman_smokesensor_em_lqi",
"select.heiman_smokesensor_em_defaulttoneselect",
"select.heiman_smokesensor_em_defaultsirenlevelselect",
"select.heiman_smokesensor_em_defaultstrobelevelselect",
"select.heiman_smokesensor_em_defaultstrobeselect",
"select.heiman_smokesensor_em_default_siren_tone",
"select.heiman_smokesensor_em_default_siren_level",
"select.heiman_smokesensor_em_default_strobe_level",
"select.heiman_smokesensor_em_default_strobe",
"siren.heiman_smokesensor_em_siren",
],
DEV_SIG_ENT_MAP: {
@ -854,22 +854,22 @@ DEVICES = [
("select", "00:11:22:33:44:55:66:77-1-1282-WarningMode"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultToneSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_defaulttoneselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_default_siren_tone",
},
("select", "00:11:22:33:44:55:66:77-1-1282-SirenLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultSirenLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_defaultsirenlevelselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_default_siren_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-StrobeLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_defaultstrobelevelselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_default_strobe_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-Strobe"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_defaultstrobeselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_smokesensor_em_default_strobe",
},
("siren", "00:11:22:33:44:55:66:77-1-1282"): {
DEV_SIG_CHANNELS: ["ias_wd"],
@ -942,32 +942,32 @@ DEVICES = [
"binary_sensor.heiman_warningdevice_iaszone",
"sensor.heiman_warningdevice_rssi",
"sensor.heiman_warningdevice_lqi",
"select.heiman_warningdevice_defaulttoneselect",
"select.heiman_warningdevice_defaultsirenlevelselect",
"select.heiman_warningdevice_defaultstrobelevelselect",
"select.heiman_warningdevice_defaultstrobeselect",
"select.heiman_warningdevice_default_siren_tone",
"select.heiman_warningdevice_default_siren_level",
"select.heiman_warningdevice_default_strobe_level",
"select.heiman_warningdevice_default_strobe",
"siren.heiman_warningdevice_siren",
],
DEV_SIG_ENT_MAP: {
("select", "00:11:22:33:44:55:66:77-1-1282-WarningMode"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultToneSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_defaulttoneselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_default_siren_tone",
},
("select", "00:11:22:33:44:55:66:77-1-1282-SirenLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultSirenLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_defaultsirenlevelselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_default_siren_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-StrobeLevel"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeLevelSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_defaultstrobelevelselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_default_strobe_level",
},
("select", "00:11:22:33:44:55:66:77-1-1282-Strobe"): {
DEV_SIG_CHANNELS: ["ias_wd"],
DEV_SIG_ENT_MAP_CLASS: "ZHADefaultStrobeSelectEntity",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_defaultstrobeselect",
DEV_SIG_ENT_MAP_ID: "select.heiman_warningdevice_default_strobe",
},
("siren", "00:11:22:33:44:55:66:77-1"): {
DEV_SIG_CHANNELS: ["ias_wd"],