Add last trip time attribute to Verisure binary sensors (#89944)

pull/73877/head^2
skrynklarn 2023-03-27 00:17:12 +02:00 committed by GitHub
parent 00ce757051
commit bdd095423b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -6,11 +6,12 @@ from homeassistant.components.binary_sensor import (
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import EntityCategory
from homeassistant.const import ATTR_LAST_TRIP_TIME, EntityCategory
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo, Entity
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.util import dt as dt_util
from .const import CONF_GIID, DOMAIN
from .coordinator import VerisureDataUpdateCoordinator
@ -79,6 +80,15 @@ class VerisureDoorWindowSensor(
and self.serial_number in self.coordinator.data["door_window"]
)
@property
def extra_state_attributes(self):
"""Return the state attributes of the sensor."""
return {
ATTR_LAST_TRIP_TIME: dt_util.parse_datetime(
self.coordinator.data["door_window"][self.serial_number]["reportTime"]
)
}
class VerisureEthernetStatus(
CoordinatorEntity[VerisureDataUpdateCoordinator], BinarySensorEntity