Add device classes to Verisure sensors (#47990)
This commit is contained in:
parent
4dc0cdbb5f
commit
f695155af5
6 changed files with 29 additions and 15 deletions
|
@ -48,12 +48,12 @@ class VerisureAlarm(CoordinatorEntity, AlarmControlPanelEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the device."""
|
"""Return the name of the entity."""
|
||||||
return "Verisure Alarm"
|
return "Verisure Alarm"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID for this alarm control panel."""
|
"""Return the unique ID for this entity."""
|
||||||
return self.coordinator.entry.data[CONF_GIID]
|
return self.coordinator.entry.data[CONF_GIID]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -68,7 +68,7 @@ class VerisureAlarm(CoordinatorEntity, AlarmControlPanelEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str | None:
|
def state(self) -> str | None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the entity."""
|
||||||
status = self.coordinator.data["alarm"]["statusType"]
|
status = self.coordinator.data["alarm"]["statusType"]
|
||||||
if status == "DISARMED":
|
if status == "DISARMED":
|
||||||
self._state = STATE_ALARM_DISARMED
|
self._state = STATE_ALARM_DISARMED
|
||||||
|
|
|
@ -22,7 +22,7 @@ async def async_setup_entry(
|
||||||
entry: ConfigEntry,
|
entry: ConfigEntry,
|
||||||
async_add_entities: Callable[[Iterable[Entity]], None],
|
async_add_entities: Callable[[Iterable[Entity]], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Set up Verisure sensors based on a config entry."""
|
"""Set up Verisure binary sensors based on a config entry."""
|
||||||
coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
coordinator: VerisureDataUpdateCoordinator = hass.data[DOMAIN][entry.entry_id]
|
||||||
|
|
||||||
sensors: list[Entity] = [VerisureEthernetStatus(coordinator)]
|
sensors: list[Entity] = [VerisureEthernetStatus(coordinator)]
|
||||||
|
@ -49,12 +49,12 @@ class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the binary sensor."""
|
"""Return the name of this entity."""
|
||||||
return self.coordinator.data["door_window"][self.serial_number]["area"]
|
return self.coordinator.data["door_window"][self.serial_number]["area"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID for this alarm control panel."""
|
"""Return the unique ID for this entity."""
|
||||||
return f"{self.serial_number}_door_window"
|
return f"{self.serial_number}_door_window"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -72,7 +72,7 @@ class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
"""Return the class of this entity."""
|
||||||
return DEVICE_CLASS_OPENING
|
return DEVICE_CLASS_OPENING
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -98,12 +98,12 @@ class VerisureEthernetStatus(CoordinatorEntity, BinarySensorEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the binary sensor."""
|
"""Return the name of this entity."""
|
||||||
return "Verisure Ethernet status"
|
return "Verisure Ethernet status"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID for this binary sensor."""
|
"""Return the unique ID for this entity."""
|
||||||
return f"{self.coordinator.entry.data[CONF_GIID]}_ethernet"
|
return f"{self.coordinator.entry.data[CONF_GIID]}_ethernet"
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -128,5 +128,5 @@ class VerisureEthernetStatus(CoordinatorEntity, BinarySensorEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str:
|
def device_class(self) -> str:
|
||||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
"""Return the class of this entity."""
|
||||||
return DEVICE_CLASS_CONNECTIVITY
|
return DEVICE_CLASS_CONNECTIVITY
|
||||||
|
|
|
@ -64,12 +64,12 @@ class VerisureSmartcam(CoordinatorEntity, Camera):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of this camera."""
|
"""Return the name of this entity."""
|
||||||
return self.coordinator.data["cameras"][self.serial_number]["area"]
|
return self.coordinator.data["cameras"][self.serial_number]["area"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unique_id(self) -> str:
|
def unique_id(self) -> str:
|
||||||
"""Return the unique ID for this camera."""
|
"""Return the unique ID for this entity."""
|
||||||
return self.serial_number
|
return self.serial_number
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -71,7 +71,7 @@ class VerisureDoorlock(CoordinatorEntity, LockEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name of the lock."""
|
"""Return the name of this entity."""
|
||||||
return self.coordinator.data["locks"][self.serial_number]["area"]
|
return self.coordinator.data["locks"][self.serial_number]["area"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -3,6 +3,10 @@ from __future__ import annotations
|
||||||
|
|
||||||
from typing import Any, Callable, Iterable
|
from typing import Any, Callable, Iterable
|
||||||
|
|
||||||
|
from homeassistant.components.sensor import (
|
||||||
|
DEVICE_CLASS_HUMIDITY,
|
||||||
|
DEVICE_CLASS_TEMPERATURE,
|
||||||
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
|
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
|
@ -64,6 +68,11 @@ class VerisureThermometer(CoordinatorEntity, Entity):
|
||||||
"""Return the unique ID for this entity."""
|
"""Return the unique ID for this entity."""
|
||||||
return f"{self.serial_number}_temperature"
|
return f"{self.serial_number}_temperature"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self) -> str:
|
||||||
|
"""Return the class of this entity."""
|
||||||
|
return DEVICE_CLASS_TEMPERATURE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> dict[str, Any]:
|
def device_info(self) -> dict[str, Any]:
|
||||||
"""Return device information about this entity."""
|
"""Return device information about this entity."""
|
||||||
|
@ -123,6 +132,11 @@ class VerisureHygrometer(CoordinatorEntity, Entity):
|
||||||
"""Return the unique ID for this entity."""
|
"""Return the unique ID for this entity."""
|
||||||
return f"{self.serial_number}_humidity"
|
return f"{self.serial_number}_humidity"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def device_class(self) -> str:
|
||||||
|
"""Return the class of this entity."""
|
||||||
|
return DEVICE_CLASS_HUMIDITY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_info(self) -> dict[str, Any]:
|
def device_info(self) -> dict[str, Any]:
|
||||||
"""Return device information about this entity."""
|
"""Return device information about this entity."""
|
||||||
|
@ -197,7 +211,7 @@ class VerisureMouseDetection(CoordinatorEntity, Entity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self) -> str | None:
|
def state(self) -> str | None:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the entity."""
|
||||||
return self.coordinator.data["mice"][self.serial_number]["detections"]
|
return self.coordinator.data["mice"][self.serial_number]["detections"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -43,7 +43,7 @@ class VerisureSmartplug(CoordinatorEntity, SwitchEntity):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self) -> str:
|
def name(self) -> str:
|
||||||
"""Return the name or location of the smartplug."""
|
"""Return the name of this entity."""
|
||||||
return self.coordinator.data["smart_plugs"][self.serial_number]["area"]
|
return self.coordinator.data["smart_plugs"][self.serial_number]["area"]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
Loading…
Add table
Reference in a new issue