lucien2k / sonoff-python

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

Fix README example to switch on #7

Closed helen-fornazier closed 4 years ago

helen-fornazier commented 5 years ago

Using s.switch('on', device_id, 0) didn't work out of the box, it trows the following error:

Traceback (most recent call last): File "/tmp/test.py", line 14, in 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'

Updating the command to s.switch('on', device_id, None) works like a charm