.

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

WeMo Insight

API

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

  • だいたい上記のPython APIに書いてあることです
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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アダプタを差している)

ref: https://qiita.com/atsushi0521/items/28355e9d789a07c61f2f