Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions netatmo_influx.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,36 @@

import lnetatmo
from influxdb import InfluxDBClient
from os.path import expanduser, exists
import json

authorization = lnetatmo.ClientAuth()
#
# custom influx config file
#
# {
# "INFLUX_HOST" : "",
# "INFLUX_PORT" : "",
# }
INFLUXCONFIG = "~/.netatmo.influxdb"

weatherData = lnetatmo.WeatherStationData(authorization)
if (INFLUXCONFIG):
influxconfigFile = expanduser(INFLUXCONFIG)
with open(influxconfigFile, "r") as f:
influxconfig = {k.upper():v for k,v in json.loads(f.read()).items()}

client = InfluxDBClient()
if {'name': 'netatmo'} not in client.get_list_database():
#print(influxconfig)
client = InfluxDBClient(host=influxconfig["INFLUX_HOST"], port=influxconfig["INFLUX_PORT"])
else:
#print("default")
client = InfluxDBClient()
if {'name': 'netatmo'} not in client.get_list_database():
client.create_database('netatmo')

authorization = lnetatmo.ClientAuth()

weatherData = lnetatmo.WeatherStationData(authorization)

#print(weatherData.stationByName())
for station in weatherData.stations:
station_data = []
module_data = []
Expand Down