mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 01:07:10 +00:00
Add entity translations to OpenGarage (#98834)
This commit is contained in:
parent
3f2c03fe77
commit
342e55409a
@ -22,6 +22,7 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
SENSOR_TYPES: tuple[BinarySensorEntityDescription, ...] = (
|
||||||
BinarySensorEntityDescription(
|
BinarySensorEntityDescription(
|
||||||
key="vehicle",
|
key="vehicle",
|
||||||
|
translation_key="vehicle",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -66,9 +67,6 @@ class OpenGarageBinarySensor(OpenGarageEntity, BinarySensorEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _update_attr(self) -> None:
|
def _update_attr(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""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)
|
state = self.coordinator.data.get(self.entity_description.key)
|
||||||
if state == 1:
|
if state == 1:
|
||||||
self._attr_is_on = True
|
self._attr_is_on = True
|
||||||
|
@ -37,6 +37,7 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
|
|||||||
|
|
||||||
_attr_device_class = CoverDeviceClass.GARAGE
|
_attr_device_class = CoverDeviceClass.GARAGE
|
||||||
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
_attr_supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||||
|
_attr_name = None
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, coordinator: OpenGarageDataUpdateCoordinator, device_id: str
|
self, coordinator: OpenGarageDataUpdateCoordinator, device_id: str
|
||||||
@ -89,7 +90,6 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
|
|||||||
"""Update the state and attributes."""
|
"""Update the state and attributes."""
|
||||||
status = self.coordinator.data
|
status = self.coordinator.data
|
||||||
|
|
||||||
self._attr_name = status["name"]
|
|
||||||
state = STATES_MAP.get(status.get("door")) # type: ignore[arg-type]
|
state = STATES_MAP.get(status.get("door")) # type: ignore[arg-type]
|
||||||
if self._state_before_move is not None:
|
if self._state_before_move is not None:
|
||||||
if self._state_before_move != state:
|
if self._state_before_move != state:
|
||||||
|
@ -12,6 +12,8 @@ from . import DOMAIN, OpenGarageDataUpdateCoordinator
|
|||||||
class OpenGarageEntity(CoordinatorEntity[OpenGarageDataUpdateCoordinator]):
|
class OpenGarageEntity(CoordinatorEntity[OpenGarageDataUpdateCoordinator]):
|
||||||
"""Representation of a OpenGarage entity."""
|
"""Representation of a OpenGarage entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
open_garage_data_coordinator: OpenGarageDataUpdateCoordinator,
|
open_garage_data_coordinator: OpenGarageDataUpdateCoordinator,
|
||||||
|
@ -83,7 +83,4 @@ class OpenGarageSensor(OpenGarageEntity, SensorEntity):
|
|||||||
@callback
|
@callback
|
||||||
def _update_attr(self) -> None:
|
def _update_attr(self) -> None:
|
||||||
"""Handle updated data from the coordinator."""
|
"""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)
|
self._attr_native_value = self.coordinator.data.get(self.entity_description.key)
|
||||||
|
@ -18,5 +18,12 @@
|
|||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"binary_sensor": {
|
||||||
|
"vehicle": {
|
||||||
|
"name": "Vehicle"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user