philippelt / netatmo-api-python

Netatmo connect API python client (for Netatmo information, see https://dev.netatmo.com)
GNU General Public License v3.0
193 stars 121 forks source link

AttributeError: 'NoneType' object has no attribute 'items' #91

Closed AFI4711 closed 6 days ago

AFI4711 commented 1 week ago

Now I get the following error everytime when calling:

for station in weather.stations:
    for module, moduleData in weather.lastData(station=station, exclude=3600).items() :
...
...
Traceback (most recent call last):
  File "/home/andi/Computer/src/python/netatmo-neu/netatmo-api-python-master/./printAllLastDataJSON.py", line 37, in <module>
    for module, moduleData in weather.lastData(station=station, exclude=3600).items() :
AttributeError: 'NoneType' object has no attribute 'items'
AFI4711 commented 6 days ago

Another simple Test shows a similiar error: simpleTest.py:

import lnetatmo

authorization = lnetatmo.ClientAuth()

weather = lnetatmo.WeatherStationData(authorization)
user = weather.user
print("Station owner : ", user.mail)
print("Data units    : ", user.unit)

devList = lnetatmo.WeatherStationData(authorization)

print ("Current temperature (inside/outside): %s / %s °C" %
        ( devList.lastData()['Weather Station']['Temperature'],
          devList.lastData()['Outdoor Module']['Temperature'])
      )

the error:

./simpleTest.py 
Station owner :  andreas@finkel.de
Data units    :  metric
Traceback (most recent call last):
  File "/home/andi/docker/netatmo_neu/netatmo-api-python-master/./simpleTest.py", line 27, in <module>
    ( devList.lastData()['Weather Station']['Temperature'],
      ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not subscriptable
philippelt commented 6 days ago

This is the behavior you would have if you don't have any weather station in your account (or that you scope do not allow to find them).

Check that you have the required scope (see https://github.com/philippelt/netatmo-api-python/issues/56#issuecomment-1638546613)

AFI4711 commented 6 days ago

Strange, I'll use your software a long time running successfully. Perhaps there are some problems with Netatmo. I'll create new credentials and try again. Many thanks so far.

philippelt commented 6 days ago

In the last two weeks, I experienced between 2 and 8 requests failure per day to netatmo servers. It seems improving now.

AFI4711 commented 6 days ago

Generation of new TOKENS and/or CLIENT_IDs brought no improvement. Since I found no data of my "Weather Station" on Netatmo Homepage (https://home.netatmo.com/control/dashboard ) I restarted the Weather Station (since new. Now everything is running fine. This is so embarrassing, sorry for the Inconveniences.