Closed alpy-nz closed 1 year ago
Hey there @danielhiversen, @zhulik, @bieniu, mind taking a look at this issue as it has been labeled with an integration (tractive
) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)
tractive documentation tractive source (message by IssueLinks)
Add this to your configuration.yaml
file:
logger:
default: warning
logs:
aiotractive: debug
homeassistant.components.tractive: debug
restart HA, wait 3-4 hours and attach here the log file. Please also attach the screenshot of the calories burned sensor history.
used the debugv11.zip to see if this would make it update - made no difference log file is using this- regressed back to 2023.7.2 and all ok again updates work as expected
Custom version of the integration is not supported.
hi see enclosed - log and screenshots - calories are unavailable- no updates in 3H as original symptom..regress back to 7.2 back to updating again
calories are unavailable
Please show me history of this sensor.
The attached log file contains only several seconds of HA work. Please attach a valid log file
apologies see 3h log the 19:46 event was a forced reload of tractive to check that i could get info into the log ok home-assistant_2023-10-30T22-25-39.019Z.log
Same issue here. The integration delivers data when first loaded or when reloaded, but then nothing is updated. Logs show no activity after the initial load. Let me know if I can help with debugging.
@stalar Yes, you can attach the log file.
@stalar Yes, you can attach the log file.
Not much to it, but here it is (I have removed logs from other integrations and edited some identifiers and locations for privacy).
I ran this little python snippet and it works correctly, so the problem seems to be in the HA integration, not the underlying library:
import asyncio
from aiotractive import Tractive
async def main():
async with Tractive("USER", "PASSWORD") as client:
client.authenticate()
async for event in client.events():
print(event)
if __name__ == "__main__":
asyncio.run(main())
Not much to it, but here it is
@alpy-nz @stalar Install this as a custom component, restart HA and report back tractive-fix.zip
I restarted with the suggested log configuration at 08:35. I got the attached logs at 08:36. It is now 19:15 and nothing has been logged since then.
If you are using Tractive as a custom component you should change the logger configuration. homeassistant.components.tractive
should be changed to custom_components.tractive
. If you don’t see a new events for an hour please attach the log file.
I think I found the problem. The wellness event does have a sleep
field, but it is set to None
. Thus the code event.get("sleep", {})
will not return the expected {}
but None
. I changed the method to this:
def _send_wellness_update(self, event: dict[str, Any]) -> None:
day = 0
night = 0
if event["sleep"]:
day = event["sleep"]["minutes_day_sleep"]
night = event["sleep"]["minutes_night_sleep"];
payload = {
ATTR_ACTIVITY_LABEL: event["wellness"].get("activity_label"),
ATTR_CALORIES: event["activity"]["calories"],
ATTR_MINUTES_DAY_SLEEP: day,
ATTR_MINUTES_NIGHT_SLEEP: night,
ATTR_MINUTES_REST: event["activity"]["minutes_rest"],
ATTR_SLEEP_LABEL: event["wellness"].get("sleep_label"),
}
self._dispatch_tracker_event(
TRACKER_WELLNESS_STATUS_UPDATED, event["pet_id"], payload
)
and it now seems to work as expected. Feel free to change the code to something more Pythonesque!
Also: to find the error I had to change the try-except to look at Exception (it was not enough to look at TypeError).
We don’t want to return 0
if there is no sleep information. Please attach the log file.
i used tractive fix.zip - log attached - same behaviour i think ie no updates home-assistant_2023-10-31T20-27-33.529Z.log
With the custom component from fix.zip (which I assume is from this PR: https://github.com/home-assistant/core/pull/103138) the logs are identical to the released version of the tractive integration.
If I modify the code in fix.zip to catch Exception
instead of TypeError
, I get the same logs but then an additional line:
... 2023-11-01 08:29:46.281 DEBUG (MainThread) [custom_components.tractive] Received event: {'message': 'wellness_overview', 'pet_id': '5c9d26dc6e65da663822exxx', 'wellness': {'score': 82, 'activity_label': 'GOOD', 'sleep_label': None, 'rest_label': 'GOOD', 'remaining_days_until_score': 0}, 'activity': {'hourly_distribution': [0, 0, 0, 0, 0, 0, 0, 2, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], 'minutes_active': 8, 'minutes_rest': 36, 'minutes_goal': 120, 'calories': 110, 'average_minutes_active': 70, 'average_minutes_rest': 490, 'current_streak': 0, 'best_day': False}, 'sleep': None, 'health_monitoring_status': None, 'associated_data': ['WELLNESS_WEEKLY_REPORT']} 2023-11-01 08:29:46.283 ERROR (MainThread) [custom_components.tractive] Error while listening for events: 'NoneType' object has no attribute 'get'
This is what I was referring to in my comment (https://github.com/home-assistant/core/issues/103020#issuecomment-1787897090) earlier.
I then made additional changes in _send_wellness_update to avoid the get
on NoneType
(when 'sleep': None
appears). With these changes, the custom component runs fine. My suggestion is that you make similar changes in the PR: https://github.com/home-assistant/core/pull/103138
Thanks!
Yeah I made a mistake, try this one: tractive-sleep-fix.zip
I have tried sleep-fix and initial results look good- getting updates – will see how it goes rest of today Many thanks !
Yeah I made a mistake, try this one: tractive-sleep-fix.zip
Working well for me!
Hi all,
My Tractive: Will not Update, i've read through this feed but the fix is kind of lost on me as i'm still new to HA.
Is a update going to be released? Or would someone be able to provide an idiots guide how to get this fix to work. Thanks
The fix should be a part of HA 2023.11.2.
The problem
Since update to 2023.10.5 tractive will not update unless forced to do so
What version of Home Assistant Core has the issue?
core-2023.10.5
What was the last working version of Home Assistant Core?
2023.7.2
What type of installation are you running?
Home Assistant OS
Integration causing the issue
Tractive
Link to integration documentation on our website
No response
Diagnostics information
home-assistant.log
Example YAML snippet
No response
Anything in the logs that might be useful for us?
Additional information
i am using an OVA within promxox