Skip to content

Instantly share code, notes, and snippets.

@ramcq
Created November 8, 2015 16:38
Show Gist options
  • Save ramcq/738fbfbe795f6135311a to your computer and use it in GitHub Desktop.
Save ramcq/738fbfbe795f6135311a to your computer and use it in GitHub Desktop.
collectd python plugin for evohome
# collectd python plugin for evohome
# Copyright 2015 Robert McQueen <[email protected]>
# GNU General Public License v2 or later, no warranty etc
#
# uses https://github.com/watchforstock/evohome-client to read temperatures and setpoints
# could be more smart in terms of keeping credentials and refreshing them when they time out rather than logging in every time
# supports multiple evohome devices
# ignores hot water
# patches welcome :)
import collectd
import evohomeclient2
USERNAME = 'xxx'
PASSWORD = 'yyy'
def scrub(s):
return ''.join([ c.lower() if c.isalnum() else "_" for c in s ])
def dispatch_location(name, cs):
vals = collectd.Values()
vals.plugin = 'evohome'
vals.plugin_instance = scrub(name)
vals.type = 'temperature'
for zone in cs.temperatures():
if zone['thermostat'] != 'EMEA_ZONE':
continue
name = 'zone_' + scrub(zone['name'])
vals.type_instance = name + '_setpoint'
vals.values = [float(zone['setpoint'])]
vals.dispatch()
if zone['temp'] is None:
continue
vals.type_instance = name + '_temp'
vals.values = [float(zone['temp'])]
vals.dispatch()
def plugin_read(input_data=None):
global USERNAME, PASSWORD
client = evohomeclient2.EvohomeClient(USERNAME, PASSWORD)
for loc in client.locations:
dispatch_location(loc.name, loc._gateways[0]._control_systems[0])
collectd.register_read(plugin_read)
@ramcq
Copy link
Author

ramcq commented Nov 8, 2015

collectd config needs something like

<Plugin python>
ModulePath "/etc/collectd/python"
LogTraces true
Import "evohome"
</Plugin>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment