Git Product home page Git Product logo

pysonofflan's People

Contributors

barbieri avatar beveradb avatar mattsaxon avatar pyup-bot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

pysonofflan's Issues

error: Missing api_key for encrypted device (G26 firmware 3.4.0)

  • pySonoffLANr3 version: 1.1.4
  • Python version: 3.7
  • Operating System: Raspbian Buster
  • G26 sonoff plug with 3.4.0 stock firmware

Description

Hi, on calling the following:

sudo pysonofflanr3 --host 192.168.1.xx state

I get the result:

2020-04-14 17:08:03,025 - info: Initialising SonoffSwitch with host 192.168.1.100
2020-04-14 17:08:10,190 - info: Service type _ewelink._tcp.local. of name eWeLink_10006c5487._ewelink._tcp.local. added
2020-04-14 17:08:10,194 - error: Missing api_key for encrypted device: eWeLink_10006c5487._ewelink._tcp.local.
2020-04-14 17:08:10,197 - info: same update received for device: eWeLink_10006c5487._ewelink._tcp.local.

Same result for on/off commands

Discover works correctly

My G26 is blocked from internet and can use eWeLink in LAN mode to control.

Unexpected error in setup_connection(): could not convert string to float: '8.0.2'

  • pySonoffLAN version: pysonofflan-0.3.0
  • Python version: Python 3.7.2
  • Operating System: Windows 10

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

image

Hangs on command line

  • pySonoffLAN version: last stable (25.5.2020)
  • Python version: 3.8.3
  • Operating System: Win10

Description

Calling pysonofflanr3 can't discover devices (two S20 firmware 3.4.0), calling a switch direclt via IP or device-id with api-key hangs forever:

What I Did

$ pysonofflanr3 --host xxx --api_key xxxx -l DEBUG on

log:
2020-05-24 11:47:27,505 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2020-05-24 11:47:27,505 - debug: enter send_availability_loop()
2020-05-24 11:47:27,505 - debug: waiting for connection
2020-05-24 11:47:27,505 - debug: send_updated_params_loop is active on the event loop
2020-05-24 11:47:27,505 - debug: Starting loop waiting for device params to change
2020-05-24 11:47:27,505 - debug: send_updated_params_loop now awaiting event

Dual R3 in engine mode

  • pySonoffLAN version:
  • Python version:
  • Operating System:

Description

Please add the possibility to control Dual R3 in engine mode.

3 parameters: "currLocation":0,"motorTurn":2}.
motorTurn 0 is for STOP command, 1 is for OPEN, 2 is for CLOSE. location 0-100

What I Did

logs:

 pysonofflanr3 --device_id 1001556e33 -l DEBUG --api_key  _hidden_ listen
2022-08-11 15:02:20,009 - info: Initialising SonoffSwitch with host None
2022-08-11 15:02:20,010 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2022-08-11 15:02:20,012 - debug: enter send_availability_loop()
2022-08-11 15:02:20,012 - debug: waiting for connection
2022-08-11 15:02:20,013 - debug: send_updated_params_loop is active on the event loop
2022-08-11 15:02:20,014 - debug: Starting loop waiting for device params to change
2022-08-11 15:02:20,014 - debug: send_updated_params_loop now awaiting event
2022-08-11 15:02:20,214 - info: Service type _ewelink._tcp.local. of name eWeLink_1001556e33._ewelink._tcp.local. added
2022-08-11 15:02:20,215 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:02:20,216 - debug: properties: {b'data1': b'vTgW4DX3CHbF59qv/UR07eu33XPC4GRJVaILp/jzGhY=', b'seq': b'16', b'iv': b'Mzc4MTg4MDkyNzUwNjgzNw==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:02:20,216 - debug: type: b'multifun_switch'
2022-08-11 15:02:20,217 - debug: decrypted data: b'{"currLocation":0,"location":0}'
2022-08-11 15:02:20,218 - debug: enter handle_message() b'{"currLocation":0,"location":0}'
2022-08-11 15:02:20,218 - error: Unknown message received from device:
2022-08-11 15:02:20,219 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:02:20,219 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:02:20,219 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:02:20,219 - error: Exception: Unknown message received from device
2022-08-11 15:03:06,603 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:06,603 - debug: properties: {b'data1': b'I1JU/NXANco+HHL6kk4dkQnQiZcTl1mtoZOvHNyy/MPAOdtSemGS7/qX5DB1Qvu7', b'seq': b'20', b'iv': b'NjE4MDU5NDcxNjI1NTIxMw==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:06,604 - debug: type: b'multifun_switch'
2022-08-11 15:03:06,605 - debug: decrypted data: b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:06,606 - debug: enter handle_message() b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:06,607 - error: Unknown message received from device:
2022-08-11 15:03:06,608 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:06,608 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:06,608 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:06,608 - error: Exception: Unknown message received from device
2022-08-11 15:03:11,109 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:11,109 - debug: properties: {b'data1': b'cqvHsbybnzGed6KmXsj0A+XRq467u0vG5lpm0vZkxFqX9dSHBsAHV9FNRbvEb5ky', b'seq': b'21', b'iv': b'Mzg0OTUyODAwNTQ3NjM1NA==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:11,110 - debug: type: b'multifun_switch'
2022-08-11 15:03:11,111 - debug: decrypted data: b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:11,112 - debug: enter handle_message() b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:11,113 - error: Unknown message received from device:
2022-08-11 15:03:11,113 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:11,113 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:11,113 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:11,113 - error: Exception: Unknown message received from device
2022-08-11 15:03:14,489 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:14,489 - debug: properties: {b'data1': b'kPqLTz7LhwH0Fr17o+wQWtP2RIhQOM8gCLR8+THDWfThg4FRIS9Meo1fkk0xXc2P', b'seq': b'22', b'iv': b'MjYyNDAyMTYyMTk1ODkxNA==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:14,490 - debug: type: b'multifun_switch'
2022-08-11 15:03:14,491 - debug: decrypted data: b'{"currLocation":0,"motorTurn":2}'
2022-08-11 15:03:14,493 - debug: enter handle_message() b'{"currLocation":0,"motorTurn":2}'
2022-08-11 15:03:14,493 - error: Unknown message received from device:
2022-08-11 15:03:14,494 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:14,494 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:14,494 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:14,494 - error: Exception: Unknown message received from device
2022-08-11 15:03:17,663 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:17,664 - debug: properties: {b'data1': b'V/OdqY02oNdkHW1j1pg4x4nGkIpPGM/ZoqOAPjR+16jnUgiAEO3iT2ZzLriiRuU+', b'seq': b'23', b'iv': b'NDIxNDk0NDM3ODYwODExOA==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:17,665 - debug: type: b'multifun_switch'
2022-08-11 15:03:17,666 - debug: decrypted data: b'{"currLocation":0,"motorTurn":1}'
2022-08-11 15:03:17,667 - debug: enter handle_message() b'{"currLocation":0,"motorTurn":1}'
2022-08-11 15:03:17,667 - error: Unknown message received from device:
2022-08-11 15:03:17,668 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:17,668 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:17,668 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:17,668 - error: Exception: Unknown message received from device
2022-08-11 15:03:19,916 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:19,916 - debug: properties: {b'data1': b'gB3VnB06FpZMAKQxvASzfJXjCkMxxUcTPvkafdkS/RAC80QfbhGyRUxTI60COhJV', b'seq': b'25', b'iv': b'NjQwNzU1MTE4MjY0NzE2NQ==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:19,917 - debug: type: b'multifun_switch'
2022-08-11 15:03:19,919 - debug: decrypted data: b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:19,921 - debug: enter handle_message() b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:19,922 - error: Unknown message received from device:
2022-08-11 15:03:19,923 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:19,923 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:19,923 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:19,923 - error: Exception: Unknown message received from device
2022-08-11 15:03:25,754 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:25,754 - debug: properties: {b'data1': b'B3vXNbXGNbI6nVyQCbvJUr9fzUtR2M/TLYWjZ32Ih09sHJ9WDy/uolYJcGI8dImB', b'seq': b'26', b'iv': b'NjAwNzgwODQ4MjAxMTMyOQ==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:25,755 - debug: type: b'multifun_switch'
2022-08-11 15:03:25,756 - debug: decrypted data: b'{"currLocation":0,"motorTurn":1}'
2022-08-11 15:03:25,758 - debug: enter handle_message() b'{"currLocation":0,"motorTurn":1}'
2022-08-11 15:03:25,758 - error: Unknown message received from device:
2022-08-11 15:03:25,759 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:25,759 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:25,759 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:25,759 - error: Exception: Unknown message received from device
2022-08-11 15:03:40,907 - debug: service is at http://192.168.0.59:8081
2022-08-11 15:03:40,908 - debug: properties: {b'data1': b'9bo1tiTXR567mAyTD1eyAmVYETYQ943Qesy7LdyE4GvBgm7xLSsP8d19Z4vYAcq0', b'seq': b'27', b'iv': b'MzU3MTM4NjY1NjAxNzk3MQ==', b'encrypt': b'true', b'apivers': b'1', b'type': b'multifun_switch', b'id': b'1001556e33', b'txtvers': b'1'}
2022-08-11 15:03:40,909 - debug: type: b'multifun_switch'
2022-08-11 15:03:40,910 - debug: decrypted data: b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:40,911 - debug: enter handle_message() b'{"currLocation":0,"location":0,"motorTurn":0}'
2022-08-11 15:03:40,912 - error: Unknown message received from device:
2022-08-11 15:03:40,913 - error: Unexpected error in handle_message() for device 1001556e33: Unknown message received from device Traceback (most recent call last):
2022-08-11 15:03:40,913 - error:   File "/home/pi/.local/lib/python3.7/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2022-08-11 15:03:40,913 - error:     raise Exception("Unknown message received from device")
2022-08-11 15:03:40,913 - error: Exception: Unknown message received from device

Reading from the POW R2

Hi, I searched for this but couldn't find anything related with the official API. Sorry if I missed something.

Please let me know if there has been any work in reading power (P, I & V) from the POW R2, or if you have any tips or clues to tackle the problem.

Thank you!

Device discovery not working, some commands hang e.g. switch on device

  • pySonoffLAN version: pysonofflanr3 v 1.1.4
  • Python version: 3.9.6
  • Operating System: Mac OSX 10.12.6

Device discovery not working

Trying to confirm device discovery
No devices found
Also warning message about future implementations reliant upon Zeroconf
No DEBUG messages indicating attempts to connect to all addresses on network (compare with pysonofflan)

_pysonofflanr3 discover
2021-07-23 22:31:48,710 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
/usr/local/lib/python3.9/site-packages/zeroconf/services/browser.py:170: FutureWarning: <pysonofflanr3.discover.MyListener object at 0x106f25e50> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
warnings.warn(

pysonofflanr3 -l DEBUG discover
2021-07-23 22:39:28,690 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
2021-07-23 22:39:28,691 - debug: Looking for all eWeLink devices on local network.
/usr/local/lib/python3.9/site-packages/zeroconf/_services/browser.py:170: FutureWarning: <pysonofflanr3.discover.MyListener object at 0x110f82580> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
warnings.warn(

pysonofflanr3 --host 192.168.0.10 --api_key "blah blah blah" listen
2021-07-23 22:51:14,898 - info: Initialising SonoffSwitch with host 192.168.0.10
2021-07-23 22:51:16,260 - info: Service type _ewelink._tcp.local. of name eWeLink_1000b88b5e._ewelink._tcp.local. added
2021-07-23 22:51:16,263 - info: None: Connected event, sending 'available' update
2021-07-23 22:51:16,263 - info: unsolicited update received from switch: on
2021-07-23 22:51:16,263 - info: == Device: 1000b88b5e (192.168.0.10) ==
2021-07-23 22:51:16,264 - info: State: ON
2021-07-23 22:51:16,264 - info: None: Connected event, waiting for disconnect
2021-07-23 22:52:03,365 - info: None: Connected event, sending 'available' update
2021-07-23 22:52:03,365 - info: unsolicited update received from switch: off
2021-07-23 22:52:03,365 - info: == Device: 1000b88b5e (192.168.0.10) ==
2021-07-23 22:52:03,365 - info: State: OFF
2021-07-23 22:52:17,701 - info: None: Connected event, sending 'available' update
2021-07-23 22:52:17,701 - info: unsolicited update received from switch: on
2021-07-23 22:52:17,702 - info: == Device: 1000b88b5e (192.168.0.10) ==
2021-07-23 22:52:17,702 - info: State: ON

Some commands hang e.g. switch on/off device

Set state for a given device
Works but command hangs from time to time

pysonofflanr3 --host 192.168.0.10 --api_key "blah blah blah" off
2021-07-23 22:56:06,331 - info: Initialising SonoffSwitch with host 192.168.0.10
2021-07-23 22:56:06,678 - info: Service type _ewelink._tcp.local. of name eWeLink_1000b88b5e._ewelink._tcp.local. added
2021-07-23 22:56:06,680 - info: None: Connected event, sending 'available' update
2021-07-23 22:56:06,680 - info: unsolicited update received from switch: on
2021-07-23 22:56:06,680 - info: == Device: 1000b88b5e (192.168.0.10) ==
2021-07-23 22:56:06,680 - info: State: ON
2021-07-23 22:56:06,681 - info: None: Connected event, waiting for disconnect
2021-07-23 22:56:08,931 - info: None: Connected event, sending 'available' update
2021-07-23 22:56:08,932 - info: == Device: 1000b88b5e (192.168.0.10) ==
2021-07-23 22:56:08,932 - info: State: OFF

Investigate issues with latest versions of ZeroConf (post 0.24.1)

The later versions of zeroconf have some issues that need investigating;

  1. Update Listener is called more times than expected, and perhaps for the wrong classes. There is a fix in client.py to filter these incorrect calls out, but it may show deeper issues
  2. The Update method (when called as part of the mock) doesn't seem to trigger updates after it's been called the first time. This doesn't seem to be an issue when using the CLI, as a new ZeroConf instance is created.

See related comments here python-zeroconf/python-zeroconf#212

error running script

  • pySonoffLAN version: 1.1.4
  • Python version: 3.7, 3.8
  • Operating System: fedora22, armbian buster, centos 8

Description

installed software with
pip3 install pysonofflanr3
when I run it without options it runs but when I run it with any command I get
root@orangepipc:/usr/src/pysonofflan# pysonofflanr3 discover
2020-06-22 19:39:08,421 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
Exception in thread zeroconf-ServiceBrowser__ewelink._tcp.local._3007312992:
Traceback (most recent call last):
File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/dist-packages/zeroconf/init.py", line 1679, in run
state_change=service_type_state_change[1],
File "/usr/local/lib/python3.7/dist-packages/zeroconf/init.py", line 1433, in fire
h(**kwargs)
File "/usr/local/lib/python3.7/dist-packages/zeroconf/init.py", line 1531, in on_change
listener.add_service(*args)
File "/usr/local/lib/python3.7/dist-packages/pysonofflanr3-1.1.4-py3.7.egg/pysonofflanr3/discover.py", line 40, in add_service
ip = utils.parseAddress(info.address) + ":" + str(info.port)
AttributeError: 'ServiceInfo' object has no attribute 'address'

What I Did

Tried to clone git, install it with
python3 setup.py install
but I get the same results

Thanks!
vrm

CLI doesn't function for ON/OFF as of v1.1.3

pysonofflanr3, version 1.1.3
Python 3.7.3
Linux raspbx 4.19.97-v7l+

if I dont pass --inching nothing works.
When I pass --inching 0.5, got an int error.
change to float solved
but still getting the erro below.
error: Unexpected error in shutdown_event_loop(): An asyncio.Future, a coroutine or an awaitable is required
and stay in a Loop forever!

2020-02-19 14:54:20,504 - info: Inching device activated by switching ON for 0.5s
2020-02-19 14:54:20,504 - debug: shutdown_event_loop called
2020-02-19 14:54:20,505 - error: Unexpected error in shutdown_event_loop(): An asyncio.Future, a coroutine or an awaitable is required
^C
Aborted!

V3-Firmware

  • pySonoffLAN version: 0.3.0
  • Python version: 3.6.8
  • Operating System: Linux Mint 19.1

Description

The device don't change the state with comandline: pysonofflan --host $HOST --api_key $API_KEY --device_id $DEVICE_ID on/off

What I Did

I installed the lib from https://github.com/mattsaxon/pysonofflan.git@V3-Firmware. The code returned some bugs like float conversion of version string in client.py and missing parameters in the "def switch_device()" in line 171 of cli.py. After fixed that bugs, the code work very well with de commands "state" and "listen", but nothing happens when I tried change the device state with the commands "on/off". The follow image shows the messages returned.

image

Can't run command

  • pySonoffLAN version: 3.3
  • Python version: 2.7
  • Operating System: Ubuntu

Description

Can't run any command with no error

What I Did

Here is what I got after run a command like pysonofflanr3. Please help me out to come over this issue. Thanks

Traceback (most recent call last):
File "/home/saytinh/.local/bin/pysonofflanr3", line 7, in
from pysonofflanr3.cli import cli
File "/home/saytinh/.local/lib/python2.7/site-packages/pysonofflanr3/init.py", line 57, in
from .client import SonoffLANModeClient
File "/home/saytinh/.local/lib/python2.7/site-packages/pysonofflanr3/client.py", line 41
host: str,
^
SyntaxError: invalid syntax

422 When Sending State Change

  • pySonoffLAN version: v1.1.2,v1.1.3,v1.1.4
  • Python version: 3.9, 3.7
  • Operating System: Mac OS X, raspbian

Description

I know this is unsupported now but I am getting 422 when trying to set state

What I Did

pysonofflanr3 --host someip --device_id id --api_key wouldnt_u_like_to_know -l DEBUG state
returns state
pysonofflanr3 --host someip --device_id id --api_key wouldnt_u_like_to_know -l DEBUG on
2020-12-11 00:10:55,765 - warning: error received: id, b'{"seq":37,"sequence":"1607667055588","error":422}'

looking at http://developers.sonoff.tech/sonoff-diy-mode-api-protocol.html I see that - 422: The operation failed and the request parameters are invalid. For example, the device does not support setting specific device information. this is a TH16 with firmware 3.4.1

I even modified the code to make sure the data was being sent correctly by passing the data from format_encryption_msg to decrypt and getting the unencrypted byte data that was passed into encrypt. Does this just mean that the TH16 on 3.4.1 isn't supported? Should I try to set up home assistant and sniff my traffic to see if it is the device or this api? That seems like a ton of work

Retry timeout not honor DEFAULT_TIMEOUT

  • pySonoffLAN version: 1.1.4
  • Python version: 3.7.7
  • Operating System: Hassio 0.109.6

Description

I have in Home Assistant a controlled light with the 'sonoff_lan_mode_r3' custom extension (not DIY).
The sonoff device is also controlled with a physical swith (connected to the sonoff device).
Also, I have an automation that switch on the light when a sensor is triggered.

What I Did

Sometimes, I have this weird behavior:

  • when the sensor is triggered the light switch on through the HA (as expected)
  • I switch off the light with the physical switch
  • the light switch on again

Sometimes it does a couple of times and other times it is continuous, until I turn off the light through the HA.

When this happens, the logs show this messages:

2020-05-16 11:49:01 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:49:06 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:49:16 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:50:31 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:50:36 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:50:47 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 11:51:17 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry

It seems that although I turn off the light, each retry to send the initial message (turn on through the automation) sends it again and causes the behavior. Almost certainly it is due to poor signal reception.

But after some tests, the first thing I noticed is the timeout:

2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] HassSonoffSwitch returning _available: True
2020-05-16 12:03:05 INFO (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Sonoff LAN Mode switch 10009c2128 switching on
2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Switch turn_on called.
2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Scheduling params update message to device: {'switch': 'on'}
2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Connected!
2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] params: {'switch': 'on'}
2020-05-16 12:03:05 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] encrypted: {'sequence': '1589623385402', 'deviceid': '10009c2128', 'selfApikey': '123', 'iv': 'ORv0Gqu0RKW+G3sstB6asw==', 'encrypt': True, 'data': 'wIjXG8EMP3tOKXVmlyXG9Q=='}
2020-05-16 12:03:05 DEBUG (SyncWorker_13) [custom_components.sonoff_lan_mode_r3.switch] Sending http message to http://192.168.0.178:8081/zeroconf/switch: {"sequence":"1589623385402","deviceid":"10009c2128","selfApikey":"123","iv":"ORv0Gqu0RKW+G3sstB6asw==","encrypt":true,"data":"wIjXG8EMP3tOKXVmlyXG9Q=="}
2020-05-16 12:03:05 DEBUG (SyncWorker_13) [custom_components.sonoff_lan_mode_r3.switch] response received: <Response [200]> b'{"seq":41445,"sequence":"1589623385402","error":0}'
2020-05-16 12:03:05 DEBUG (SyncWorker_13) [custom_components.sonoff_lan_mode_r3.switch] message sent to switch successfully
2020-05-16 12:03:07 WARNING (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Device: 10009c2128. Update message not received in timeout period, retry
2020-05-16 12:03:07 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] send_updated_params_loop now awaiting event
2020-05-16 12:03:07 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Connected!
2020-05-16 12:03:07 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] params: {'switch': 'on'}
2020-05-16 12:03:07 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] encrypted: {'sequence': '1589623387476', 'deviceid': '10009c2128', 'selfApikey': '123', 'iv': 'Srw8HjgG2G4B7Be2aAgAag==', 'encrypt': True, 'data': 'L1hf4985Fp6t8qZRH5Y4HQ=='}
2020-05-16 12:03:07 DEBUG (SyncWorker_17) [custom_components.sonoff_lan_mode_r3.switch] Sending http message to http://192.168.0.178:8081/zeroconf/switch: {"sequence":"1589623387476","deviceid":"10009c2128","selfApikey":"123","iv":"Srw8HjgG2G4B7Be2aAgAag==","encrypt":true,"data":"L1hf4985Fp6t8qZRH5Y4HQ=="}
2020-05-16 12:03:07 DEBUG (SyncWorker_17) [custom_components.sonoff_lan_mode_r3.switch] response received: <Response [200]> b'{"seq":41446,"sequence":"1589623387476","error":0}'
2020-05-16 12:03:07 DEBUG (SyncWorker_17) [custom_components.sonoff_lan_mode_r3.switch] message sent to switch successfully
2020-05-16 12:03:08 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff_lan_mode_r3.switch] service is at http://192.168.0.178:8081
2020-05-16 12:03:08 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff_lan_mode_r3.switch] properties: {b'txtvers': b'1', b'id': b'10009c2128', b'type': b'plug', b'apivers': b'1', b'seq': b'41445', b'encrypt': b'true', b'iv': b'NzkyNTEyNjE5MDcwNzMyMA==', b'data1': b'KjrxZjS2oPTlTFtSEBv+sa3sfV49U7RzgehApBf4ODFb+kBjj7v1WhuOzlvDlp/JqT4FOAD1kWuSQ2dyXg//Y5S6Mg6dSH1yaI06j62humAlb18wzd5vdE2GqZ9bvcrk'}
2020-05-16 12:03:08 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff_lan_mode_r3.switch] type: b'plug'
2020-05-16 12:03:08 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff_lan_mode_r3.switch] decrypted data: b'{"switch":"on","startup":"stay","pulse":"off","sledOnline":"off","pulseWidth":500,"rssi":-80}'
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] enter handle_message() b'{"switch":"on","startup":"stay","pulse":"off","sledOnline":"off","pulseWidth":500,"rssi":-80}'
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Message: Received status from device, storing in instance
2020-05-16 12:03:08 INFO (MainThread) [custom_components.sonoff_lan_mode_r3.switch] 10009c2128: Connected event, sending 'available' update
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] expected update received from switch: on
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Switch update pre-callback filter running
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Not inching switch, calling parent callback
2020-05-16 12:03:08 INFO (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Sonoff LAN Mode switch 10009c2128 received updated state from the device: ON, available: True
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] HassSonoffSwitch async_update called
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] HassSonoffSwitch returning _available: True
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] HassSonoffSwitch returning _state: True
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] HassSonoffSwitch returning _name: 10009c2128
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] Update message sent, event cleared, looping
2020-05-16 12:03:08 DEBUG (MainThread) [custom_components.sonoff_lan_mode_r3.switch] send_updated_params_loop now awaiting event

If I have understood correctly, turn_on is called at 12:03:05, and there is a retry at 12:03:07. But if DEFAULT_TIMEOUT = 5, shouldn't this happen later, around 12:03:10?

latency and or complete silence

  • pySonoffLAN version: pySonoffLANr3
  • Python version: 3.5
  • Operating System: Rasbian

Thanks Matt for fixing the Py3.5 issue! it now works (see below).

//--- pySonoffLanr3 v1.10 working:
pi@raspberrypi:~ $ pysonofflanr3  --device_id 1000866aa0 --api_key 530fbde2-4357-4889-bc0c-d57ae2527c5c  on
2020-01-09 16:15:04,465 - info: Initialising SonoffSwitch with host None
2020-01-09 16:15:04,483 - info: Service type _ewelink._tcp.local. of name eWeLink_1000866aa0._ewelink._tcp.local. added
2020-01-09 16:15:04,492 - info: unsolicited update received from switch: off
2020-01-09 16:15:04,495 - info: == Device: 1000866aa0 (None) ==
2020-01-09 16:15:04,497 - info: State: OFF
2020-01-09 16:15:04,582 - info: == Device: 1000866aa0 (None) ==
2020-01-09 16:15:04,583 - info: State: ON
pi@raspberrypi:~ $ pysonofflanr3  --device_id 1000866aa0 --api_key 530fbde2-4357-4889-bc0c-d57ae2527c5c  off
2020-01-09 16:15:12,183 - info: Initialising SonoffSwitch with host None
2020-01-09 16:15:12,202 - info: Service type _ewelink._tcp.local. of name eWeLink_1000866aa0._ewelink._tcp.local. added
2020-01-09 16:15:12,210 - info: unsolicited update received from switch: on
2020-01-09 16:15:12,222 - info: == Device: 1000866aa0 (None) ==
2020-01-09 16:15:12,223 - info: State: ON
2020-01-09 16:15:12,305 - info: == Device: 1000866aa0 (None) ==
2020-01-09 16:15:12,306 - info: State: OFF
pi@raspberrypi:~ $ 

I did, however, come across another strange behavior over the last few days while working on this.

There has been a LOT of latency, in fact often the ITEAD device is completely non-responsive, when trying to get the it to respond to commands. The discover command will often complete with no feedback. The state, on, and off commands also begin to run, but essentially timeout. Only occasionally will the device respond.

On a hunch, I did an experiment that produced interesting results. I opened a 2nd CL window, and began pinging the IP of the device (which was responding appropriately, with a ping every second.). Back in my original CL window session, I again began sending discover, state, on, and off commands - and the device responded immediately to every command consistently. When I stopped the pinging in the 2nd CL window, and went back to sending commands in the original window, the device again became unresponsive. I was able to reproduce this behavior several times - ie while pinging the device in one CL session, it was responding immediately to commands in another CL window; when the pinging stops for more than a few seconds the device becomes very unresponsive.

I'm not sure what this means - does this make any sense?

On the python question: I'm currently running Py3.5 - would there be a benefit to upgrading to a higher number 3.6 or 3.8?

Also, I still have Python 2.5 installed - is this a problem, or can Python3x co-exist without issues (or at least without issues for PySonoffLANr3?)

AttributeError: 'ServiceInfo' object has no attribute 'address'

  • pySonoffLAN version: version 1.1.4
  • Python version: Python 3.9.1
  • Operating System: ubuntu

Description

pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [mytotallysecretkey] --device_id [and_its_device_id] state
or
pysonofflanr3 discover

bring up the error:

root@[machine]:/usr/src/app# pysonofflanr3 discover
2021-02-16 19:30:17,651 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
Exception in thread zeroconf-ServiceBrowser__ewelink._tcp.local._82:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1755, in run
self._service_state_changed.fire(
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1513, in fire
h(**kwargs)
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1611, in on_change
listener.add_service(*args)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/discover.py", line 40, in add_service
ip = utils.parseAddress(info.address) + ":" + str(info.port)
AttributeError: 'ServiceInfo' object has no attribute 'address'


or the error:

root@[machine]:/usr/src/app# pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [the_secret_key] --device_id [the_id] state
2021-02-16 19:27:02,510 - info: Initialising SonoffSwitch with host 172.23.8.158
2021-02-16 19:27:02,510 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2021-02-16 19:27:02,511 - debug: enter send_availability_loop()
2021-02-16 19:27:02,512 - debug: waiting for connection
2021-02-16 19:27:02,512 - debug: send_updated_params_loop is active on the event loop
2021-02-16 19:27:02,512 - debug: Starting loop waiting for device params to change
2021-02-16 19:27:02,512 - debug: send_updated_params_loop now awaiting event
2021-02-16 19:27:02,632 - info: Service type _ewelink.tcp.local. of name eWeLink[some_id]._ewelink._tcp.local. added
Exception in thread zeroconf-ServiceBrowser__ewelink._tcp.local._31:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1755, in run
self._service_state_changed.fire(
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1513, in fire
h(**kwargs)
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1611, in on_change
listener.add_service(*args)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py", line 154, in add_service
self.update_service(zeroconf, type, name)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py", line 166, in update_service
found_ip = utils.parseAddress(info.address)
AttributeError: 'ServiceInfo' object has no attribute 'address'


What I Did

pysonofflanr3 discover
pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [the_secret_key] --device_id [the_id] state

Solution

change "found_ip = utils.parseAddress(info.address)" to
found_ip = utils.parseAddress(info.addresses[0])
in those files:
joe /usr/local/lib/python3.9/site-packages/pysonofflanr3/discover.py line 40
joe /usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py line 119 & line 166

as zeroconf has changed its api from deprecated address to addresses

Manual Inching Support can be removed

At the moment, inching is implemented in code, but this is no longer necessary as its been implemented in firmware and can be controlled via eWeLink app.

For DIY mode it should be implemented with a call to the switch via REST rather than implemented in this wrapper library

NameError: name 'config' is not defined

  • pySonoffLAN version: 0.3.0
  • Python version: 3.7.4
  • Operating System: Linux aarch64

I'm trying to turn on/off a sonoff switch on v3 with pysonofflan. First I get the state of the switch, it is working fine:
/tmp/home/root# pysonofflan --device_id xxxxxxx --api_key xxxxxxxxxxxx state
2019-11-22 20:13:26,679 - info: Initialising SonoffSwitch with host None
2019-11-22 20:13:27,771 - info: Service type _ewelink._tcp.local. of name eWeLink_1000412bfe._ewelink._tcp.local. added
2019-11-22 20:13:27,778 - info: unsolicited update received from switch: off
2019-11-22 20:13:27,779 - info: == Device: 1000412bfe (None) ==
2019-11-22 20:13:27,779 - info: State: OFF

Next I try to turn on the switch, and I have the error below:

/tmp/home/root# pysonofflan --device_id xxxxxxx --api_key xxxxxxxxxxxx on
2019-11-22 20:15:18,064 - info: Initialising SonoffSwitch with host None
Traceback (most recent call last):
File "/opt/bin/pysonofflan", line 11, in
load_entry_point('pysonofflan==0.3.0', 'console_scripts', 'pysonofflan')()
File "/opt/lib/python3.7/site-packages/click/core.py", line 764, in call
return self.main(*args, **kwargs)
File "/opt/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/opt/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/opt/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/opt/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/opt/lib/python3.7/site-packages/click/decorators.py", line 64, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
File "/opt/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/opt/lib/python3.7/site-packages/pysonofflan-0.3.0-py3.7.egg/pysonofflan/cli.py", line 118, in on
switch_device(config['host'], config['inching'], 'on')
File "/opt/lib/python3.7/site-packages/pysonofflan-0.3.0-py3.7.egg/pysonofflan/cli.py", line 202, in switch_device
device_id=config['device_id'],
NameError: name 'config' is not defined

PySonoffLANR3 documentation

The various documentation for the R3 fork is not up to date. This needs sorting out prior to full publication on PyPi

Switching on/off hangs when using CLI

  • pySonoffLAN version: v1.1.4
  • Python version: 3.9
  • Operating System: Armbian 21.05.1

Description

When I switch a device on or off using the CLI it will not terminate after finishing the task. It only works if there is no state change happening.

What I Did

These are the commands (of course there was a real IP and API key given)

pysonofflanr3 --host a.b.c.d --api_key xxo on
pysonofflanr3 --host a.b.c.d --api_key xxo off

It received the expected output, but did not exit properly.

pysonofflanr3 - Unknown message received from device

  • pySonoffLAN version: pysonofflanr3 1.1.4
  • Python version: 3.8.5
  • Operating System: Ubuntu 20.04.1 LTS

Description

  1. Describe what you were trying to get done.
    i am trying to toggle on/off sonoff micro (FW CKA-DM4-GL) with version 3.7.1 firmware.
    (see link for model https://www.itead.cc/sonoff-micro-5v-usb-smart-adaptor.html)

  2. Tell us what happened, what went wrong, and what you expected to happen.
    pysonofflanr3 --host {LAN IP address} --api_key {device API key} --device_id {device ID no} on
    ( device API is obtained using the following script https://github.com/Philiptpp/sonoff_registered_devices)

the command return :
021-02-07 13:13:31,769 - info: Initialising SonoffSwitch with host {LAN IP address}:8081
2021-02-07 13:13:32,074 - info: Service type _ewelink._tcp.local. of name eWeLink_1000f54b35._ewelink._tcp.local. added
2021-02-07 13:13:32,076 - error: Unknown message received from device:
2021-02-07 13:13:32,078 - error: Unexpected error in handle_message() for device {device ID no}: Unknown message received from device Traceback (most recent call last):
2021-02-07 13:13:32,078 - error: File "/home/edric/.local/lib/python3.8/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2021-02-07 13:13:32,078 - error: raise Exception("Unknown message received from device")
2021-02-07 13:13:32,078 - error: Exception: Unknown message received from device

then the script just hangs there until i abort it

What I Did

here is a debug output (ran with pysonofflanr3 --host {LAN IP address} --api_key {device API key} --device_id {device id} -l DEBUG on
2021-02-07 13:24:11,721 - info: Initialising SonoffSwitch with host {LAN IP address}:8081
2021-02-07 13:24:11,722 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2021-02-07 13:24:11,723 - debug: enter send_availability_loop()
2021-02-07 13:24:11,723 - debug: waiting for connection
2021-02-07 13:24:11,723 - debug: send_updated_params_loop is active on the event loop
2021-02-07 13:24:11,723 - debug: Starting loop waiting for device params to change
2021-02-07 13:24:11,723 - debug: send_updated_params_loop now awaiting event
2021-02-07 13:24:11,971 - info: Service type _ewelink._tcp.local. of name eWeLink_1000f54b35._ewelink._tcp.local. added
2021-02-07 13:24:11,973 - debug: service is at http://{LAN IP address}:8081
2021-02-07 13:24:11,973 - debug: properties: {b'data4': b'Ew4EHClpy0i7BZYWm/Fr7Zk33MJF4nvqpOEafpeTuvlS1/arhSeoBiLFQZB+zt6ILPYw6n/pUJqp9V0Um/s4/6aL96yorJg2/MQPTtXZK53KUNzuBKpkuvH5ZmWRaLvpE2lYbg=', b'data3': b'BQm+X/xKP4WRbQfuKy7Dp2cggk9QCP+jK1Ygh6QsFpoi8O8rRB2DKPwEnp+V5k6wLRrl/9JQ+/JU2qhtsH71jrqhzjsjD/aOVMyP1efutQGd9bUdXOsGrizUcleCAwdTKjO+zcZG99OUaH2j6/3LZUWxMxoc+Xwrj7U8UOjcFqalOrnxQ7y5BrWHu147dOF1KLAAfPWYENOhGrx+TR3je3asJbS8Muq5YnmJ3dvyoW5K6IwxRpMFRFl', b'data2': b'GNDHtx+7mjVEi7HFinSFtzu3YNVn891A1AyQIYdiFNBKhizbmRh6PxPdAJFVy+nPsRn+/cmNB/5JZpyQDU6gFwzMQc2kkguZa7e0yASvlZuqLiSB2lRjmKfiWQfwOLhR0GdjvWOqpghZ3mHwLRbumAiDEEz4uE5rxvYeD4lxl9nW9ibr8ePu7iSvhsnxGFJEp/LRi913Y76c6ZOtsfY2Rv6sqxkeSPGwgUVhtIelC2DuY2/pbKzH7Ue', b'data1': b'yjEHINDfBk5avN756SJF+oE7LrkzZxpO3inwOoH8nf2WqqjzaoY+srs1DWAdgDfTpOMMyp/1p3+kPXIevBFLZ8LkqYvy7IlFGtHKXYBrXyNb3hz5TkmwT1X/ojssX+l1pr+Ke7xeToyGWtmNK0GBrnQZb/YMIXO9LiKmPsKn5iuOl92AFsiIo9q0N0K+API6jLyxuGlo3Ttc5bABiCxwunP1ymaAmw5zwbQC21XAXtWGcjlfXTQ76iU', b'seq': b'8', b'iv': b'NjM1OTIzNzU1MTk0NjAxNA==', b'encrypt': b'true', b'apivers': b'1', b'type': b'switch_radar', b'id': b'{device id}', b'txtvers': b'1'}
2021-02-07 13:24:11,973 - debug: type: b'switch_radar'
2021-02-07 13:24:11,975 - debug: decrypted data: b'{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"configure":[{"startup":"off","outlet":0},{"startup":"off","outlet":1},{"startup":"off","outlet":2},{"startup":"off","outlet":3}],"pulses":[{"pulse":"off","width":1000,"outlet":0},{"pulse":"off","width":1000,"outlet":1},{"pulse":"off","width":1000,"outlet":2},{"pulse":"off","width":1000,"outlet":3}],"sledOnline":"on","staMac":"44:5D:5E:01:45:8C","rssi":-62,"senMode":{"enabled":0,"dTime":10,"tUnit":"s","outlets":[0,1,2,3]},"savMode":{"enabled":0,"dTime":1,"tUnit":"m","outlets":[0,1,2,3]},"alertMode":{"enabled":0}}'
2021-02-07 13:24:11,976 - debug: enter handle_message() b'{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}],"configure":[{"startup":"off","outlet":0},{"startup":"off","outlet":1},{"startup":"off","outlet":2},{"startup":"off","outlet":3}],"pulses":[{"pulse":"off","width":1000,"outlet":0},{"pulse":"off","width":1000,"outlet":1},{"pulse":"off","width":1000,"outlet":2},{"pulse":"off","width":1000,"outlet":3}],"sledOnline":"on","staMac":"44:5D:5E:01:45:8C","rssi":-62,"senMode":{"enabled":0,"dTime":10,"tUnit":"s","outlets":[0,1,2,3]},"savMode":{"enabled":0,"dTime":1,"tUnit":"m","outlets":[0,1,2,3]},"alertMode":{"enabled":0}}'
2021-02-07 13:24:11,977 - error: Unknown message received from device:
2021-02-07 13:24:11,981 - error: Unexpected error in handle_message() for device {device id}: Unknown message received from device Traceback (most recent call last):
2021-02-07 13:24:11,981 - error: File "/home/{home user folder}/.local/lib/python3.8/site-packages/pysonofflanr3/sonoffdevice.py", line 330, in handle_message
2021-02-07 13:24:11,981 - error: raise Exception("Unknown message received from device")
2021-02-07 13:24:11,981 - error: Exception: Unknown message received from device

pysonofflan hangs

  • pySonoffLAN version: 0.3.0
  • Python version: 3.6.8
  • Operating System: Raspbian 9

Description

installing using the following command:

sudo pip install --upgrade git+https://github.com/barbieri/pysonofflan.git@V3-Firmware-fixes

pysonofflan hangs when trying to retrieve the state or change the state:

$ pysonofflan --host 10.0.0.52 --loglevel DEBUG state
2019-09-08 00:22:38,751 - info: Initialising SonoffSwitch with host 10.0.0.52
2019-09-08 00:22:38,755 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2019-09-08 00:22:38,761 - debug: enter send_availability_loop()
2019-09-08 00:22:38,764 - debug: waiting for connection
2019-09-08 00:22:38,766 - debug: send_updated_params_loop is active on the event loop
2019-09-08 00:22:38,767 - debug: Starting loop waiting for device params to change
2019-09-08 00:22:38,768 - debug: send_updated_params_loop now awaiting event

This is my eWelink device: Cemig RDCBC-1P
Firmware version 3.3.0 (PSF-B01-GL)

Is the device_id and api_key necessary?

sonoff 4ch pro r2 issue

  • pySonoffLAN version:3
  • Python version:3.7
  • Operating System:Fedora

It working great at sonoff 4ch pro r2, But On/Off to outlet 0 only

how i can change to selected outlet 0-3

Also i wondering how i can directly On/Off action by curl command without encrypted.

CL: proper way to designate the --api_key

  • pySonoffLAN version: pySonoffLanr3
  • Python version: 3.5
  • Operating System: Raspbian

Thanks for fixing the threading issue! using pySonOffLanr3 now succeeds using the "discover" command on my off-brand ITEAD device:

`pi@raspberrypi:~ $ pysonofflanr3 -l DEBUG discover

2020-01-07 21:16:12,521 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
2020-01-07 21:16:12,524 - debug: Looking for all eWeLink devices on local network.
2020-01-07 21:16:12,548 - debug: 2020-01-07 21:16:12.548115 - Service eWeLink_1000866XXX._ewelink._tcp.local. added
2020-01-07 21:16:12,549 - debug: ServiceInfo(type='_ewelink._tcp.local.', name='eWeLink_1000866XXX._ewelink._tcp.local.', addresses=[b'\xc0\xa8\x01t'], port=8081, weight=0, priority=0, server='eWeLink_1000866XXX.local.', properties={b'iv': b'NzA4MTUwNjAwODIwNTA4MA==', b'data1': b'fZ3DhymzFgU4qm/Hfgbk0ME5pwmcVQRvHxm/qyyRGd22oBJ3GGDsR43HVe0gPvNo5O/Iu2eeqjoqhUK9vFe1xHoCapNFPpLyy8U9eqPdEd8=', b'apivers': b'1', b'encrypt': True, b'type': b'plug', b'txtvers': b'1', b'seq': b'38', b'id': b'1000866XXX'})
2020-01-07 21:16:12,551 - info: Found Sonoff LAN Mode device 1000866XXX at socket 192.168.1.116:8081
2020-01-07 21:16:20,544 - debug: Found Sonoff LAN Mode device 1000866XXX at socket 192.168.1.116:8081
pi@raspberrypi:~ $
`

This was great to see, so I tried the next step to see if I could get the device to return it's state. Reading the docs I saw I need to include the --api_key parameter, as I have no way to put this device into DIY mode. So I tried this:

pi@raspberrypi:~ $ pysonofflanr3 --host 192.168.1.116 --api_key 530fbde2-XXXX-XXXX-bc0c-d57ae2527c5c state 2020-01-08 09:49:24,776 - info: Initialising SonoffSwitch with host 192.168.1.116 2020-01-08 09:50:03,013 - info: Service type _ewelink._tcp.local. of name eWeLink_1000866XXX._ewelink._tcp.local. added 2020-01-08 09:50:03,028 - error: Unexpected error in handle_message() for device 1000866XXX: the JSON object must be str, not 'bytes' <function format_exc at 0x7696fd68>

It appears I did not format the api_key parameter correctly, I tried putting it in quotes, as well as formatting it as a JSON string, as well as including the --device_id parameter, but still no luck. I also tried this with the "on" and "off" commands, instead of the "state" command, but I got the same errors.

Can you explain or provide an example of the proper way to enter the --api_key parameter on the CL? Do I also need to include the --device_id parameter? Or is there something else going wrong here?

Unexpected error in shutdown_event_loop(): gather() got an unexpected keyword argument 'loop'

  • pySonoffLAN version: pySonoffLANr3
  • Python version: 3.10.6
  • Operating System: Kubuntu 22.04

Description

When using state, on or off commands, I get an error when it is finishing and the command does not return

What I Did

pysonofflanr3 --host 192.168.1.58 --api_key on
2023-03-02 18:37:09,566 - info: Initialising SonoffSwitch with host 192.168.1.58
2023-03-02 18:37:09,734 - info: Service type _ewelink._tcp.local. of name eWeLink_10000be334._ewelink._tcp.local. added
2023-03-02 18:37:09,738 - info: None: Connected event, sending 'available' update
2023-03-02 18:37:09,738 - info: unsolicited update received from switch: off
2023-03-02 18:37:09,738 - info: == Device: 10000be334 (192.168.1.58) ==
2023-03-02 18:37:09,738 - info: State: OFF
2023-03-02 18:37:09,738 - info: None: Connected event, waiting for disconnect
2023-03-02 18:37:09,947 - info: None: Connected event, sending 'available' update
2023-03-02 18:37:09,947 - info: == Device: 10000be334 (192.168.1.58) ==
2023-03-02 18:37:09,947 - info: State: ON
2023-03-02 18:37:09,947 - error: Unexpected error in shutdown_event_loop(): gather() got an unexpected keyword argument 'loop'
^C
Aborted!

Flake 8 runs on all environments

Flake 8 runs for each build environment (currently 3).

The CI should be enhanced so it only runs once as a separate environment

pysonofflan problem

pi@home:~ $ python3
Python 3.9.2 (default, Feb 28 2021, 17:03:44)
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.

quit
Use quit() or Ctrl-D (i.e. EOF) to exit

pi@home:~ $ pysonofflanr3 discover
2022-09-15 19:03:16,061 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
/home/pi/.local/lib/python3.9/site-packages/zeroconf/_services/browser.py:168: FutureWarning: <pysonofflanr3.discover.MyListener object at 0x7f998af550> has no update_service method. Provide one (it can be empty if you don't care about the updates), it'll become mandatory.
warnings.warn(

#question

is there a way of passing also the port?
to the pysonofflanr3 --host '--port?
or will always uses 8081?
thanks

Without an api-key specified on command line, error message is not intuitive

  • pySonoffLAN version: 1.1.1-1.1.3
  • Python version: 3.5.3
  • Operating System: Raspbian GNU/Linux 9 (stretch)

Description

Hi, i cannot get state of my sonoff devices (3.0.1 firmware ITA-GZ1-GL, producer by Maker) in LAN mode from my raspberry using pysonofflanr3 because i'm getting in this error

"encoding without a string argument"

I see in debug mode that the discovery options give me back in addresses and properties tag the character "b" before the string of the variable value.

May be this is the cause of

What I Did

[root@raspberrypi0w pysonofflanr3]# pysonofflanr3 -l DEBUG discover
2020-02-18 09:18:38,449 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
2020-02-18 09:18:38,468 - debug: Looking for all eWeLink devices on local network.
2020-02-18 09:18:38,576 - debug: 2020-02-18 09:18:38.575541 - Service eWeLink_10002361e4._ewelink._tcp.local. added
2020-02-18 09:18:38,593 - debug: ServiceInfo(type='_ewelink._tcp.local.', name='eWeLink_10002361e4._ewelink._tcp.local.', addresses=[b'\xc0\xa8\x05e'], port=8081, weight=0, priority=0, server='eWeLink_10002361e4.local.', properties={b'type': b'plug', b'id': b'10002361e4', b'encrypt': True, b'seq': b'430', b'apivers': b'1', b'data1': b'KJZR7owgmK582y4Yk/2BuVkrzzsoyatcUfrlw68FyB3vE73t2vWatbW2YIDbaVH5KhV9veBpXlze/WMa4vIfuA9IuvUGQigR2j3ecPk08D4=', b'txtvers': b'1', b'iv': b'MDcxODE4OTY1NzM1Mzg4NA=='})
2020-02-18 09:18:38,605 - info: Found Sonoff LAN Mode device 10002361e4 at socket 192.168.5.101:8081
2020-02-18 09:18:38,670 - debug: 2020-02-18 09:18:38.669384 - Service eWeLink_1000236c5b._ewelink._tcp.local. added
2020-02-18 09:18:38,712 - debug: ServiceInfo(type='_ewelink._tcp.local.', name='eWeLink_1000236c5b._ewelink._tcp.local.', addresses=[b'\xc0\xa8\x05d'], port=8081, weight=0, priority=0, server='eWeLink_1000236c5b.local.', properties={b'type': b'plug', b'id': b'1000236c5b', b'encrypt': True, b'seq': b'230', b'apivers': b'1', b'data1': b'4eDOhuZfR5bJYNnldpA3byd3LWMQ1mTSImASQjWOwoJc9Y4Cj2yStDGGDjJfCWXGyehelRscMCxw8CUyVUhyxLMmLpBT8RV5vwRvWgaWJMg=', b'txtvers': b'1', b'iv': b'MzI2Mzg0MzU2MDM4NDM5NQ=='})
2020-02-18 09:18:38,746 - info: Found Sonoff LAN Mode device 1000236c5b at socket 192.168.5.100:8081
2020-02-18 09:18:46,721 - debug: Found Sonoff LAN Mode device 1000236c5b at socket 192.168.5.100:8081
2020-02-18 09:18:46,735 - debug: Found Sonoff LAN Mode device 10002361e4 at socket 192.168.5.101:8081

[root@raspberrypi0w pysonofflanr3]# pysonofflanr3 --host 192.168.5.100 -l DEBUG state
2020-02-18 09:22:15,893 - info: Initialising SonoffSwitch with host 192.168.5.100
2020-02-18 09:22:15,909 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2020-02-18 09:22:15,936 - debug: enter send_availability_loop()
2020-02-18 09:22:15,956 - debug: waiting for connection
2020-02-18 09:22:15,967 - debug: send_updated_params_loop is active on the event loop
2020-02-18 09:22:15,976 - debug: Starting loop waiting for device params to change
2020-02-18 09:22:15,986 - debug: send_updated_params_loop now awaiting event
2020-02-18 09:22:16,078 - info: Service type _ewelink._tcp.local. of name eWeLink_1000236c5b._ewelink._tcp.local. added
2020-02-18 09:22:16,131 - debug: service is at 192.168.5.100:8081
2020-02-18 09:22:16,200 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:16,188 - debug: properties: {b'data1': b'4eDOhuZfR5bJYNnldpA3byd3LWMQ1mTSImASQjWOwoJc9Y4Cj2yStDGGDjJfCWXGyehelRscMCxw8CUyVUhyxLMmLpBT8RV5vwRvWgaWJMg=', b'txtvers': b'1', b'id': b'1000236c5b', b'type': b'plug', b'seq': b'230', b'apivers': b'1', b'iv': b'MzI2Mzg0MzU2MDM4NDM5NQ==', b'encrypt': True}
2020-02-18 09:22:16,226 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:16,276 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:16,245 - debug: type: b'plug'
2020-02-18 09:22:16,311 - error: Error updating service for device None: encoding without a string argument, Traceback (most recent call last):
2020-02-18 09:22:16,311 - error: File "/usr/local/lib/python3.5/dist-packages/pysonofflanr3/client.py", line 229, in update_service
2020-02-18 09:22:16,311 - error: data = sonoffcrypto.decrypt(data1, iv, self.api_key)
2020-02-18 09:22:16,311 - error: File "/usr/local/lib/python3.5/dist-packages/pysonofflanr3/sonoffcrypto.py", line 72, in decrypt
2020-02-18 09:22:16,311 - error: api_key = bytes(api_key, "utf-8")
2020-02-18 09:22:16,311 - error: TypeError: encoding without a string argument
2020-02-18 09:22:17,097 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:17,105 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:17,237 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:17,251 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,035 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,059 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,110 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,121 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,171 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,196 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,236 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:19,245 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,046 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,056 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,120 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,130 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,193 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,209 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,271 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:23,279 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,101 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,109 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,187 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,221 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,233 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,262 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,284 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
2020-02-18 09:22:31,327 - debug: same update received for device: eWeLink_1000236c5b._ewelink._tcp.local.
^C

Caught Exception: can't start new thread

  • pySonoffLAN version: 0.3.0
  • Python version: 3.5
  • Operating System: Raspbian

I found matt's fork and used pip to install, When I run the CLI discover command, it ends with:
Caught Exception: can't start new thread

Here is the pip install command I used, and the output:

pi@raspberrypi:~/pysonofflan_v3 $ sudo pip install git+https://github.com/mattsaxon/pysonofflan.git@V3-Firmware
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting git+https://github.com/mattsaxon/pysonofflan.git@V3-Firmware
  Cloning https://github.com/mattsaxon/pysonofflan.git (to revision V3-Firmware) to /tmp/pip-req-build-uq2xu0nx
  Running command git clone -q https://github.com/mattsaxon/pysonofflan.git /tmp/pip-req-build-uq2xu0nx
Requirement already satisfied: Click>=7.0 in /usr/local/lib/python3.5/dist-packages (from pysonofflan==0.3.0) (7.0)
Requirement already satisfied: click_log in /usr/local/lib/python3.5/dist-packages (from pysonofflan==0.3.0) (0.3.2)
Requirement already satisfied: websockets in /usr/local/lib/python3.5/dist-packages (from pysonofflan==0.3.0) (7.0)
Requirement already satisfied: pycryptodome in /usr/local/lib/python3.5/dist-packages (from pysonofflan==0.3.0) (3.9.4)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from pysonofflan==0.3.0) (2.12.4)
Building wheels for collected packages: pysonofflan
  Building wheel for pysonofflan (setup.py) ... done
  Created wheel for pysonofflan: filename=pysonofflan-0.3.0-py2.py3-none-any.whl size=19478 sha256=7fae0207117fb09f6722ed69b737db56132b162526c8000b5daf6311d07131cc
  Stored in directory: /tmp/pip-ephem-wheel-cache-ik7c7wsk/wheels/19/15/d3/d182cb566d77a0cf0089734f3b7e7ab19b8a2e4ef3fbe25e8e
Successfully built pysonofflan
Installing collected packages: pysonofflan
Successfully installed pysonofflan-0.3.0

(I had already used pip install and pip uninstall a few times)

Here is the discover command and output:

pi@raspberrypi:~/pysonofflan_v3 $ pysonofflan -l DEBUG discover
2019-11-28 23:37:07,254 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
2019-11-28 23:37:07,256 - debug: Attempting connection to all IPs on local network.
2019-11-28 23:37:07,309 - debug: Attempting connection to IP: 127.0.0.1 on port 8081
2019-11-28 23:37:07,311 - debug: Attempting connection to IP: 192.168.0.0 on port 8081
2019-11-28 23:37:07,313 - debug: Attempting connection to IP: 192.168.0.1 on port 8081
2019-11-28 23:37:07,314 - debug: Attempting connection to IP: 192.168.0.2 on port 8081
2019-11-28 23:37:07,315 - debug: Attempting connection to IP: 192.168.0.3 on port 8081
...
2019-11-28 23:37:07,521 - debug: Attempting connection to IP: 192.168.0.115 on port 8081
2019-11-28 23:37:07,523 - debug: Attempting connection to IP: 192.168.0.116 on port 8081
2019-11-28 23:37:07,524 - debug: Attempting connection to IP: 192.168.0.117 on port 8081
...
2019-11-28 23:37:07,787 - debug: Attempting connection to IP: 192.168.0.243 on port 8081
2019-11-28 23:37:07,790 - debug: Attempting connection to IP: 192.168.0.244 on port 8081
2019-11-28 23:37:07,792 - debug: Attempting connection to IP: 192.168.0.245 on port 8081
2019-11-28 23:37:07,792 - error: Caught Exception: can't start new thread
pi@raspberrypi:~/pysonofflan_v3 $ 

(I have removed most of the IP address output for brevity - my sonoff device is at 192.168.1.116)

I had previously installed the master branch from beveradb/pysonofflan, and even though I've since learned it will not work properly with my V3.3.0 device, I was able to at least get the discover command to work, and it would report finding my device at IP 192.168.1.116

I would very much like to get this V3-Firmware branch to work via CLI, but I'm wondering why it's throwing the Caught Exception: can't start new thread error - do I have a version issue with some dependency?

(My objective is to control several outside lights on the grounds, and write my own code to fire the CLI commands, ie. not planning to use homeassistant, etc.)

Call hangs forever when running as a library

  • pySonoffLAN version: pysonofflanr3, version 1.1.4
  • Python version: Python 3.7.4
  • Operating System: Windows 10

Intro

First of all, thank you for maintaining this library, it is amazing that something like this is available for use for everyone. I cannot tell you how much I appreciate you taking the time to work on this library.

Second of all, this is maybe just me misunderstanding how the library should be used. If this is the case, feel free to show me my mistake(s) or point me in the right direction to learn how to do it correctly. I have tried to google around quite a bit and looked into the source code, but I have a very hard time understanding all of the asyncio code and I did not find a solution.

Thank you again for your time!

Description

I have a Sonoff switch, I know its ID and API key, and I have successfully used your command line tool to get its state and turn it on/off. I am now trying to use your project as a library in my existing python program to control the switch (for context, I am trying to use it as part of a Flask webserver).

I took the code from the docstring of the sonoffswitch.py file, filled in the address and API key and tried to run it to get state/turn on/turn off.

What happened: The python script hangs and until I terminate it by Ctrl+C, it keeps running without doing anything with the switch.

What I expected to happen: I expected it to print the device_id of the switch, turn it on, turn it off and then print the current state.

What I Did

I took the example code from the docstring of SonoffSwitch in sonoffswitch.py, changed the IP address and added my API key.

from pysonofflanr3 import SonoffSwitch

# Usage example when used as library:
p = SonoffSwitch("192.168.1.XX", api_key = "abcd-efgh-ijkl")
# print the device ID
print(p.device_id)
# change state of plug
p.state = "ON"
p.state = "OFF"
# query and print current state of plug
print(p.state)

Upon running, this script hangs. After keyboard interrupt, this is the traceback I get:

C:\Users\<user>\Desktop>python test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    p = SonoffSwitch(host="192.168.1.XX", api_key = "abcd-efgh-ijkl")
  File "C:\Programs\Anaconda3\lib\site-packages\pysonofflanr3\sonoffswitch.py", line 69, in __init__
    outlet=outlet,
  File "C:\Programs\Anaconda3\lib\site-packages\pysonofflanr3\sonoffdevice.py", line 116, in __init__
    self.loop.run_until_complete(self.send_updated_params_task)
  File "C:\Programs\Anaconda3\lib\asyncio\base_events.py", line 566, in run_until_complete
    self.run_forever()
  File "C:\Programs\Anaconda3\lib\asyncio\base_events.py", line 534, in run_forever
    self._run_once()
  File "C:\Programs\Anaconda3\lib\asyncio\base_events.py", line 1735, in _run_once
    event_list = self._selector.select(timeout)
  File "C:\Programs\Anaconda3\lib\selectors.py", line 323, in select
    r, w, _ = self._select(self._readers, self._writers, [], timeout)
  File "C:\Programs\Anaconda3\lib\selectors.py", line 314, in _select
    r, w, x = select.select(r, w, w, timeout)
KeyboardInterrupt

Proof that running from command line works

This is the output when I control the switch from the command line:

C:\Users\<user>\Desktop>pysonofflanr3 --host 192.168.1.XX --api_key abcd-efgh-ijkl on
2020-05-18 15:07:38,773 - info: Initialising SonoffSwitch with host 192.168.1.XX
2020-05-18 15:07:38,842 - info: Service type _ewelink._tcp.local. of name eWeLink_1000XXXXXX._ewelink._tcp.local. added
2020-05-18 15:07:38,842 - info: None: Connected event, sending 'available' update
2020-05-18 15:07:38,842 - info: unsolicited update received from switch: off
2020-05-18 15:07:38,842 - info: == Device: 1000XXXXXX (192.168.1.XX) ==
2020-05-18 15:07:38,842 - info: State: OFF
2020-05-18 15:07:38,842 - info: None: Connected event, waiting for disconnect
2020-05-18 15:07:39,042 - info: None: Connected event, sending 'available' update
2020-05-18 15:07:39,042 - info: == Device: 1000XXXXXX (192.168.1.XX) ==
2020-05-18 15:07:39,042 - info: State: ON

C:\Users\<user>\Desktop>pysonofflanr3 --host 192.168.1.XX --api_key abcd-efgh-ijkl off
2020-05-18 15:07:42,124 - info: Initialising SonoffSwitch with host 192.168.1.XX
2020-05-18 15:07:42,124 - info: Service type _ewelink._tcp.local. of name eWeLink_1000XXXXXX._ewelink._tcp.local. added
2020-05-18 15:07:42,124 - info: None: Connected event, sending 'available' update
2020-05-18 15:07:42,124 - info: unsolicited update received from switch: on
2020-05-18 15:07:42,124 - info: == Device: 1000XXXXXX (192.168.1.XX) ==
2020-05-18 15:07:42,124 - info: State: ON
2020-05-18 15:07:42,124 - info: None: Connected event, waiting for disconnect
2020-05-18 15:07:42,224 - info: None: Connected event, sending 'available' update
2020-05-18 15:07:42,225 - info: == Device: 1000XXXXXX (192.168.1.XX) ==
2020-05-18 15:07:42,225 - info: State: OFF

C:\Users\<user>\Desktop>pysonofflanr3 --host 192.168.1.XX --api_key abcd-efgh-ijkl state
2020-05-18 15:08:16,904 - info: Initialising SonoffSwitch with host 192.168.1.XX
2020-05-18 15:08:17,038 - info: Service type _ewelink._tcp.local. of name eWeLink_1000XXXXXX._ewelink._tcp.local. added
2020-05-18 15:08:17,042 - info: None: Connected event, sending 'available' update
2020-05-18 15:08:17,042 - info: unsolicited update received from switch: off
2020-05-18 15:08:17,042 - info: == Device: 1000XXXXXX (192.168.1.XX) ==
2020-05-18 15:08:17,042 - info: State: OFF

Thank you again for your time and I would be happy to provide any further details.

Add Outlet to CLI

At the moment, the CLI can't accept an outlet parameter and default's to the first (outlet: 0).

The CLI needs enhancing to allow this to be specified

V3-Firmware branch

  • pySonoffLAN version: 0.3.0
  • Python version: 3.7.2
  • Operating System: Windows 10

Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.