Exclude AsusWRT tracker state attribute from recorder (#102602)

This commit is contained in:
ollo69 2023-10-23 23:16:27 +02:00 committed by GitHub
parent 5d430f53cd
commit 5245c94342
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,8 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DATA_ASUSWRT, DOMAIN
from .router import AsusWrtDevInfo, AsusWrtRouter
ATTR_LAST_TIME_REACHABLE = "last_time_reachable"
DEFAULT_DEVICE_NAME = "Unknown device"
@ -52,6 +54,8 @@ def add_entities(
class AsusWrtDevice(ScannerEntity):
"""Representation of a AsusWrt device."""
_unrecorded_attributes = frozenset({ATTR_LAST_TIME_REACHABLE})
_attr_should_poll = False
def __init__(self, router: AsusWrtRouter, device: AsusWrtDevInfo) -> None:
@ -97,7 +101,7 @@ class AsusWrtDevice(ScannerEntity):
self._attr_extra_state_attributes = {}
if self._device.last_activity:
self._attr_extra_state_attributes[
"last_time_reachable"
ATTR_LAST_TIME_REACHABLE
] = self._device.last_activity.isoformat(timespec="seconds")
self.async_write_ha_state()