philippelt / netatmo-api-python

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

Using samples/weather2file to download old data returns Device not found #55

Closed aolik08 closed 11 months ago

aolik08 commented 12 months ago

trying to use weather2file to try to download old data seems it is not working. even if the {module_name} is properly identified it seems it returns ERROR: code=404, reason=Not Found, body=b'{"error":{"code":9,"message":"Device not found"}}'

PYTHONPATH=. ./samples/weather2file --format csv
 INFO: Previous file ./weatherdata.csv not found. Setting empty DataFrame
 INFO: Timezone Europe/Bucharest extracted from data.
 INFO: Processing MasterBedroom...
 INFO: Collecting data for MasterBedroom...
 ERROR: code=404, reason=Not Found, body=b'{"error":{"code":9,"message":"Device not found"}}'
 WARNING: None received. Aborting data collection from module MasterBedroom
 INFO: Collected data from MasterBedroom contains 0 samples.
Traceback (most recent call last):
  File "./samples/weather2file", line 642, in <module>
    main()
  File "./samples/weather2file", line 613, in main
    df_handler.append(
  File "./samples/weather2file", line 150, in append
    self.df = self.df.append(df).reset_index(drop=True)
  File "/usr/local/lib/python3.8/dist-packages/pandas/core/generic.py", line 5989, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'append'

it seems that the issue is from here, but i am not an expert on python

            # Get new data from Netatmo
            d = self._get_field_dict(station_mac,
                               module_data_overview['_id'],
                               module_data_overview['data_type'],
                               module_start_date_timestamp,
                               end_date_timestamp)

            retreived_module_data = self._get_measurement(d) 

is there something that i do wrong?

philippelt commented 11 months ago

Assuming they are valid, what you should double check, ensure that the station_mac you are supplying as well as the module_id are all in lowercase

aolik08 commented 11 months ago

The weather2file was not changed in 3 years and, from what I remember, some big changes were performed on Netatmo API side. From what I can understand it seems that on line 471 d = self._get_field_dict(station_mac, "station_mac" is having the value devices.station_name from Netatmo API, instead of devices._id

in my case, i don't know why this field is composed from the following fields: "home_name" + " " + "(" + device.module_name + ")" it has a space char between home_name and device.module_name image

If i just hard-code the station_mac of my weather station, just before, i get some values, but the weather2filescript is havin issues interpreting it: image

"something fishy is going on..."

philippelt commented 11 months ago

Unfortunately, this sample code was developped by @joebe975 and being just a sample code I did not invest time on it to update it with netatmo evolution.

May be I will have to remove it if @joebe975 can no longer maintain it...

aolik08 commented 11 months ago

ah, ok... thank you for that

joebe975 commented 11 months ago

I will try to look into it sometime the coming weeks.