-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pysonofflanr3 - Unknown message received from device #250
Comments
Yeah you might need to fork and handle type "switch_radar" you could include OUTLET flag also as it appears your device has 4 |
ah yes line 330 https://github.com/mattsaxon/pysonofflan/blob/V3-Firmware/pysonofflanr3/sonoffdevice.py you will need to add into the elif on line 317 for switch_radar. I can cludge into my fork if you wish as this is no longer maintained |
in simple term, do you mean i need to edit the file by copying elif from line 317 of sonoffdevice.py ? thank you for replying. i didnt realized the library is no longer maintained. i can edit it, but the instuction is a little vague |
Hi, here is my fork: you would need to uninstall your pysonofflanr3 You can see I just commited small change to handle switch_radar device, maybe it works |
thank you so much. i just downloaded it and tried. Howeverm it threw a new error 2021-02-07 18:29:28,881 - info: Initialising SonoffSwitch with host {device IP} |
apologies, I moved switch_radar to the strip type handler as your device has multiple outlets - hopefully this update will work for you |
please dont apologize, especially that you have been so helpful and responsive. With the latest update, there is some positive progress: i am able to get the "state" of the device. Yay! problem: i am still unable to toggle device "on" or "off" here is the output when i try turning on: similar error when i try to turn off the device: here is a debug info: thanks a million! |
I'm out of my capabilities zone here, but the sequence issue seems to be a time sync thing not accepted. I wonder could the time on your Mac be off compared to your sonoff - the sequence is generated via
this is in client.py line 359. maybe it different, would you need to have the same timezone on your Mac as to what ewelink expects |
on http://developers.sonoff.tech/sonoff-diy-mode-api-protocol.html it says that error 400:
I think device is expecting differently formatted JSON to what is being sent in the command, maybe you could try include the -OUTLET flag and use 0 or 1 or 2 or 3 |
thank you for going way out to help me figure this out. i shall tinker with what u said and see where it brings me. i am using linux. i will check and see if there is a need to sync the internal clock with device. but i think maybe the outlet flag is the issue. i'll keep trying. thank u |
no problem. the more I look at it, sequence is just used to track responses so it wouldn't cause an error as long as is unique which is the case. I think the smart adapter expects something else to be included in the JSON, although that error code 400 is for bad JSON format which it isn't. Looks like error 422 would be for a param that was sent but not required If its not the outlet flag, would need to wireshark the network traffic to see what is being transmitted when using the ewelink app. |
exactly what i am thinking, will sniff out the transmission with ewelink app and see whats up. |
Description
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)
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
The text was updated successfully, but these errors were encountered: