Closed osteeg closed 4 years ago
Hello Oliver,
lastData do not refresh data automatically. It just return data collected when WeatherStationData instance was created.
In short:
device = lnetatmo.WeatherStationData(authorization)
while True:
print(devList.lastData()['external']['Temperature'])
sleep(15*60)
will always return the same data every 15 min and
while True:
device = lnetatmo.WeatherStationData(authorization)
print(devList.lastData()['external']['Temperature'])
sleep(15*60)
will display updated data.
The reason not to just 'update' is that the instance build many data structures that may change between calls (a module can run out of power and just disappear). Creating a new instance is the shortest path to keep simple things simple.
Remember that if you have a worker that keeps running for long, it's better to enclose WeatherStationData() instance creation in a try/except clause because it relies on ability from Netatmo to respond which is not guaranteed and to test if the module you require is always present... and a plan for remediation if it is not the case (send alarm sms/mail to someone for example).
Enjoy Philippe
Thanks a lot
I have the following issue.
When I start the program the devList.lastData() function get all the data as expected. When I redo this function afterwards in 15 Min cycles I got always the same data.
What is my mistake?
RG Oliver