Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from ouimeaux.environment import Environment
import ambient
ambi = ambient.Ambient(xxxx, "xxxxxxxxxxxx")
def on_switch(switch):
print "Switch found!",
def on_motion(motion):
print "Motion found!",
env = Environment(on_switch, on_motion)
# get device
insight = env.get_switch('WeMo Insight')
# get power
current_power = int(insight.current_power) / 1000.0
print current_power
today_kwh = float(insight.today_kwh)
print today_kwh
# make data
tmp = {}
tmp["d1"] = current_power
tmp["d2"] = today_kwh
r = ambi.send(tmp)
print 'Status code: %d' % r.status_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment