Skip to content

Instantly share code, notes, and snippets.

@bohemian916
Last active September 6, 2018 09:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bohemian916/63bf346614a634c98113027f299f0abb to your computer and use it in GitHub Desktop.
Save bohemian916/63bf346614a634c98113027f299f0abb to your computer and use it in GitHub Desktop.
エアコンの消費電力を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