Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
エアコンの消費電力をAmbientに送る
from ouimeaux.environment import Environment
import ambient
ambi = ambient.Ambient(xxxx, "xxxxxxxxxxxx")
def on_switch(switch):
print "Switch found!", switch.name
def on_motion(motion):
print "Motion found!", motion.name
env = Environment(on_switch, on_motion)
env.start()
# get device
env.discover(seconds=5)
insight = env.get_switch('WeMo Insight')
print(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