Add entity translations to Risco (#98921)
This commit is contained in:
parent
969063ccf8
commit
be78169065
5 changed files with 27 additions and 16 deletions
|
@ -88,6 +88,8 @@ class RiscoAlarm(AlarmControlPanelEntity):
|
|||
"""Representation of a Risco cloud partition."""
|
||||
|
||||
_attr_code_format = CodeFormat.NUMBER
|
||||
_attr_has_entity_name = True
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -107,8 +109,6 @@ class RiscoAlarm(AlarmControlPanelEntity):
|
|||
self._code_disarm_required = options[CONF_CODE_DISARM_REQUIRED]
|
||||
self._risco_to_ha = options[CONF_RISCO_STATES_TO_HA]
|
||||
self._ha_to_risco = options[CONF_HA_STATES_TO_RISCO]
|
||||
self._attr_has_entity_name = True
|
||||
self._attr_name = None
|
||||
for state in self._ha_to_risco:
|
||||
self._attr_supported_features |= STATES_TO_SUPPORTED_FEATURES[state]
|
||||
|
||||
|
|
|
@ -50,14 +50,13 @@ class RiscoCloudBinarySensor(RiscoCloudZoneEntity, BinarySensorEntity):
|
|||
"""Representation of a Risco cloud zone as a binary sensor."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.MOTION
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self, coordinator: RiscoDataUpdateCoordinator, zone_id: int, zone: Zone
|
||||
) -> None:
|
||||
"""Init the zone."""
|
||||
super().__init__(
|
||||
coordinator=coordinator, name=None, suffix="", zone_id=zone_id, zone=zone
|
||||
)
|
||||
super().__init__(coordinator=coordinator, suffix="", zone_id=zone_id, zone=zone)
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool | None:
|
||||
|
@ -69,12 +68,11 @@ class RiscoLocalBinarySensor(RiscoLocalZoneEntity, BinarySensorEntity):
|
|||
"""Representation of a Risco local zone as a binary sensor."""
|
||||
|
||||
_attr_device_class = BinarySensorDeviceClass.MOTION
|
||||
_attr_name = None
|
||||
|
||||
def __init__(self, system_id: str, zone_id: int, zone: Zone) -> None:
|
||||
"""Init the zone."""
|
||||
super().__init__(
|
||||
system_id=system_id, name=None, suffix="", zone_id=zone_id, zone=zone
|
||||
)
|
||||
super().__init__(system_id=system_id, suffix="", zone_id=zone_id, zone=zone)
|
||||
|
||||
@property
|
||||
def extra_state_attributes(self) -> Mapping[str, Any] | None:
|
||||
|
@ -93,11 +91,12 @@ class RiscoLocalBinarySensor(RiscoLocalZoneEntity, BinarySensorEntity):
|
|||
class RiscoLocalAlarmedBinarySensor(RiscoLocalZoneEntity, BinarySensorEntity):
|
||||
"""Representation whether a zone in Risco local is currently triggering an alarm."""
|
||||
|
||||
_attr_translation_key = "alarmed"
|
||||
|
||||
def __init__(self, system_id: str, zone_id: int, zone: Zone) -> None:
|
||||
"""Init the zone."""
|
||||
super().__init__(
|
||||
system_id=system_id,
|
||||
name="Alarmed",
|
||||
suffix="_alarmed",
|
||||
zone_id=zone_id,
|
||||
zone=zone,
|
||||
|
@ -112,11 +111,12 @@ class RiscoLocalAlarmedBinarySensor(RiscoLocalZoneEntity, BinarySensorEntity):
|
|||
class RiscoLocalArmedBinarySensor(RiscoLocalZoneEntity, BinarySensorEntity):
|
||||
"""Representation whether a zone in Risco local is currently armed."""
|
||||
|
||||
_attr_translation_key = "armed"
|
||||
|
||||
def __init__(self, system_id: str, zone_id: int, zone: Zone) -> None:
|
||||
"""Init the zone."""
|
||||
super().__init__(
|
||||
system_id=system_id,
|
||||
name="Armed",
|
||||
suffix="_armed",
|
||||
zone_id=zone_id,
|
||||
zone=zone,
|
||||
|
|
|
@ -56,7 +56,6 @@ class RiscoCloudZoneEntity(RiscoCloudEntity):
|
|||
self,
|
||||
*,
|
||||
coordinator: RiscoDataUpdateCoordinator,
|
||||
name: str | None,
|
||||
suffix: str,
|
||||
zone_id: int,
|
||||
zone: Zone,
|
||||
|
@ -66,7 +65,6 @@ class RiscoCloudZoneEntity(RiscoCloudEntity):
|
|||
super().__init__(coordinator=coordinator, **kwargs)
|
||||
self._zone_id = zone_id
|
||||
self._zone = zone
|
||||
self._attr_name = name
|
||||
device_unique_id = zone_unique_id(self._risco, zone_id)
|
||||
self._attr_unique_id = f"{device_unique_id}{suffix}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
@ -90,7 +88,6 @@ class RiscoLocalZoneEntity(Entity):
|
|||
self,
|
||||
*,
|
||||
system_id: str,
|
||||
name: str | None,
|
||||
suffix: str,
|
||||
zone_id: int,
|
||||
zone: Zone,
|
||||
|
@ -100,7 +97,6 @@ class RiscoLocalZoneEntity(Entity):
|
|||
super().__init__(**kwargs)
|
||||
self._zone_id = zone_id
|
||||
self._zone = zone
|
||||
self._attr_name = name
|
||||
device_unique_id = f"{system_id}_zone_{zone_id}_local"
|
||||
self._attr_unique_id = f"{device_unique_id}{suffix}"
|
||||
self._attr_device_info = DeviceInfo(
|
||||
|
|
|
@ -64,5 +64,20 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"alarmed": {
|
||||
"name": "Alarmed"
|
||||
},
|
||||
"armed": {
|
||||
"name": "Armed"
|
||||
}
|
||||
},
|
||||
"switch": {
|
||||
"bypassed": {
|
||||
"name": "Bypassed"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ class RiscoCloudSwitch(RiscoCloudZoneEntity, SwitchEntity):
|
|||
"""Representation of a bypass switch for a Risco cloud zone."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
_attr_translation_key = "bypassed"
|
||||
|
||||
def __init__(
|
||||
self, coordinator: RiscoDataUpdateCoordinator, zone_id: int, zone: Zone
|
||||
|
@ -47,7 +48,6 @@ class RiscoCloudSwitch(RiscoCloudZoneEntity, SwitchEntity):
|
|||
"""Init the zone."""
|
||||
super().__init__(
|
||||
coordinator=coordinator,
|
||||
name="Bypassed",
|
||||
suffix="_bypassed",
|
||||
zone_id=zone_id,
|
||||
zone=zone,
|
||||
|
@ -76,12 +76,12 @@ class RiscoLocalSwitch(RiscoLocalZoneEntity, SwitchEntity):
|
|||
"""Representation of a bypass switch for a Risco local zone."""
|
||||
|
||||
_attr_entity_category = EntityCategory.CONFIG
|
||||
_attr_translation_key = "bypassed"
|
||||
|
||||
def __init__(self, system_id: str, zone_id: int, zone: Zone) -> None:
|
||||
"""Init the zone."""
|
||||
super().__init__(
|
||||
system_id=system_id,
|
||||
name="Bypassed",
|
||||
suffix="_bypassed",
|
||||
zone_id=zone_id,
|
||||
zone=zone,
|
||||
|
|
Loading…
Add table
Reference in a new issue