エアコンの消費電力をAmbientに送る
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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