Closed zanac closed 4 years ago
vanni@domon:~/src/sonoff/1/sonoff-python$ python3 ./prova.py [{'createdAt': '2018-12-10T08:43:46.266Z', 'onlineTime': '2019-11-02T22:36:14.911Z', 'location': '', '__v': 0, 'apikey': '7f6ad353-5b15-424a-91a7-00e6b8ca9992 ', 'sharedTo': [], 'type': '10', 'showBrand': True, 'group': '', 'ip': '46.234.201.3', 'productModel': 'Sonoff Pow', 'devConfig': {}, 'devicekey': '85468a4c-e e1f-460e-aa10-a486fd0f473c', 'deviceUrl': '', 'deviceid': '10001bd399', 'params': {'uiActive': 60, 'fwVersion': '2.6.1', 'startup': 'stay', 'switch': 'off', ' rssi': -51, 'staMac': '60:01:94:5E:09:35', 'timers': [], 'init': 1, 'power': '0', 'timeZone': 1, 'controlType': '7', 'sledOnline': 'on'}, 'deviceStatus': '', 'brandName': 'Maker', 'settings': {'opsNotify': 0, 'opsHistory': 1, 'alarmNotify': 1}, 'extra': {'_id': '59e4513b5c1af3a660cd57b2', 'extra': {'apmac': 'd0:27: 00:37:a4:83', 'mac': 'd0:27:00:37:a4:82', 'manufacturer': '深圳创易智能系统有限公司', 'staMac': '60:01:94:5E:09:35', 'description': 'WWJG001093', 'model': 'PSC-B01-GL', ' brandId': '5611402280a0e2630f7b102d', 'ui': '功率检测单通道插座', 'uiid': 5, 'modelInfo': '578df9d0cc81455a5831eaea'}}, 'devGroups': [], 'groups': [], 'brandLogoUrl': '', 'offlineTime': '2019-11-02T22:34:28.302Z', 'name': 'Presa 02', '_id': '5c0e2742ccb92c9f850a98ef', 'uiid': 5, 'online': True}] Traceback (most recent call last): File "./prova.py", line 10, in s.switch('on', device_id, 0) File "/home/vanni/src/sonoff/1/sonoff-python/sonoff/sonoff.py", line 268, in switch params = { 'switches' : device['params']['switches'] } KeyError: 'switches'
Hi, try to call s.switch('on', device_id, None)
s.switch('on', device_id, None)
it work!
vanni@domon:~/src/sonoff/1/sonoff-python$ python3 ./prova.py
[{'createdAt': '2018-12-10T08:43:46.266Z', 'onlineTime': '2019-11-02T22:36:14.911Z', 'location': '', '__v': 0, 'apikey': '7f6ad353-5b15-424a-91a7-00e6b8ca9992 ', 'sharedTo': [], 'type': '10', 'showBrand': True, 'group': '', 'ip': '46.234.201.3', 'productModel': 'Sonoff Pow', 'devConfig': {}, 'devicekey': '85468a4c-e e1f-460e-aa10-a486fd0f473c', 'deviceUrl': '', 'deviceid': '10001bd399', 'params': {'uiActive': 60, 'fwVersion': '2.6.1', 'startup': 'stay', 'switch': 'off', ' rssi': -51, 'staMac': '60:01:94:5E:09:35', 'timers': [], 'init': 1, 'power': '0', 'timeZone': 1, 'controlType': '7', 'sledOnline': 'on'}, 'deviceStatus': '', 'brandName': 'Maker', 'settings': {'opsNotify': 0, 'opsHistory': 1, 'alarmNotify': 1}, 'extra': {'_id': '59e4513b5c1af3a660cd57b2', 'extra': {'apmac': 'd0:27: 00:37:a4:83', 'mac': 'd0:27:00:37:a4:82', 'manufacturer': '深圳创易智能系统有限公司', 'staMac': '60:01:94:5E:09:35', 'description': 'WWJG001093', 'model': 'PSC-B01-GL', ' brandId': '5611402280a0e2630f7b102d', 'ui': '功率检测单通道插座', 'uiid': 5, 'modelInfo': '578df9d0cc81455a5831eaea'}}, 'devGroups': [], 'groups': [], 'brandLogoUrl': '', 'offlineTime': '2019-11-02T22:34:28.302Z', 'name': 'Presa 02', '_id': '5c0e2742ccb92c9f850a98ef', 'uiid': 5, 'online': True}]
Traceback (most recent call last):
File "./prova.py", line 10, in
s.switch('on', device_id, 0)
File "/home/vanni/src/sonoff/1/sonoff-python/sonoff/sonoff.py", line 268, in switch
params = { 'switches' : device['params']['switches'] }
KeyError: 'switches'