Skip to content

Commit

Permalink
Add extra attributes speed and heading
Browse files Browse the repository at this point in the history
  • Loading branch information
MTrab committed Mar 29, 2024
1 parent 4f12a3d commit 56f5828
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion custom_components/webastoconnect/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from homeassistant.util import slugify as util_slugify

from .api import WebastoConnectUpdateCoordinator
from .const import ATTR_COORDINATOR, DOMAIN
from .const import ATTR_COORDINATOR, ATTR_DIRECTION, ATTR_SPEED, DOMAIN

LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -75,6 +75,16 @@ def __init__(
util_slugify(f"{self.coordinator.cloud.name} {self._attr_name}")
)

self._attributes = {
ATTR_DIRECTION: self.coordinator.cloud.heading,
ATTR_SPEED: self.coordinator.cloud.speed,
}

@property
def extra_state_attributes(self):
"""Return device specific attributes."""
return self._attributes

@property
def available(self) -> bool:
"""Handle the location states."""
Expand All @@ -94,6 +104,12 @@ def _handle_coordinator_update(self) -> None:
):
self._prev_lat = self.coordinator.cloud.location["lat"]
self._prev_lon = self.coordinator.cloud.location["lon"]

self._attributes = {
ATTR_DIRECTION: self.coordinator.cloud.heading,
ATTR_SPEED: self.coordinator.cloud.speed,
}

self.async_write_ha_state()

@property
Expand Down

0 comments on commit 56f5828

Please sign in to comment.