mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Motion blinds add translations (#99078)
This commit is contained in:
parent
3c30ad1850
commit
cf8da2fc89
@ -33,7 +33,6 @@ from .const import (
|
|||||||
UPDATE_INTERVAL_MOVING_WIFI,
|
UPDATE_INTERVAL_MOVING_WIFI,
|
||||||
)
|
)
|
||||||
from .entity import MotionCoordinatorEntity
|
from .entity import MotionCoordinatorEntity
|
||||||
from .gateway import device_name
|
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -170,6 +169,7 @@ async def async_setup_entry(
|
|||||||
class MotionPositionDevice(MotionCoordinatorEntity, CoverEntity):
|
class MotionPositionDevice(MotionCoordinatorEntity, CoverEntity):
|
||||||
"""Representation of a Motion Blind Device."""
|
"""Representation of a Motion Blind Device."""
|
||||||
|
|
||||||
|
_attr_name = None
|
||||||
_restore_tilt = False
|
_restore_tilt = False
|
||||||
|
|
||||||
def __init__(self, coordinator, blind, device_class):
|
def __init__(self, coordinator, blind, device_class):
|
||||||
@ -184,9 +184,7 @@ class MotionPositionDevice(MotionCoordinatorEntity, CoverEntity):
|
|||||||
else:
|
else:
|
||||||
self._update_interval_moving = UPDATE_INTERVAL_MOVING
|
self._update_interval_moving = UPDATE_INTERVAL_MOVING
|
||||||
|
|
||||||
name = device_name(blind)
|
|
||||||
self._attr_device_class = device_class
|
self._attr_device_class = device_class
|
||||||
self._attr_name = name
|
|
||||||
self._attr_unique_id = blind.mac
|
self._attr_unique_id = blind.mac
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -402,7 +400,7 @@ class MotionTDBUDevice(MotionPositionDevice):
|
|||||||
super().__init__(coordinator, blind, device_class)
|
super().__init__(coordinator, blind, device_class)
|
||||||
self._motor = motor
|
self._motor = motor
|
||||||
self._motor_key = motor[0]
|
self._motor_key = motor[0]
|
||||||
self._attr_name = f"{device_name(blind)} {motor}"
|
self._attr_translation_key = motor.lower()
|
||||||
self._attr_unique_id = f"{blind.mac}-{motor}"
|
self._attr_unique_id = f"{blind.mac}-{motor}"
|
||||||
|
|
||||||
if self._motor not in ["Bottom", "Top", "Combined"]:
|
if self._motor not in ["Bottom", "Top", "Combined"]:
|
||||||
|
@ -22,6 +22,8 @@ from .gateway import device_name
|
|||||||
class MotionCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinatorMotionBlinds]):
|
class MotionCoordinatorEntity(CoordinatorEntity[DataUpdateCoordinatorMotionBlinds]):
|
||||||
"""Representation of a Motion Blind entity."""
|
"""Representation of a Motion Blind entity."""
|
||||||
|
|
||||||
|
_attr_has_entity_name = True
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
coordinator: DataUpdateCoordinatorMotionBlinds,
|
coordinator: DataUpdateCoordinatorMotionBlinds,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
"""Support for Motion Blinds sensors."""
|
"""Support for Motion Blinds sensors."""
|
||||||
from motionblinds import DEVICE_TYPES_GATEWAY, DEVICE_TYPES_WIFI, BlindType
|
from motionblinds import DEVICE_TYPES_WIFI, BlindType
|
||||||
|
|
||||||
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
@ -13,7 +13,6 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
|
|
||||||
from .const import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
|
from .const import DOMAIN, KEY_COORDINATOR, KEY_GATEWAY
|
||||||
from .entity import MotionCoordinatorEntity
|
from .entity import MotionCoordinatorEntity
|
||||||
from .gateway import device_name
|
|
||||||
|
|
||||||
ATTR_BATTERY_VOLTAGE = "battery_voltage"
|
ATTR_BATTERY_VOLTAGE = "battery_voltage"
|
||||||
|
|
||||||
@ -53,8 +52,6 @@ class MotionBatterySensor(MotionCoordinatorEntity, SensorEntity):
|
|||||||
def __init__(self, coordinator, blind):
|
def __init__(self, coordinator, blind):
|
||||||
"""Initialize the Motion Battery Sensor."""
|
"""Initialize the Motion Battery Sensor."""
|
||||||
super().__init__(coordinator, blind)
|
super().__init__(coordinator, blind)
|
||||||
|
|
||||||
self._attr_name = f"{device_name(blind)} battery"
|
|
||||||
self._attr_unique_id = f"{blind.mac}-battery"
|
self._attr_unique_id = f"{blind.mac}-battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -77,7 +74,7 @@ class MotionTDBUBatterySensor(MotionBatterySensor):
|
|||||||
|
|
||||||
self._motor = motor
|
self._motor = motor
|
||||||
self._attr_unique_id = f"{blind.mac}-{motor}-battery"
|
self._attr_unique_id = f"{blind.mac}-{motor}-battery"
|
||||||
self._attr_name = f"{device_name(blind)} {motor} battery"
|
self._attr_translation_key = f"{motor.lower()}_battery"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
@ -108,14 +105,7 @@ class MotionSignalStrengthSensor(MotionCoordinatorEntity, SensorEntity):
|
|||||||
def __init__(self, coordinator, blind):
|
def __init__(self, coordinator, blind):
|
||||||
"""Initialize the Motion Signal Strength Sensor."""
|
"""Initialize the Motion Signal Strength Sensor."""
|
||||||
super().__init__(coordinator, blind)
|
super().__init__(coordinator, blind)
|
||||||
|
|
||||||
if blind.device_type in DEVICE_TYPES_GATEWAY:
|
|
||||||
name = "Motion gateway signal strength"
|
|
||||||
else:
|
|
||||||
name = f"{device_name(blind)} signal strength"
|
|
||||||
|
|
||||||
self._attr_unique_id = f"{blind.mac}-RSSI"
|
self._attr_unique_id = f"{blind.mac}-RSSI"
|
||||||
self._attr_name = name
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def native_value(self):
|
def native_value(self):
|
||||||
|
@ -60,5 +60,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"cover": {
|
||||||
|
"top": {
|
||||||
|
"name": "Top"
|
||||||
|
},
|
||||||
|
"bottom": {
|
||||||
|
"name": "Bottom"
|
||||||
|
},
|
||||||
|
"combined": {
|
||||||
|
"name": "Combined"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"sensor": {
|
||||||
|
"top_battery": {
|
||||||
|
"name": "Top battery"
|
||||||
|
},
|
||||||
|
"bottom_battery": {
|
||||||
|
"name": "Bottom battery"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user