mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Update name for Notification CC sensors and buttons (#93019)
* Update name for Notification CC sensors and buttons * Add comment with reference to names
This commit is contained in:
parent
83f206a6fe
commit
3e93dd6a01
@ -122,7 +122,9 @@ class ZWaveNotificationIdleButton(ZWaveBaseEntity, ButtonEntity):
|
|||||||
"""Initialize a ZWaveNotificationIdleButton entity."""
|
"""Initialize a ZWaveNotificationIdleButton entity."""
|
||||||
super().__init__(config_entry, driver, info)
|
super().__init__(config_entry, driver, info)
|
||||||
self._attr_name = self.generate_name(
|
self._attr_name = self.generate_name(
|
||||||
include_value_name=True, name_prefix="Idle"
|
alternate_value_name=self.info.primary_value.property_name,
|
||||||
|
additional_info=[self.info.primary_value.property_key_name],
|
||||||
|
name_prefix="Idle",
|
||||||
)
|
)
|
||||||
self._attr_unique_id = f"{self._attr_unique_id}.notification_idle"
|
self._attr_unique_id = f"{self._attr_unique_id}.notification_idle"
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ class ZWaveBaseEntity(Entity):
|
|||||||
self,
|
self,
|
||||||
include_value_name: bool = False,
|
include_value_name: bool = False,
|
||||||
alternate_value_name: str | None = None,
|
alternate_value_name: str | None = None,
|
||||||
additional_info: list[str] | None = None,
|
additional_info: list[str | None] | None = None,
|
||||||
name_prefix: str | None = None,
|
name_prefix: str | None = None,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Generate entity name."""
|
"""Generate entity name."""
|
||||||
@ -155,8 +155,11 @@ class ZWaveBaseEntity(Entity):
|
|||||||
or self.info.primary_value.property_name
|
or self.info.primary_value.property_name
|
||||||
or ""
|
or ""
|
||||||
)
|
)
|
||||||
|
|
||||||
name = f"{name} {value_name}".strip()
|
name = f"{name} {value_name}".strip()
|
||||||
name = f"{name} {' '.join(additional_info or [])}".strip()
|
# Only include non empty additional info
|
||||||
|
if additional_info := [item for item in (additional_info or []) if item]:
|
||||||
|
name = f"{name} {' '.join(additional_info)}"
|
||||||
# append endpoint if > 1
|
# append endpoint if > 1
|
||||||
if (
|
if (
|
||||||
self.info.primary_value.endpoint is not None
|
self.info.primary_value.endpoint is not None
|
||||||
|
@ -468,6 +468,28 @@ class ZWaveMeterSensor(ZWaveNumericSensor):
|
|||||||
class ZWaveListSensor(ZwaveSensor):
|
class ZWaveListSensor(ZwaveSensor):
|
||||||
"""Representation of a Z-Wave Numeric sensor with multiple states."""
|
"""Representation of a Z-Wave Numeric sensor with multiple states."""
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
config_entry: ConfigEntry,
|
||||||
|
driver: Driver,
|
||||||
|
info: ZwaveDiscoveryInfo,
|
||||||
|
entity_description: SensorEntityDescription,
|
||||||
|
unit_of_measurement: str | None = None,
|
||||||
|
) -> None:
|
||||||
|
"""Initialize a ZWaveListSensor entity."""
|
||||||
|
super().__init__(
|
||||||
|
config_entry, driver, info, entity_description, unit_of_measurement
|
||||||
|
)
|
||||||
|
|
||||||
|
# Entity class attributes
|
||||||
|
# Notification sensors have the following name mapping (variables are property
|
||||||
|
# keys, name is property)
|
||||||
|
# https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/notifications.json
|
||||||
|
self._attr_name = self.generate_name(
|
||||||
|
alternate_value_name=self.info.primary_value.property_name,
|
||||||
|
additional_info=[self.info.primary_value.property_key_name],
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> SensorDeviceClass | None:
|
def device_class(self) -> SensorDeviceClass | None:
|
||||||
"""Return sensor device class."""
|
"""Return sensor device class."""
|
||||||
|
@ -24,7 +24,7 @@ LOW_BATTERY_BINARY_SENSOR = "binary_sensor.multisensor_6_low_battery_level"
|
|||||||
ENABLED_LEGACY_BINARY_SENSOR = "binary_sensor.z_wave_door_window_sensor_any"
|
ENABLED_LEGACY_BINARY_SENSOR = "binary_sensor.z_wave_door_window_sensor_any"
|
||||||
DISABLED_LEGACY_BINARY_SENSOR = "binary_sensor.multisensor_6_any"
|
DISABLED_LEGACY_BINARY_SENSOR = "binary_sensor.multisensor_6_any"
|
||||||
NOTIFICATION_MOTION_BINARY_SENSOR = "binary_sensor.multisensor_6_motion_detection"
|
NOTIFICATION_MOTION_BINARY_SENSOR = "binary_sensor.multisensor_6_motion_detection"
|
||||||
NOTIFICATION_MOTION_SENSOR = "sensor.multisensor_6_motion_sensor_status"
|
NOTIFICATION_MOTION_SENSOR = "sensor.multisensor_6_home_security_motion_sensor_status"
|
||||||
INDICATOR_SENSOR = "sensor.z_wave_thermostat_indicator_value"
|
INDICATOR_SENSOR = "sensor.z_wave_thermostat_indicator_value"
|
||||||
BASIC_NUMBER_ENTITY = "number.livingroomlight_basic"
|
BASIC_NUMBER_ENTITY = "number.livingroomlight_basic"
|
||||||
PROPERTY_DOOR_STATUS_BINARY_SENSOR = (
|
PROPERTY_DOOR_STATUS_BINARY_SENSOR = (
|
||||||
|
@ -67,17 +67,20 @@ async def test_notification_idle_button(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Test Notification idle button."""
|
"""Test Notification idle button."""
|
||||||
node = multisensor_6
|
node = multisensor_6
|
||||||
state = hass.states.get("button.multisensor_6_idle_cover_status")
|
state = hass.states.get("button.multisensor_6_idle_home_security_cover_status")
|
||||||
assert state
|
assert state
|
||||||
assert state.state == "unknown"
|
assert state.state == "unknown"
|
||||||
assert state.attributes["friendly_name"] == "Multisensor 6 Idle Cover status"
|
assert (
|
||||||
|
state.attributes["friendly_name"]
|
||||||
|
== "Multisensor 6 Idle Home Security Cover status"
|
||||||
|
)
|
||||||
|
|
||||||
# Test successful idle call
|
# Test successful idle call
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
BUTTON_DOMAIN,
|
BUTTON_DOMAIN,
|
||||||
SERVICE_PRESS,
|
SERVICE_PRESS,
|
||||||
{
|
{
|
||||||
ATTR_ENTITY_ID: "button.multisensor_6_idle_cover_status",
|
ATTR_ENTITY_ID: "button.multisensor_6_idle_home_security_cover_status",
|
||||||
},
|
},
|
||||||
blocking=True,
|
blocking=True,
|
||||||
)
|
)
|
||||||
|
@ -1362,8 +1362,10 @@ async def test_disabled_entity_on_value_removed(
|
|||||||
er_reg = er.async_get(hass)
|
er_reg = er.async_get(hass)
|
||||||
|
|
||||||
# re-enable this default-disabled entity
|
# re-enable this default-disabled entity
|
||||||
sensor_cover_entity = "sensor.4_in_1_sensor_cover_status"
|
sensor_cover_entity = "sensor.4_in_1_sensor_home_security_cover_status"
|
||||||
idle_cover_status_button_entity = "button.4_in_1_sensor_idle_cover_status"
|
idle_cover_status_button_entity = (
|
||||||
|
"button.4_in_1_sensor_idle_home_security_cover_status"
|
||||||
|
)
|
||||||
er_reg.async_update_entity(entity_id=sensor_cover_entity, disabled_by=None)
|
er_reg.async_update_entity(entity_id=sensor_cover_entity, disabled_by=None)
|
||||||
await hass.async_block_till_done()
|
await hass.async_block_till_done()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user