dvd-dev / hilo

Home Assistant Hilo Integration via HACS
MIT License
122 stars 26 forks source link

Invalidation du cache intelligente #358

Closed valleedelisle closed 5 months ago

valleedelisle commented 5 months ago

Si un defi est en mode pre_heat, et que les metadata du defi datent d'avant le debut du pre_heat, on doit invalider le cache pour aller chercher les nouvelles donnees populees par Hilo.

Depends on dvd-dev/python-hilo#165

ic-dev21 commented 5 months ago

En test jusqu'au prochain défi, just in case. If it works, will merge.

ic-dev21 commented 5 months ago

Test supplémentaire, l'invalidation plantait:

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:898 
First occurred: 4:03:03 AM (4 occurrences) 
Last logged: 5:33:01 AM

Update for sensor.defi_hilo fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 898, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1216, in async_device_update
    await self.async_update()
  File "/config/custom_components/hilo/sensor.py", line 665, in _async_update
    details = await self._hilo.get_event_details(raw_event["id"])
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/hilo/__init__.py", line 368, in get_event_details
    if event.invalid:
       ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyhilo/event.py", line 110, in invalid
    and self.last_update < self.current_phase_times["start"]
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: can't compare offset-naive and offset-aware datetimes

Ajouté l'info de timezone dans event.py, fonctionne pour le moment mais c'est au switch de phase que ça se passe.