lucien2k / sonoff-python

Make use of your sonoff smart switches without flashing them via the cloud APIs
MIT License
53 stars 32 forks source link

KeyError: 'switches' #6

Closed helen-fornazier closed 5 years ago

helen-fornazier commented 5 years ago

Hello,

I am having the following error when I call s.switch('on', device_id, 0):

Traceback (most recent call last):
  File "/tmp/test.py", line 14, in <module>
    s.switch('on', device_id, 0)
  File "/usr/local/lib/python2.7/dist-packages/sonoff/sonoff.py", line 246, in switch
    params = { 'switches' : device['params']['switches'] }
KeyError: 'switches'

Looking at the device object, I see:

 u'params': {u'fwVersion': u'1.6.0',
             u'rssi': -51,
             u'staMac': u'68:C6:3A:A3:8B:B4',
             u'startup': u'off',
             u'switch': u'off'},

There is no 'switches' key in 'params'

helen-fornazier commented 5 years ago

It works if I use s.switch('on', device_id, None) instead

nKiNk commented 5 years ago

It seems that we get that error if the switch is not an outlet type.