I am using a python script to write rain data into an influxdb
for station in weatherData.stations:
allModules = {}
module_data = []
station = weatherData.stationById(station)
station_name = station['station_name']
station_id = station['_id']
module_name = station['module_name']
altitude = station['place']['altitude']
country= station['place']['country']
timezone = station['place']['timezone']
longitude = station['place']['location'][0]
latitude = station['place']['location'][1]
# the station is a module
allModules[station_id] = module_name
# get all other modules via getModulesNameList
modules = weatherData.modulesNamesList()
for moduleName in modules:
module = weatherData.moduleByName(moduleName)
if module is None:
continue
deviceId = module['_id']
allModules[deviceId] = moduleName
for mid, mname in allModules.items():
for measurement in ['rain', 'sum_rain']:
data = weatherData.getMeasure(device_id = station_id, module_id = mid, mtype=measurement, scale='30min', date_begin=yesterday, date_end=now, real_time = True)
#print(data)
if type(data['body']) is list:
# no values for measurement
continue
for ts, values in data['body'].items():
value = values[0]
if type(value) == int:
value = float(value)
value = Decimal(value)
value = round(value, 1)
module_data.append({
"measurement": measurement,
"tags": {
"station": station_name,
"module": mname,
"source": 'getMeasure'
},
"time": int(ts),
"fields": {
"value": value
}
})
# write to influx
client.write_points(module_data, time_precision='s', database='netatmo')
but this fails after updating to version 4:
% /usr/local/bin/python3.9 /home/stuff/netatmo_influxdb/netatmo_influx_rain.py
Traceback (most recent call last):
File "/home/stuff/netatmo_influxdb/netatmo_influx_rain.py", line 40, in <module>
modules = weatherData.modulesNamesList()
File "/usr/home/stuff/netatmo_influxdb/lnetatmo.py", line 458, in modulesNamesList
res.append(self.stationByName(station)['module_name'])
File "/usr/home/stuff/netatmo_influxdb/lnetatmo.py", line 473, in stationByName
return self.getStation(station)
File "/usr/home/stuff/netatmo_influxdb/lnetatmo.py", line 467, in getStation
if station in self.stations : return self.stations[station]
TypeError: unhashable type: 'dict'
I am using a python script to write rain data into an influxdb
but this fails after updating to version 4: