sbabcock23 / hass-tryfi

Home Assistant integration for TryFi Dog Collar GPS monitoring.
https://github.com/sbabcock23/hass-tryfi
Apache License 2.0
51 stars 17 forks source link

Two collars - only one added w/ errors #62

Open Mason10198 opened 1 year ago

Mason10198 commented 1 year ago

My scenario consists of the following:

I have been using HASS-TryFi for a while now with no issues, with only ONE collar and ONE base. I just added a second collar/base to my Fi setup, and upon removal/re-initialization of the HASS-TryFi integration, some of the entities are not being integrated. Dog1s collar & base, the old Series 2 base, and Dog2s base are picked up, but Dog2s collar is missing. Image attached, sensitive information removed.

Screenshot

I have removed/reinstalled HASS-TryFi, tried manually installing, several full reboots of my Home Assistant OS machine, etc, all to no avail. Logs are included below, sensitive information removed.

2023-02-08 07:31:16.620 INFO (MainThread) [custom_components.tryfi] Success Connecting to TryFi
2023-02-08 07:31:18.875 INFO (MainThread) [homeassistant.components.device_tracker] Setting up device_tracker.tryfi
2023-02-08 07:31:18.875 INFO (MainThread) [homeassistant.components.light] Setting up light.tryfi
2023-02-08 07:31:18.876 INFO (MainThread) [homeassistant.components.sensor] Setting up sensor.tryfi
2023-02-08 07:31:18.876 INFO (MainThread) [homeassistant.components.select] Setting up select.tryfi
2023-02-08 07:31:18.876 INFO (MainThread) [homeassistant.components.binary_sensor] Setting up binary_sensor.tryfi
2023-02-08 07:31:18.880 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new light.tryfi entity: light.dog1_collar_light
2023-02-08 07:31:18.881 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_collar_battery_level
2023-02-08 07:31:18.882 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_daily_steps
2023-02-08 07:31:18.882 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_weekly_steps
2023-02-08 07:31:18.883 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_monthly_steps
2023-02-08 07:31:18.883 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_daily_distance
2023-02-08 07:31:18.884 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_weekly_distance
2023-02-08 07:31:18.884 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_monthly_distance
2023-02-08 07:31:18.884 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_daily_sleep
2023-02-08 07:31:18.889 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_weekly_sleep
2023-02-08 07:31:18.890 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_monthly_sleep
2023-02-08 07:31:18.890 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_daily_nap
2023-02-08 07:31:18.891 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_weekly_nap
2023-02-08 07:31:18.891 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_monthly_nap
2023-02-08 07:31:18.891 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_activity_type
2023-02-08 07:31:18.892 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_current_place_name
2023-02-08 07:31:18.892 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_current_place_address
2023-02-08 07:31:18.893 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1_connected_to
2023-02-08 07:31:18.893 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog1s_base
2023-02-08 07:31:18.894 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.og_base
2023-02-08 07:31:18.895 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new sensor.tryfi entity: sensor.dog2s_base
2023-02-08 07:31:18.895 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new select.tryfi entity: select.dog1_lost_mode
2023-02-08 07:31:18.896 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new binary_sensor.tryfi entity: binary_sensor.dog1_collar_battery_charging
2023-02-08 07:31:19.261 INFO (MainThread) [homeassistant.helpers.entity_registry] Registered new device_tracker.tryfi entity: device_tracker.dog1_tracker
2023-02-08 07:31:19.262 ERROR (MainThread) [homeassistant.components.light] Error adding entities for domain light with platform tryfi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/light.py", line 90, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.267 ERROR (MainThread) [homeassistant.components.sensor] Error adding entities for domain sensor with platform tryfi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/sensor.py", line 376, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.270 ERROR (MainThread) [homeassistant.components.select] Error adding entities for domain select with platform tryfi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/select.py", line 66, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.271 ERROR (MainThread) [homeassistant.components.binary_sensor] Error adding entities for domain binary_sensor with platform tryfi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/binary_sensor.py", line 88, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.279 ERROR (MainThread) [homeassistant.components.light] Error while setting up tryfi platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/light.py", line 90, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.280 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up tryfi platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/sensor.py", line 376, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.280 ERROR (MainThread) [homeassistant.components.select] Error while setting up tryfi platform for select
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/select.py", line 66, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:19.281 ERROR (MainThread) [homeassistant.components.binary_sensor] Error while setting up tryfi platform for binary_sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/binary_sensor.py", line 88, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:20.203 ERROR (MainThread) [homeassistant.components.device_tracker] Error adding entities for domain device_tracker with platform tryfi
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/device_tracker.py", line 91, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
2023-02-08 07:31:20.204 ERROR (MainThread) [homeassistant.components.device_tracker] Error while setting up tryfi platform for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 301, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 442, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 549, in _async_add_entity
    device_info = entity.device_info
  File "/config/custom_components/tryfi/device_tracker.py", line 91, in device_info
    "model": self.pet.breed,
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiPet.py", line 291, in breed
    return self._breed
AttributeError: 'FiPet' object has no attribute '_breed'
17kisern commented 1 year ago

Very similar experience for myself. It looks like the underlying Python library that @sbabcock23 wrote, of which this Home Assistant integration is a wrapper for, got an update just last week, while this integration hasn't been updated since December. Looking at the classes inside the Python library, it looks like the variables are in fact present, and haven't been touched in the recent library update, so my best guess is something else in the recent update is crashing(?), and the whole library is in an unknown state. Or simply the Home Assistant integration needs to be updated to use the latest pytryfi library, as @rjshade did predict query failures would start to occur without his update.

@rjshade , do you think these errors are related to the Query failures you predicted would happen in the latest pytryfi release?

Including my own stacktrace as a point of reference


  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 182, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 330, in _async_refresh
    self.async_update_listeners()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 135, in async_update_listeners
    update_callback()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 390, in _handle_coordinator_update
    self.async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 566, in async_write_ha_state
    self._async_write_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 607, in _async_write_ha_state
    state = self._stringify_state(available)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 572, in _stringify_state
    if (state := self.state) is None:
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1007, in state
    if (is_on := self.is_on) is None:
  File "/config/custom_components/tryfi/light.py", line 74, in is_on
    return bool(self.pet.device.ledOn)
  File "/usr/local/lib/python3.10/site-packages/pytryfi/fiDevice.py", line 68, in ledOn
    return self._ledOn
AttributeError: 'FiDevice' object has no attribute '_ledOn'```
rjshade commented 1 year ago

I don't think any of these failures are related to the schema change I mentioned. It looks like FiPet._breed and FiDevice._ledOn should be set on successful query responses from the server. Perhaps something is failing with these queries?

jldeen commented 1 year ago

@17kisern and @Mason10198 There has been a new release of hass-tryfi and the underlying package pytryfi - the new version is 0.0.19 and I believe should resolve the issues in this thread. Could you please update to the latest version and close this issue if you are all set? 😀

17kisern commented 1 year ago

I am no longer receiving these errors/bugs after updating to the latest version, thank you @jldeen! Since @Mason10198 created this issue, it's up to him to close it out