New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ignore trackable
without details
in Tractive integration
#109814
Ignore trackable
without details
in Tractive integration
#109814
Conversation
Hey there @Danielhiversen, @zhulik, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I have tested, and it works, but I would change it to diff --git a/homeassistant/components/tractive/__init__.py b/homeassistant/components/tractive/__init__.py
index 79b1b6d7db..c0d214750e 100644
--- a/homeassistant/components/tractive/__init__.py
+++ b/homeassistant/components/tractive/__init__.py
@@ -103,7 +103,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
# So we have to remove None values from trackables list. Additionally, we must omit
# trackables that do not have `details`, pets shared from another account do not
# contain details.
- trackables = [item for item in trackables if item and "details" in item.trackable]
+ trackables = [item for item in trackables if item]
hass.data[DOMAIN][entry.entry_id][CLIENT] = tractive
hass.data[DOMAIN][entry.entry_id][TRACKABLES] = trackables
@@ -130,6 +130,10 @@ async def _generate_trackables(
# Check that the pet has tracker linked.
if not trackable["device_id"]:
return None
+
+ if "details" not in trackable:
+ _LOGGER.warning("Tracker %s has no details and will be skipped. This happens for shared trackers", trackable["device_id"])
+ return None
tracker = client.tracker(trackable["device_id"]) |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @bieniu 👍
../Frenck
Breaking change
Proposed change
It appears that currently the Tractive API does not provide details about a tracker that is shared from another account. We don't know if this is a temporary bug or a change in API functionality. With this change, trackers without details will be skipped.
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: