Add device classes to Verisure sensors (#47990)

pull/47997/head
Franck Nijhof 2021-03-16 16:30:04 +01:00 committed by GitHub
parent 4dc0cdbb5f
commit f695155af5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 15 deletions

View File

@ -48,12 +48,12 @@ class VerisureAlarm(CoordinatorEntity, AlarmControlPanelEntity):
@property
def name(self) -> str:
"""Return the name of the device."""
"""Return the name of the entity."""
return "Verisure Alarm"
@property
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]
@property
@ -68,7 +68,7 @@ class VerisureAlarm(CoordinatorEntity, AlarmControlPanelEntity):
@property
def state(self) -> str | None:
"""Return the state of the device."""
"""Return the state of the entity."""
status = self.coordinator.data["alarm"]["statusType"]
if status == "DISARMED":
self._state = STATE_ALARM_DISARMED

View File

@ -22,7 +22,7 @@ async def async_setup_entry(
entry: ConfigEntry,
async_add_entities: Callable[[Iterable[Entity]], 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]
sensors: list[Entity] = [VerisureEthernetStatus(coordinator)]
@ -49,12 +49,12 @@ class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity):
@property
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"]
@property
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"
@property
@ -72,7 +72,7 @@ class VerisureDoorWindowSensor(CoordinatorEntity, BinarySensorEntity):
@property
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
@property
@ -98,12 +98,12 @@ class VerisureEthernetStatus(CoordinatorEntity, BinarySensorEntity):
@property
def name(self) -> str:
"""Return the name of the binary sensor."""
"""Return the name of this entity."""
return "Verisure Ethernet status"
@property
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"
@property
@ -128,5 +128,5 @@ class VerisureEthernetStatus(CoordinatorEntity, BinarySensorEntity):
@property
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

View File

@ -64,12 +64,12 @@ class VerisureSmartcam(CoordinatorEntity, Camera):
@property
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"]
@property
def unique_id(self) -> str:
"""Return the unique ID for this camera."""
"""Return the unique ID for this entity."""
return self.serial_number
@property

View File

@ -71,7 +71,7 @@ class VerisureDoorlock(CoordinatorEntity, LockEntity):
@property
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"]
@property

View File

@ -3,6 +3,10 @@ from __future__ import annotations
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.const import PERCENTAGE, TEMP_CELSIUS
from homeassistant.core import HomeAssistant
@ -64,6 +68,11 @@ class VerisureThermometer(CoordinatorEntity, Entity):
"""Return the unique ID for this entity."""
return f"{self.serial_number}_temperature"
@property
def device_class(self) -> str:
"""Return the class of this entity."""
return DEVICE_CLASS_TEMPERATURE
@property
def device_info(self) -> dict[str, Any]:
"""Return device information about this entity."""
@ -123,6 +132,11 @@ class VerisureHygrometer(CoordinatorEntity, Entity):
"""Return the unique ID for this entity."""
return f"{self.serial_number}_humidity"
@property
def device_class(self) -> str:
"""Return the class of this entity."""
return DEVICE_CLASS_HUMIDITY
@property
def device_info(self) -> dict[str, Any]:
"""Return device information about this entity."""
@ -197,7 +211,7 @@ class VerisureMouseDetection(CoordinatorEntity, Entity):
@property
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"]
@property

View File

@ -43,7 +43,7 @@ class VerisureSmartplug(CoordinatorEntity, SwitchEntity):
@property
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"]
@property