Add entity translations to Blink (#95138)

This commit is contained in:
Joost Lekkerkerker 2023-06-26 18:29:33 +02:00 committed by GitHub
parent 07936884a3
commit 36ded01264
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 10 deletions

View File

@ -41,6 +41,7 @@ class BlinkSyncModule(AlarmControlPanelEntity):
_attr_icon = ICON
_attr_supported_features = AlarmControlPanelEntityFeature.ARM_AWAY
_attr_name = None
def __init__(self, data, name, sync):
"""Initialize the alarm control panel."""
@ -48,9 +49,10 @@ class BlinkSyncModule(AlarmControlPanelEntity):
self.sync = sync
self._name = name
self._attr_unique_id = sync.serial
self._attr_name = f"{DOMAIN} {name}"
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, sync.serial)}, name=name, manufacturer=DEFAULT_BRAND
identifiers={(DOMAIN, sync.serial)},
name=f"{DOMAIN} {name}",
manufacturer=DEFAULT_BRAND,
)
def update(self) -> None:

View File

@ -27,17 +27,15 @@ _LOGGER = logging.getLogger(__name__)
BINARY_SENSORS_TYPES: tuple[BinarySensorEntityDescription, ...] = (
BinarySensorEntityDescription(
key=TYPE_BATTERY,
name="Battery",
device_class=BinarySensorDeviceClass.BATTERY,
entity_category=EntityCategory.DIAGNOSTIC,
),
BinarySensorEntityDescription(
key=TYPE_CAMERA_ARMED,
name="Camera Armed",
translation_key="camera_armed",
),
BinarySensorEntityDescription(
key=TYPE_MOTION_DETECTED,
name="Motion Detected",
device_class=BinarySensorDeviceClass.MOTION,
),
)

View File

@ -38,11 +38,12 @@ async def async_setup_entry(
class BlinkCamera(Camera):
"""An implementation of a Blink Camera."""
_attr_name = None
def __init__(self, data, name, camera):
"""Initialize a camera."""
super().__init__()
self.data = data
self._attr_name = f"{DOMAIN} {name}"
self._camera = camera
self._attr_unique_id = f"{camera.serial}-camera"
self._attr_device_info = DeviceInfo(

View File

@ -25,14 +25,13 @@ _LOGGER = logging.getLogger(__name__)
SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key=TYPE_TEMPERATURE,
name="Temperature",
native_unit_of_measurement=UnitOfTemperature.FAHRENHEIT,
device_class=SensorDeviceClass.TEMPERATURE,
entity_category=EntityCategory.DIAGNOSTIC,
),
SensorEntityDescription(
key=TYPE_WIFI_STRENGTH,
name="Wifi Signal",
translation_key="wifi_rssi",
native_unit_of_measurement=SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
device_class=SensorDeviceClass.SIGNAL_STRENGTH,
entity_category=EntityCategory.DIAGNOSTIC,
@ -57,10 +56,11 @@ async def async_setup_entry(
class BlinkSensor(SensorEntity):
"""A Blink camera sensor."""
_attr_has_entity_name = True
def __init__(self, data, camera, description: SensorEntityDescription) -> None:
"""Initialize sensors from Blink camera."""
self.entity_description = description
self._attr_name = f"{DOMAIN} {camera} {description.name}"
self.data = data
self._camera = data.cameras[camera]
self._attr_unique_id = f"{self._camera.serial}-{description.key}"
@ -71,7 +71,7 @@ class BlinkSensor(SensorEntity):
)
self._attr_device_info = DeviceInfo(
identifiers={(DOMAIN, self._camera.serial)},
name=camera,
name=f"{DOMAIN} {camera}",
manufacturer=DEFAULT_BRAND,
model=self._camera.camera_type,
)

View File

@ -34,5 +34,17 @@
"description": "Configure Blink integration"
}
}
},
"entity": {
"sensor": {
"wifi_rssi": {
"name": "Wi-Fi RSSI"
}
},
"binary_sensor": {
"camera_armed": {
"name": "Camera armed"
}
}
}
}