beveradb / pysonofflan

Python interface for controlling Sonoff smart switches/plugs running original Itead firmware, locally, in "LAN mode".
MIT License
30 stars 37 forks source link

oly works on discover #129

Closed juanmol closed 4 years ago

juanmol commented 4 years ago

Description

Trying to get the status or to stablish it.

What I Did

# pysonofflan discover
2019-11-26 12:26:16,909 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
2019-11-26 12:26:17,620 - info: Found Sonoff LAN Mode device at IP 192.168.0.28
2019-11-26 12:26:17,620 - info: Found Sonoff LAN Mode device at IP 192.168.0.22
2019-11-26 12:26:17,621 - info: Found Sonoff LAN Mode device at IP 192.168.0.19
2019-11-26 12:26:17,621 - info: Found Sonoff LAN Mode device at IP 192.168.0.15
2019-11-26 12:26:17,621 - info: Found Sonoff LAN Mode device at IP 192.168.0.23
2019-11-26 12:26:17,622 - info: Found Sonoff LAN Mode device at IP 192.168.0.16
2019-11-26 12:26:17,622 - info: Found Sonoff LAN Mode device at IP 192.168.0.24

# pysonofflan --host 192.168.0.28 state
2019-11-26 12:26:35,896 - info: Initialising SonoffSwitch with host 192.168.0.28
ctrl+c

# pysonofflan -l DEBUG --host 192.168.0.28 state
2019-11-26 12:28:31,213 - info: Initialising SonoffSwitch with host 192.168.0.28
2019-11-26 12:28:31,214 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2019-11-26 12:28:31,214 - debug: send_updated_params_loop is active on the event loop
2019-11-26 12:28:31,215 - debug: Starting loop waiting for device params to change
2019-11-26 12:28:31,215 - debug: send_updated_params_loop now awaiting event
2019-11-26 12:28:31,215 - debug: setup_connection is active on the event loop
2019-11-26 12:28:31,215 - debug: setup_connection yielding to connect()
2019-11-26 12:28:31,215 - debug: Connecting to websocket address: ws://192.168.0.28:8081/

and nothing happends.

parkerPhilip commented 4 years ago

I can at least verify this behavior. I initialized the basic device via phone app (reporting firmware as 3.3.0) and have it set in LAN mode, with the local router blocking its internet access. Using the pysonofflan discover command, the device is found on the correct local IP. Any other pysonofflan command fails, including on, off, or state. In DEBUG mode it appears to fail when connecting via websocket, as described above.

mattsaxon commented 4 years ago

Gents, this library doesn’t work with firmware 3.x as is stated on the read me page.

parkerPhilip commented 4 years ago

Thanks for your prompt response. I re-read the readme page, and don't see any references to 3.x firmware; only "original firmware" and the helpful comments about the 2018 LAN mode change. I have not uploaded any different firmware, so they have the same "original" firmware they were shipped with. As pysonofflan appears to fail while trying to connect with a websocket (doesn't work with 3.x), can you provide any advice or feedback about why this is, and-or if there may be a way around this? My devices do have LAN mode, so is there a way they can "be controlled directly on the local network using a WebSocket connection on port 8081" with the 3.x firmware? pysonofflan can "discover" the devices, so it's tantalizingly to get that close!

parkerPhilip commented 4 years ago

Ah! just found your v3 fork at mattsaxon-pysonofflan. I will try this.

mattsaxon commented 4 years ago

Apologies, I thought the page referred directly to 2.6 firmware. We need to ensure that it does and I will make that change at some point. Glad you found my fork, but we should make it easier to spot!

mattsaxon commented 4 years ago

Closed as V3 firmware works with this. Also updated readme to point to the relevant fork