Skip to content

Instantly share code, notes, and snippets.

@jdrews
Created May 1, 2016 20:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdrews/cce721f32df4d65904bd482816d4cd78 to your computer and use it in GitHub Desktop.
Save jdrews/cce721f32df4d65904bd482816d4cd78 to your computer and use it in GitHub Desktop.
Grab temp and humidity from ecobee API and store in influxdb. Poll trigger via cron
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment