J-Lindvig / Pollen_DK

Scraping of pollen count in Denmark
GNU General Public License v3.0
7 stars 4 forks source link

Sensors not updating #2

Open JakobEgPedersen opened 8 months ago

JakobEgPedersen commented 8 months ago

The integration works fine, but only updates when HA is restarted. I have tried to make a service call in an automation to reload the integration, like I also do for other integrations, but cannot find this integration in automation. Is it supposed to automatically pull new data every day, or only when a service call is made? I can see others on Facebook DK HA group are having same issue. pollen

jesperll commented 7 months ago

Each sensor is created with the instance of a region that exists at launch. https://github.com/J-Lindvig/Pollen_DK/blob/97d12984156198b3631fa789b2f017201923d921/custom_components/pollen_dk/sensor.py#L49-L54

pollen_DK.update replaces all the region instance with new ones but the sensors keep looking at the original https://github.com/J-Lindvig/Pollen_DK/blob/97d12984156198b3631fa789b2f017201923d921/custom_components/pollen_dk/pollen_dk_api.py#L33-L37

thomasgunnar commented 6 months ago

I have the same problem - any fixes ?

daath commented 6 months ago

Same - Any fix for this?

JakobEgPedersen commented 6 months ago

Each sensor is created with the instance of a region that exists at launch.

https://github.com/J-Lindvig/Pollen_DK/blob/97d12984156198b3631fa789b2f017201923d921/custom_components/pollen_dk/sensor.py#L49-L54

pollen_DK.update replaces all the region instance with new ones but the sensors keep looking at the original

https://github.com/J-Lindvig/Pollen_DK/blob/97d12984156198b3631fa789b2f017201923d921/custom_components/pollen_dk/pollen_dk_api.py#L33-L37

Jesper LL what are you trying to say? Should it work, or are there something that I can change in the code myself to make it work? Fact is that it only updates at HA restart. I have tried various attempts to make it refrest, but only works at restart.

jesperll commented 6 months ago

I'm saying the code is written incorrectly and will never update correctly as-is My python skills are unfortunately quite "read only" and so all I could do was point at the problem - not the solution ¯\(ツ)