mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-06-24 09:48:53 +02:00
Added now and unknown states to last seen tracker attribute #203
This commit is contained in:
parent
263b38b301
commit
ccb1b1fae7
1 changed files with 12 additions and 0 deletions
|
@ -145,3 +145,15 @@ class MikrotikHostDeviceTracker(MikrotikDeviceTracker):
|
||||||
def state(self) -> str:
|
def state(self) -> str:
|
||||||
"""Return the state of the device."""
|
"""Return the state of the device."""
|
||||||
return self._ctrl.option_zone if self.is_connected else STATE_NOT_HOME
|
return self._ctrl.option_zone if self.is_connected else STATE_NOT_HOME
|
||||||
|
|
||||||
|
@property
|
||||||
|
def extra_state_attributes(self) -> Mapping[str, Any]:
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = super().extra_state_attributes
|
||||||
|
if self.is_connected:
|
||||||
|
attributes[format_attribute("last-seen")] = "Now"
|
||||||
|
|
||||||
|
if not attributes[format_attribute("last-seen")]:
|
||||||
|
attributes[format_attribute("last-seen")] = "Unknown"
|
||||||
|
|
||||||
|
return attributes
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue