Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #460 from Thomas55555/only-setup-device_tracker-if…
Browse files Browse the repository at this point in the history
…-mower-has-coordinates

only setup device_tracker if mower has coordinates
  • Loading branch information
Thomas55555 authored May 22, 2023
2 parents ca27905 + 0b7f259 commit 9a9ff63
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions custom_components/husqvarna_automower/device_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,17 @@ async def async_setup_entry(
) -> None:
"""Set up device_tracker platform."""
coordinator = hass.data[DOMAIN][entry.entry_id]
async_add_entities(
AutomowerTracker(coordinator, idx)
for idx, ent in enumerate(coordinator.session.data["data"])
)
entity_list = []
for idx, ent in enumerate(coordinator.session.data["data"]):
try:
coordinator.session.data["data"][idx]["attributes"]["positions"][0][
"latitude"
]
entity_list.append(AutomowerTracker(coordinator, idx))
except IndexError:
pass

async_add_entities(entity_list)


class AutomowerTracker(TrackerEntity, AutomowerEntity):
Expand Down

0 comments on commit 9a9ff63

Please sign in to comment.