LoginSignup
3
1

More than 5 years have passed since last update.

WeMo Insightで現在の消費電力を取得する

Last updated at Posted at 2018-01-13

WeMo Insight

API

WeMo Insightの現在の消費電力を知る手順

  • だいたい上記のPython APIに書いてあることです
pi@raspberrypi:~ $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09) 
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from ouimeaux.environment import Environment
>>> 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()
>>> env.discover(seconds=3)
Switch found! WeMo
>>> env.list_switches()
['WeMo']
>>> switch = env.get_switch('WeMo')
>>> switch
<WeMo Insight "WeMo">
>>> print switch.get_state()
0
>>> switch.on()
>>> print switch.get_state()
1
>>> print switch.insight_params
{'onfor': 51, 'state': '8', 'ontotal': 16144, 'totalmw': 40961936, 'ontoday': 16499, 'todaymw': 40961936, 'lastchange': datetime.datetime(2018, 1, 13, 13, 4, 24), 'currentpower': 0}
>>> print switch.insight_params['currentpower']
0 (WeMoに何も差してない状態)
>>> print switch.insight_params['currentpower']
15915 (WeMoにノートPCのACアダプタを差している)
3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1