Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ecobee
- from influxdb import InfluxDBClient
- def logPoint(sensorName=None, sensorValue=None, sensorType=None):
- return {
- "measurement": sensorType,
- "tags": {
- "sensor": sensorName
- },
- "fields": {
- "value": sensorValue
- }
- }
- client = InfluxDBClient(host='YOUR_IP',
- port=8086,
- database='YOURDB',
- username='username',
- password='password',
- verify_ssl=False)
- APIKEY = "ecobee-api-key"
- points = []
- eapi = ecobee.Client(APIKEY,scope='smartRead')
- thermostats = eapi.list_thermostats()
- for thermostat in thermostats:
- name = str(thermostat.name)
- temp = str(thermostat.current_temperature)
- humidity = str(thermostat.current_humidity)
- print("thermostat_name = " + name + ", temp = " + temp + ", humidity = " + humidity)
- points.append(logPoint(sensorName=name, sensorValue=float(temp), sensorType="temp"))
- points.append(logPoint(sensorName=name, sensorValue=float(humidity), sensorType="humidity"))
- # there is only one remote sensor per thermostat. Otherwise loop over thermostat.list_sensors()
- sensor = thermostat.get_sensor("rs:100")
- name = str(sensor.name)
- temp = str(sensor.temperature)
- print("sensor_name = " + name + ", temp = " + temp)
- points.append(logPoint(sensorName=sensor.name, sensorValue=float(temp), sensorType="temp"))
- print("points = " + str(points))
- client.write_points(points)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement