peterbuga / HASS-sonoff-ewelink

Home Assistant component to control Sonoff/eWeLink devices with original firmware
MIT License
791 stars 296 forks source link

[websocket] error from callback <bound method Sonoff.on_message of #235

Closed perseus177 closed 3 years ago

perseus177 commented 4 years ago

Version:

Control of devices is working in HA, but errors are displayed in logs

Problem in log: 2020-05-10 20:24:16 ERROR (Thread-4) [custom_components.sonoff] websocket error: [Errno -3] Try again 2020-05-10 21:01:27 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea30790>>: 'entity_id' 2020-05-10 21:02:58 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea30790>>: 'entity_id' 2020-05-10 21:03:08 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea30790>>: 'entity_id' 2020-05-10 21:04:48 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea30790>>: 'entity_id'

peterbuga commented 4 years ago

this is a duplicate / side-effect of this one https://github.com/peterbuga/HASS-sonoff-ewelink/issues/232 i won't close it yet so anyone else see this and not create another similar issue

perseus177 commented 4 years ago

I added logs from debug mode, maybe help to solve this problem

2020-05-12 20:30:16 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"100037ac42","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"rssi":-54},"from":"device","seq":"211"} 2020-05-12 20:30:16 DEBUG (Thread-4) [custom_components.sonoff] updating: switch.sonoff_100037ac42 on 2020-05-12 20:46:38 DEBUG (MainThread) [custom_components.sonoff] Received state event change for: 100037ac42 2020-05-12 20:46:38 DEBUG (MainThread) [custom_components.sonoff] Device100037ac42change to: {"switch": "off"} 2020-05-12 20:46:38 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"error":0,"deviceid":"100037ac42","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","sequence":"15893091984146326"} 2020-05-12 21:04:19 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000af54a3","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"575"} 2020-05-12 21:04:19 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 21:05:06 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000af54a3","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"576"} 2020-05-12 21:05:06 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 21:05:08 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"on","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"1045"} 2020-05-12 21:05:08 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 21:05:23 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"sysmsg","deviceid":"1000941240","apikey":"cca7d81b-c379-4d7f-8cc1-b0ccbe1a57c7","ts":0,"params":{"online":true}} 2020-05-12 21:05:23 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","d_seq":8,"ts":0,"params":{"sledOnline":"off"},"from":"device"} 2020-05-12 21:05:23 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"fwVersion":"3.4.0","staMac":"84:0D:8E:77:62:A1","rssi":-52,"init":1,"lock":0,"configure":[{"startup":"off","outlet":0},{"startup":"off","outlet":1},{"startup":"off","outlet":2},{"startup":"off","outlet":3}],"pulses":[{"pulse":"off","width":301000,"outlet":0},{"pulse":"on","width":2700000,"outlet":1},{"pulse":"off","width":1000,"outlet":2},{"pulse":"off","width":1000,"outlet":3}],"switches":[{"switch":"off","outlet":0},{"switch":"on","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device"} 2020-05-12 21:05:23 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 21:06:27 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"1047"} 2020-05-12 21:06:27 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 21:59:38 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000af54a3","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"on","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"577"} 2020-05-12 21:59:38 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 22:02:26 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000af54a3","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"578"} 2020-05-12 22:02:26 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 22:02:28 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"on","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"1048"} 2020-05-12 22:02:28 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 22:04:29 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"action":"update","deviceid":"1000941240","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","userAgent":"device","ts":0,"params":{"switches":[{"switch":"off","outlet":0},{"switch":"off","outlet":1},{"switch":"off","outlet":2},{"switch":"off","outlet":3}]},"from":"device","seq":"1049"} 2020-05-12 22:04:29 ERROR (Thread-4) [websocket] error from callback <bound method Sonoff.on_message of <custom_components.sonoff.Sonoff object at 0x6ea26c30>>: 'entity_id' 2020-05-12 22:06:49 ERROR (SyncWorker_9) [homeassistant.components.yeelight] Unable to update device 192.168.0.170, Pracovna Hlavne Svetlo: Bulb closed the connection. 2020-05-12 22:07:29 DEBUG (MainThread) [custom_components.sonoff] Received state event change for: 100037ac42 2020-05-12 22:07:29 DEBUG (MainThread) [custom_components.sonoff] Device100037ac42change to: {"switch": "on"} 2020-05-12 22:07:29 DEBUG (Thread-4) [custom_components.sonoff] websocket msg: {"error":0,"deviceid":"100037ac42","apikey":"4252d7cb-0345-47ed-8b98-d8a7f44fe4d6","sequence":"15893140495234687"}

michielton commented 4 years ago

I made some minor modifications to __init__.py at set_entity_state method. Multi-gang-switch handling had some bugs. Now the error is gone and incoming websocket msgs about multi-gang swiches are handled fine. Will try to attach my modified __init__.py.

Zipped fix here: fix.zip

Beware: this is a modded version of the async-patch branch.

peterbuga commented 4 years ago

@michielton that's where i pointed the problem too, unfortunately i don't have a device with more than 1 switch so i never got the problem + i was kinda busy to inject the values.

thanks & i'll check it out hopefully tonight!

michielton commented 4 years ago

@michielton that's where i pointed the problem too, unfortunately i don't have a device with more than 1 switch so i never got the problem + i was kinda busy to inject the values.

thanks & i'll check it out hopefully tonight!

Cool. I'm not a frequent Github user so I don't know how to do pull requests and that kind of stuff. But I'm sure you'll manage to check the differences in my zipped version and (if accepted) use them in your code.

Thanks for your great work! Stay healthy and have a nice day.

peterbuga commented 4 years ago

@michielton given the fact you confirmed what i was suspecting you picked my interest and i've done some further fixes. pretty please try the latest code i've just pushed and let me know if it works ok for you! you seem to know enough of python to help me debug further this if needed šŸ˜¬ the community needs you too šŸ™Œ !!!

michielton commented 4 years ago

@peterbuga No need for debugging at the moment. Just tried your latest code and everything works like a charm! Thanks again, if you ever need some additional debugging don't hesitate to contact me.

Cheers!