home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.64k stars 29.94k forks source link

integration: tractive - missing location #97718

Closed guybw closed 1 year ago

guybw commented 1 year ago

The problem

I am currently using the Tractive integration but I've noticed that the location of the tracker no longer shows up. I've setup the tracker on my dev box for HA and it's still not showing up at all but the other sensors are. The only issue I saw was the error message below.

I have power saving enabled but that is the only thing that is new in the last 6 months so I've run out of ideas.

What version of Home Assistant Core has the issue?

core-2023.8.0

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

tractive

Link to integration documentation on our website

https://www.home-assistant.io/integrations/tractive/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.device_tracker
Source: components/tractive/device_tracker.py:46
Integration: Device tracker (documentation, issues)
First occurred: August 2, 2023 at 9:54:31 PM (1 occurrences)
Last logged: August 2, 2023 at 9:54:31 PM

Error while setting up tractive platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 362, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/tractive/device_tracker.py", line 31, in async_setup_entry
    entities = [TractiveDeviceTracker(client.user_id, item) for item in trackables]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tractive/device_tracker.py", line 31, in <listcomp>
    entities = [TractiveDeviceTracker(client.user_id, item) for item in trackables]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/tractive/device_tracker.py", line 46, in __init__
    self._battery_level: int = item.hw_info["battery_level"]
                               ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
KeyError: 'battery_level'

Additional information

No response

home-assistant[bot] commented 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!

Code owner commands Code owners of `tractive` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign tractive` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


tractive documentation tractive source (message by IssueLinks)

bieniu commented 1 year ago

Could you please use this as a custom component (copy tractive folder from zip file to /config/custom_components), restart HA and attach here the log file?

tractive.zip

guybw commented 1 year ago

Hi @bieniu I can provide the log if required but it's now working correctly! The location is showing up and it's working great. Thanks so much for getting on this so quickly.

bieniu commented 1 year ago

Please provide the log, I need to understand why your tracker is affected by this issue.

NNMavy commented 1 year ago

I had the same error in my logs so I ran the custom version. As requested here are the logs minus some of the personal data:

2023-08-05 11:01:42.304 WARNING (MainThread) [custom_components.tractive.device_tracker] Item: Trackables(tracker=<Tracker id=XXXXXVOB type=tracker>, trackable={'_id': '62c47b1cdf0e74b63e937c9a', 'created_at': 1657043712, 'updated_at': 1657044249, '_version': 'f193ec10', 'type': 'PET', 'leaderboard_opt_out': False, 'friendship_code': '62c47d19b483e62037d45a09', 'home_location': None, 'deleted_at': None, 'device_id': 'XXXXXVOB', '_type': 'pet', 'user': {'_id': 'xxxxxx', '_type': 'user', '_version': '6f96e1b5'}, 'details': {'name': 'Nova', 'pet_type': 'CAT', 'breed_ids': ['1124'], 'gender': 'F', 'birthday': 1588355712, 'profile_picture_frame': None, 'height': None, 'weight': 4500, 'chip_id': None, 'neutered': False, 'lim': None, 'ribcage': None, 'weight_is_default': None, 'height_is_default': None, 'instagram_username': None, 'profile_picture_id': '7rW76zQDLIOtddJnhs4pFI', 'cover_picture_id': None, 'characteristic_ids': [], 'gallery_picture_ids': [], '_id': '62c47b1dbb578a131f6c6290', '_type': 'pet_detail', '_version': '9b89578f', 'read_only': True}, 'read_only': True}, tracker_details={'_id': 'XXXXXVOB', '_version': 'd8aa0a7d-1871829831-2246856230', 'hw_id': 'XXXXXVOB', 'model_number': 'TRDOG1', 'hw_edition': 'IKATI', 'bluetooth_mac': None, 'geofence_sensitivity': 'HIGH', 'battery_save_mode': True, 'read_only': True, 'read_only_since': 1640104510, 'demo': False, 'self_test_available': False, 'capabilities': ['LT', 'BUZZER', 'LT_BLE', 'LED_BLE', 'BUZZER_BLE', 'LED', 'ACTIVITY_TRACKING'], 'supported_geofence_types': ['CIRCLE', 'RECTANGLE', 'POLYGON'], 'fw_version': 'DOG-027a', 'state': 'NOT_REPORTING', 'charging_state': 'NOT_CHARGING', 'battery_state': 'FULL', 'state_reason': None, '_type': 'tracker'}, hw_info={'code': 4002, 'category': 'REQUEST', 'message': 'The resource device hardware report was not found.', 'detail': None}, pos_report={'time': 1678213664, 'time_rcvd': 1678213669, 'sensor_used': 'GPS', 'pos_status': ['LAST_VALID_FIX', 'STATIONARY_FIX', 'INDOORS'], 'latlong': [51.000000, 4.000000], 'speed': 0.2, 'course': 194, 'pos_uncertainty': 13, '_id': 'XXXXXVOB', '_type': 'device_pos_report', '_version': 'a1a9e8d0a', 'altitude': -8, 'report_id': '5d9c7ce5e8e5a97a0d8e9a1a', 'nearby_user_id': None, 'power_saving_zone_id': None})
2023-08-05 11:01:42.305 WARNING (MainThread) [custom_components.tractive.device_tracker] Item: Trackables(tracker=<Tracker id=XXXXXQUD type=tracker>, trackable={'_id': '62bf1684dae5b1388eac45f3', 'created_at': 1656690304, 'updated_at': 1690362950, '_version': 'fb26237e', 'type': 'PET', 'leaderboard_opt_out': False, 'friendship_code': '62bf17fcf05e8569a9c4e522', 'home_location': [51.000000, 4.000000], 'deleted_at': None, 'device_id': 'XXXXXQUD', '_type': 'pet', 'user': {'_id': 'xxxxxx', '_type': 'user', '_version': '6f96e1b5'}, 'details': {'name': 'Luna', 'pet_type': 'CAT', 'breed_ids': ['1085'], 'gender': 'F', 'birthday': 1588347776, 'profile_picture_frame': None, 'height': None, 'weight': 3200, 'chip_id': '', 'neutered': True, 'lim': 0.14000000059604645, 'ribcage': 0.36000001430511475, 'weight_is_default': None, 'height_is_default': None, 'instagram_username': '', 'profile_picture_id': '5nmyvYpOzhsZ4NwsuF2OYM', 'cover_picture_id': None, 'characteristic_ids': [], 'gallery_picture_ids': [], '_id': '62bf16842313a1cb8fa4dcd6', '_type': 'pet_detail', '_version': 'dbf59995', 'read_only': True}, 'read_only': True}, tracker_details={'_id': 'XXXXXQUD', '_version': 'b3277e40-2260517384-3655590051', 'hw_id': 'XXXXXQUD', 'model_number': 'TG5', 'hw_edition': 'DARKBLUE-TEXTURE-WORLDWIDE', 'bluetooth_mac': None, 'geofence_sensitivity': 'HIGH', 'battery_save_mode': None, 'read_only': True, 'read_only_since': 1656690649, 'demo': False, 'self_test_available': False, 'capabilities': ['LT', 'BUZZER', 'LT_BLE', 'LED_BLE', 'BUZZER_BLE', 'HW_REPORTS_BLE', 'WIFI_SCAN_REPORTS_BLE', 'LED', 'ACTIVITY_TRACKING', 'WIFI_ZONE', 'SLEEP_TRACKING'], 'supported_geofence_types': ['CIRCLE', 'RECTANGLE', 'POLYGON'], 'fw_version': '005.170-TRV5-005-1b8d80', 'state': 'OPERATIONAL', 'state_reason': 'POWER_SAVING', 'charging_state': 'NOT_CHARGING', 'battery_state': 'REGULAR', 'power_saving_zone_id': '6456120b73f75aec222cbe2e', '_type': 'tracker'}, hw_info={'time': 1691220613, 'battery_level': 46, 'clip_mounted_state': None, '_id': 'XXXXXQUD', '_type': 'device_hw_report', '_version': '66a98e6c0', 'report_id': '64cdfa8bad1d8720c6e89a66', 'power_saving_zone_id': '6456120b73f75aec222cbe2e', 'hw_status': None}, pos_report={'time': 1691220613, 'time_rcvd': 1691220621, 'sensor_used': 'KNOWN_WIFI', 'pos_status': None, 'latlong': [51.000000, 4.000000], 'speed': None, 'pos_uncertainty': 30, '_id': 'XXXXXQUD', '_type': 'device_pos_report', '_version': '71dc41943', 'altitude': 2, 'report_id': '6453a558934925834914cd17', 'nearby_user_id': None, 'power_saving_zone_id': '6456120b73f75aec222cbe2e'})
2023-08-05 11:01:42.306 WARNING (MainThread) [custom_components.tractive.device_tracker] Item: Trackables(tracker=<Tracker id=XXXXXVMI type=tracker>, trackable={'_id': '5dcebfc617a55e6ef0aa4642', 'created_at': 1573830656, 'updated_at': 1657043771, '_version': '4d61beb4', 'type': 'PET', 'leaderboard_opt_out': False, 'friendship_code': '5dea5a6304d714d8ecd334c2', 'home_location': None, 'deleted_at': None, 'device_id': 'XXXXXVMI', '_type': 'pet', 'user': {'_id': 'xxxxxx', '_type': 'user', '_version': '6f96e1b5'}, 'details': {'name': 'Moomoo', 'pet_type': 'CAT', 'breed_ids': ['1124'], 'gender': 'M', 'birthday': 1475314432, 'profile_picture_frame': None, 'height': 0.3, 'weight': 4500, 'chip_id': '', 'neutered': True, 'lim': None, 'ribcage': None, 'weight_is_default': True, 'height_is_default': True, 'instagram_username': None, 'profile_picture_id': '7r91izYu6y2QRvFuYG58p7', 'cover_picture_id': None, 'characteristic_ids': None, 'gallery_picture_ids': None, '_id': '5dcebfc692527a175cfdbc3f', '_type': 'pet_detail', '_version': '075aa4ca', 'read_only': True}, 'read_only': True}, tracker_details={'_id': 'XXXXXVMI', '_version': '84331fa9-2260517384-1942427401', 'hw_id': 'XXXXXVMI', 'model_number': 'TRNJA4', 'hw_edition': 'DARKBLUE-TEXTURE', 'bluetooth_mac': None, 'geofence_sensitivity': 'HIGH', 'battery_save_mode': True, 'read_only': True, 'read_only_since': 1657044294, 'demo': False, 'self_test_available': False, 'capabilities': ['LT', 'BUZZER', 'LT_BLE', 'LED_BLE', 'BUZZER_BLE', 'HW_REPORTS_BLE', 'WIFI_SCAN_REPORTS_BLE', 'LED', 'ACTIVITY_TRACKING', 'WIFI_ZONE', 'SLEEP_TRACKING'], 'supported_geofence_types': ['CIRCLE', 'RECTANGLE', 'POLYGON'], 'fw_version': '005.170-TRV4-005-1b8d80', 'state': 'OPERATIONAL', 'state_reason': 'POWER_SAVING', 'charging_state': 'NOT_CHARGING', 'battery_state': 'FULL', 'power_saving_zone_id': '62c80db4ae91d68181f7868a', '_type': 'tracker'}, hw_info={'time': 1691216910, 'battery_level': 96, 'clip_mounted_state': None, '_id': 'XXXXXVMI', '_type': 'device_hw_report', '_version': '790288ed3', 'report_id': '64cdec13ba7c7823de882097', 'power_saving_zone_id': '62c80db4ae91d68181f7868a', 'hw_status': None}, pos_report={'time': 1691216910, 'time_rcvd': 1691216917, 'sensor_used': 'KNOWN_WIFI', 'pos_status': None, 'latlong': [51.000000, 4.000000], 'speed': None, 'pos_uncertainty': 30, '_id': 'XXXXXVMI', '_type': 'device_pos_report', '_version': 'b13af7966', 'altitude': 2, 'report_id': '6296ed2ce38211a6697fa31b', 'nearby_user_id': None, 'power_saving_zone_id': '62c80db4ae91d68181f7868a'})
bieniu commented 1 year ago

Thank you @NNMavy

BerraHok commented 1 year ago

Does it mean that a fix for the integration (for instance battery level not handled correctly) will be released in a future update of HA?

bieniu commented 1 year ago

Yes, 2023.8.2.

BerraHok commented 1 year ago

Thanks!

BerraHok commented 1 year ago

Hi

Just updated to HA 2023.8.2, but battery level still not working (unavailable). Any ideas?

bieniu commented 1 year ago

This issue is not related to missing state for battery level entity. Please open a new issue and attach the diagnostics file.