dontinelli / fyta-custom_component

Home Assistant integration for FYTA plant sensors, configured as custom component
GNU General Public License v3.0
11 stars 1 forks source link

Unexpected error fetching FYTA Coordinator data: 'plant' #17

Closed resterampeberlin closed 7 months ago

resterampeberlin commented 7 months ago

System Health details

System Information

version core-2024.2.5
installation_type Home Assistant Container
dev false
hassio false
docker true
user root
virtualenv false
python_version 3.12.1
os_name Linux
os_version 6.1.21-v7+
arch armv7l
timezone Europe/Berlin
config_dir /config
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 1 -- | -- resources | 0 mode | auto-gen
Recorder oldest_recorder_run | 23. März 2024 um 11:46 -- | -- current_recorder_run | 25. März 2024 um 07:24 estimated_db_size | 14.31 MiB database_engine | sqlite database_version | 3.44.2

Checklist

Describe the issue

The integration crashes once in a while

Reproduction steps

I can´t say when it happens. It just a appears in the log.

Debug logs

2024-03-25 11:42:28.976 ERROR (MainThread) [custom_components.fyta.coordinator] Unexpected error fetching FYTA Coordinator data: 'plant'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/fyta/coordinator.py", line 46, in _async_update_data
    data = await self.fyta.update_all_plants()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fyta_cli/fyta_connector.py", line 73, in update_all_plants
    current_plant = await self.update_plant_data(plant)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/fyta_cli/fyta_connector.py", line 85, in update_plant_data
    plant_data: dict = p["plant"]
                       ~^^^^^^^^^
KeyError: 'plant'

Diagnostics dump

home-assistant_fyta_2024-03-25T11-10-30.774Z.log

dontinelli commented 7 months ago

You write that it happens occasionally. Is this on startup or also during normal operation? Do the sensors otherwise report correct values?

resterampeberlin commented 7 months ago

As you can see from the log it happened 4h after startup. Reported values are ok. It did not happen the first time but now I am monitoring it closer.

dontinelli commented 7 months ago

While not directly linked, it seems that #17 and #18 have a similar root cause, i.e. that invalid data is reported by the server. I guess I have to amend error handling in fyta_cli.

resterampeberlin commented 7 months ago

Yes, that is also my impression because of the random occurrence.

dontinelli commented 7 months ago

@resterampeberlin: can you please confirm if issue is fixed, before I create a new release?

resterampeberlin commented 7 months ago

I have just pulled the update and restarted home assistant. Let´s wait and see ...

resterampeberlin commented 7 months ago

So far no further crashes. It seems to me that you have caught all exceptions.

dontinelli commented 6 months ago

So far no further crashes. It seems to me that you have caught all exceptions.

Thank you. Just issued new release.