mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Add entity translations to FireServiceRota (#95337)
This commit is contained in:
parent
09bfb08067
commit
e4eb7e4796
@ -35,6 +35,9 @@ async def async_setup_entry(
|
|||||||
class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
"""Representation of an FireServiceRota sensor."""
|
"""Representation of an FireServiceRota sensor."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_translation_key = "duty"
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: DataUpdateCoordinator,
|
coordinator: DataUpdateCoordinator,
|
||||||
@ -44,15 +47,10 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
super().__init__(coordinator)
|
super().__init__(coordinator)
|
||||||
self._client = client
|
self._client = client
|
||||||
self._unique_id = f"{entry.unique_id}_Duty"
|
self._attr_unique_id = f"{entry.unique_id}_Duty"
|
||||||
|
|
||||||
self._state: bool | None = None
|
self._state: bool | None = None
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the sensor."""
|
|
||||||
return "Duty"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
"""Return the icon to use in the frontend."""
|
"""Return the icon to use in the frontend."""
|
||||||
@ -61,11 +59,6 @@ class ResponseBinarySensor(CoordinatorEntity, BinarySensorEntity):
|
|||||||
|
|
||||||
return "mdi:calendar-remove"
|
return "mdi:calendar-remove"
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return the unique ID for this binary sensor."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool | None:
|
def is_on(self) -> bool | None:
|
||||||
"""Return the state of the binary sensor."""
|
"""Return the state of the binary sensor."""
|
||||||
|
@ -28,20 +28,17 @@ class IncidentsSensor(RestoreEntity, SensorEntity):
|
|||||||
"""Representation of FireServiceRota incidents sensor."""
|
"""Representation of FireServiceRota incidents sensor."""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_translation_key = "incidents"
|
||||||
|
|
||||||
def __init__(self, client):
|
def __init__(self, client):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._client = client
|
self._client = client
|
||||||
self._entry_id = self._client.entry_id
|
self._entry_id = self._client.entry_id
|
||||||
self._unique_id = f"{self._client.unique_id}_Incidents"
|
self._attr_unique_id = f"{self._client.unique_id}_Incidents"
|
||||||
self._state = None
|
self._state = None
|
||||||
self._state_attributes = {}
|
self._state_attributes = {}
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the sensor."""
|
|
||||||
return "Incidents"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
"""Return the icon to use in the frontend."""
|
"""Return the icon to use in the frontend."""
|
||||||
@ -58,11 +55,6 @@ class IncidentsSensor(RestoreEntity, SensorEntity):
|
|||||||
"""Return the state of the sensor."""
|
"""Return the state of the sensor."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return the unique ID of the sensor."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self) -> dict[str, Any]:
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return available attributes for sensor."""
|
"""Return available attributes for sensor."""
|
||||||
|
@ -25,5 +25,22 @@
|
|||||||
"create_entry": {
|
"create_entry": {
|
||||||
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
"default": "[%key:common::config_flow::create_entry::authenticated%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"duty": {
|
||||||
|
"name": "Duty"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"incidents": {
|
||||||
|
"name": "Incidents"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"switch": {
|
||||||
|
"incident_response": {
|
||||||
|
"name": "Incident response"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,23 +28,20 @@ class ResponseSwitch(SwitchEntity):
|
|||||||
"""Representation of an FireServiceRota switch."""
|
"""Representation of an FireServiceRota switch."""
|
||||||
|
|
||||||
_attr_should_poll = False
|
_attr_should_poll = False
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
_attr_translation_key = "incident_response"
|
||||||
|
|
||||||
def __init__(self, coordinator, client, entry):
|
def __init__(self, coordinator, client, entry):
|
||||||
"""Initialize."""
|
"""Initialize."""
|
||||||
self._coordinator = coordinator
|
self._coordinator = coordinator
|
||||||
self._client = client
|
self._client = client
|
||||||
self._unique_id = f"{entry.unique_id}_Response"
|
self._attr_unique_id = f"{entry.unique_id}_Response"
|
||||||
self._entry_id = entry.entry_id
|
self._entry_id = entry.entry_id
|
||||||
|
|
||||||
self._state = None
|
self._state = None
|
||||||
self._state_attributes = {}
|
self._state_attributes = {}
|
||||||
self._state_icon = None
|
self._state_icon = None
|
||||||
|
|
||||||
@property
|
|
||||||
def name(self) -> str:
|
|
||||||
"""Return the name of the switch."""
|
|
||||||
return "Incident Response"
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self) -> str:
|
def icon(self) -> str:
|
||||||
"""Return the icon to use in the frontend."""
|
"""Return the icon to use in the frontend."""
|
||||||
@ -60,11 +57,6 @@ class ResponseSwitch(SwitchEntity):
|
|||||||
"""Get the assumed state of the switch."""
|
"""Get the assumed state of the switch."""
|
||||||
return self._state
|
return self._state
|
||||||
|
|
||||||
@property
|
|
||||||
def unique_id(self) -> str:
|
|
||||||
"""Return the unique ID for this switch."""
|
|
||||||
return self._unique_id
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def available(self) -> bool:
|
def available(self) -> bool:
|
||||||
"""Return if switch is available."""
|
"""Return if switch is available."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user