rene-d / netatmo

Python3 API for the Netatmo Weather Station
The Unlicense
36 stars 18 forks source link

Pb with list argument #20

Open cedricmeschin opened 2 years ago

cedricmeschin commented 2 years ago

Hi, I discover this script and I test it. When I run netatmo test, connection is ok netatmo.py xxx@xxx : OK

but when I run netatmo list it return me an error like this: 1 station 70:ee:50:xx.xx.xx MyHome (Indoor) MyCity FR Traceback (most recent call last): File "/usr/local/bin/netatmo", line 8, in <module> sys.exit(main()) File "/usr/local/lib/python3.9/dist-packages/netatmo/netatmo.py", line 929, in main args.func(args) File "/usr/local/lib/python3.9/dist-packages/netatmo/netatmo.py", line 792, in list_stations module["module_name"], KeyError: 'module_name'

Here is anonimysed return of "module" variable (I added print(module) in line 798) {'_id': '70:ee:50:xx:xx:xx', 'date_setup': 1658014428, 'last_setup': 1658014428, 'type': 'NAMain', 'last_status_store': 1661957324, 'firmware': 181, 'wifi_status': 60, 'reachable': True, 'co2_calibrating': False, 'data_type': ['Temperature', 'CO2', 'Humidity', 'Noise', 'Pressure'], 'place': { 'altitude': 20, 'city': 'MyCity', 'country': 'FR', 'timezone': 'Europe/Paris', 'location': [x.xxxxxxxxxx, x.xxxxxxxxx]}, 'station_name': 'MyHome (Indoor)', 'home_id': '61a69ec32ac81348e60ebc14', 'home_name': 'MyHome', 'dashboard_data': { 'time_utc': 1661957322, 'Temperature': 26.6, 'CO2': 513, 'Humidity': 64, 'Noise': 47, 'Pressure': 1015.4, 'AbsolutePressure': 1013, 'min_temp': 23.2, 'max_temp': 26.7, 'date_max_temp': 1661951570, 'date_min_temp': 1661931366, 'temp_trend': 'stable', 'pressure_trend': 'stable' }, 'modules': [{ '_id': '02:00:00:xx:xx:xx', 'type': 'NAModule1', 'module_name': 'Extérieur', 'data_type': ['Temperature', 'Humidity'], 'battery_percent': 97, 'reachable': True, 'last_setup': 1658014429, 'firmware': 50, 'last_message': 1661957317, 'last_seen': 1661957298, 'rf_status': 59, 'battery_vp': 5950, 'dashboard_data': { 'time_utc': 1661957298, 'Temperature': 26.3, 'Humidity': 63, 'min_temp': 19.7, 'max_temp': 28.7, 'date_max_temp': 1661951248, 'date_min_temp': 1661908047, 'temp_trend': 'stable' } }] }

Thanks for your help. Regards

rene-d commented 2 years ago

Replace module["module_name"],at line 794 by module.get("module_name", "unknown"),

Or use the Git version, it has the fix.