Add entity translations to OpenGarage (#98834)
This commit is contained in:
parent
3f2c03fe77
commit
342e55409a
5 changed files with 11 additions and 7 deletions
|
@ -22,6 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||
SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||
BinarySensorEntityDescription(
|
||||
key="vehicle",
|
||||
translation_key="vehicle",
|
||||
),
|
||||
)
|
||||
|
||||
|
@ -66,9 +67,6 @@ class OpenGarageBinarySensor(OpenGarageEntity, BinarySensorEntity):
|
|||
@callback
|
||||
def _update_attr(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
self._attr_name = (
|
||||
f'{self.coordinator.data["name"]} {self.entity_description.key}'
|
||||
)
|
||||
state = self.coordinator.data.get(self.entity_description.key)
|
||||
if state == 1:
|
||||
self._attr_is_on = True
|
||||
|
|
|
@ -37,6 +37,7 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
|
|||
|
||||
_attr_device_class = CoverDeviceClass.GARAGE
|
||||
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||
_attr_name = None
|
||||
|
||||
def __init__(
|
||||
self, coordinator: OpenGarageDataUpdateCoordinator, device_id: str
|
||||
|
@ -89,7 +90,6 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
|
|||
"""Update the state and attributes."""
|
||||
status = self.coordinator.data
|
||||
|
||||
self._attr_name = status["name"]
|
||||
state = STATES_MAP.get(status.get("door")) # type: ignore[arg-type]
|
||||
if self._state_before_move is not None:
|
||||
if self._state_before_move != state:
|
||||
|
|
|
@ -12,6 +12,8 @@ from . import DOMAIN, OpenGarageDataUpdateCoordinator
|
|||
class OpenGarageEntity(CoordinatorEntity[OpenGarageDataUpdateCoordinator]):
|
||||
"""Representation of a OpenGarage entity."""
|
||||
|
||||
_attr_has_entity_name = True
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
open_garage_data_coordinator: OpenGarageDataUpdateCoordinator,
|
||||
|
|
|
@ -83,7 +83,4 @@ class OpenGarageSensor(OpenGarageEntity, SensorEntity):
|
|||
@callback
|
||||
def _update_attr(self) -> None:
|
||||
"""Handle updated data from the coordinator."""
|
||||
self._attr_name = (
|
||||
f'{self.coordinator.data["name"]} {self.entity_description.key}'
|
||||
)
|
||||
self._attr_native_value = self.coordinator.data.get(self.entity_description.key)
|
||||
|
|
|
@ -18,5 +18,12 @@
|
|||
"abort": {
|
||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"binary_sensor": {
|
||||
"vehicle": {
|
||||
"name": "Vehicle"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue