HASS-sonoff-ewelink
HASS-sonoff-ewelink copied to clipboard
Detected I/O inside the event loop
In HomeAssistant 0.109.0b0 I have the folowing warning:
Log Details (WARNING) Logger: homeassistant.util.async_ Source: util/async_.py:120 First occurred: 1:09:34 PM (539 occurrences) Last logged: 5:13:47 PM
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
Updated today on 0.109 also get:
Logger: homeassistant.util.async_
Source: util/async_.py:120
First occurred: 18:11:43 (11 occurrences)
Last logged: 18:17:51
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 176: headers=self._headers, json=app_details)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 374: ), headers=self._headers)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 221: r = requests.post('https://%s-disp.coolkit.cc:8080/dispatch/app' % self._api_region, headers=self._headers)```
Also updated today on 0.109 also get:
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self.headers) 14:34:28 – util/async.py (WARNING) - a mensagem ocorreu pela primeira às 14:26:21 e apareceu 9 vezes
same problem here, with HA 0.109
Same after the update:
Log Details (WARNING) Logger: homeassistant.util.async_ Source: util/async_.py:120 First occurred: 3:27:20 PM (11 occurrences) Last logged: 3:34:30 PM
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 176: headers=self._headers, json=app_details) Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers) Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 221: r = requests.post('https://%s-disp.coolkit.cc:8080/dispatch/app' % self._api_region, headers=self._headers)
Yeah @homeassistant said it in the blog this would happen
error for line 374 is in this request:
r = requests.get('https://{}-api.coolkit.cc:8080/api/user/device?lang=en&apiKey={}&getTags=1&version=6&ts=%s&nonce=%s&appid=oeVkj2lYFGnJu5XUtWisfW4utiN4u9Mq&imei=%s&os=iOS&model=%s&romVersion=%s&appVersion=%s'.format( self._api_region, self.get_user_apikey(), str(int(time.time())), ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(8)), self._imei, self._model, self._romVersion, self._appVersion ), headers=self._headers)
i don't have logs for other lines.
Same issue here.
[homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
I'm running in Docker on ubuntu.
Home Assistant 0.109.0
Appreciate any help you can provide. I'm happy to do some testing if that helps at all.
same for me: 2020-04-30 15:28:13 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
same for me too :( 2020-04-30 15:48:15 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
Hi there, same issue here. hope you can look at it, and have a patch to fix it. thanks for your great work @peterbuga!!!
Remains also after update to 0.109.1: 2020-04-30 18:26:47 WARNING (MainThread) [homeassistant.util.async_] Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
@everyone due to the way the logic works and the limitations of the app API i find it very hard to work around this new limitation/warning. i mean it worked just fine(-ish) until now 😅 and it's still works ok in my current setup 🤷♂️ probably this is a more forced paradigm set by the guys @ homeassistant to avoid more custom components going nuts and eat system resources.
there's definitely no easy fix, other than disabling the component (recommended) or upgrading the error reporting to ERROR-level for this component (not recommended). the real fix would be a much much needed ground-up rewrite... 😒
Honestly, it is not a hard fix.
Looking at the logs above, it is about 3 lines that currently cause issues. Add/Wrap those calls as a job to the executor and await hem.
https://developers.home-assistant.io/docs/asyncio_working_with_async#calling-sync-functions-from-async
Please note, that the current state of this integration make Home Assistant execution halt/blocked until these calls are finished. Basically, this integration causes hiccups for the whole system now.
@everyone digging after the issues found on this component as also in the lan_mode_r3 one, I found this new approach
https://github.com/AlexxIT/SonoffLAN
@everyone digging after the issues found on this component as also in the lan_mode_r3 one, I found this new approach
https://github.com/AlexxIT/SonoffLAN
Did you give it a try, barto64? Any issues? Thanks.
I made a first try with a couple of Basic R3 and it worked fine. I strongly recommend to carefully read the doc and watch DrZss video with additional explanations. @peterbuga and others made an extraordinary job and effort in building the old one but it may be the time to move on a different direction especially if you can update all your sonoff firmwares to V3 that is a must. I may have +25 sonoff at home and will need some time to complete the full migration. For now I am in POC phase in my HA DEV environment. Will keep posted my findings in this thread
Thanks a lot barto64 for your response. I've just a dozen basics (all with 3.4.0 and a unused RR-Bridge). I'll wait of peterburga (thanks Peter for your effort) answer on the (call/submitjob) solution (while calls can block a program open new jobs won't only fail in that particular job). If this simple intervention can solve the warning it would be a marvellous solution also for new implementation as new jobs can fail without compromising existing functionality. It could be the way to regain full control without a complete rewrite of todays integration.
As integration i like peters solution it has worked fine al the time and running horses shouldn't be changed while running.
@everyone digging after the issues found on this component as also in the lan_mode_r3 one, I found this new approach
https://github.com/AlexxIT/SonoffLAN
Thanks for the info, but that integration is not well suited for me, since i have lan sonoff but also some remote sonoff and this integration is the best for me. If sonoffLAN could cover both LAN and cloud devices then i will give it a try but for now is not suitable for my needs.
If it was just error messages, I could live with that and I'd certainly fix the code as suggested above to ignore but for me, ALL my Sonoffs are showing as "Entity not available" so I cannot control them whatsoever. :-(
Just tried AlexxIT's version and all but my Power R2 works and I really need that as I have Automations attached to it. My R2 is software version 3.4.0.
So unless and/or until a workaround/fix is found, it looks like it's back to HA 0.108.9 for me. :-(
Logger: homeassistant.util.async_ Source: util/async_.py:120 First occurred: 1 maja 2020, 22:40:36 (430 occurrences) Last logged: 5:56:43
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers)
If it was just error messages, I could live with that and I'd certainly fix the code as suggested above to ignore but for me, ALL my Sonoffs are showing as "Entity not available" so I cannot control them whatsoever. :-(
Just tried AlexxIT's version and all but my Power R2 works and I really need that as I have Automations attached to it. My R2 is software version 3.4.0.
So unless and/or until a workaround/fix is found, it looks like it's back to HA 0.108.9 for me. :-(
I made an R2 to work with this config:
1000250d42:
devicekey: 96cff2c2-7213-457a-a9d1-1f0951b95f21
device_class: [switch, switch]
I tested Basic, R2, Touch, S26, 4CH PRO and Basic 2 and all seems to work well simultaneously with Cloud and LAN mode.
Only one failing to me is a Tishric TSR620/DC
The fact that this working integrated with HACS a the promised to make it a native HA component give me some additional confidence.
Besides it keeps the same name convention in creating the entities so it should make the conversion transparent. I am working on that now.
1000250d42: devicekey: 96cff2c2-7213-457a-a9d1-1f0951b95f21 device_class: [switch, switch]
Cool, thanks for that. Erm.... How do I discover my Device Key, please?
1000250d42:
devicekey: 96cff2c2-7213-457a-a9d1-1f0951b95f21
device_class: [switch, switch]
Cool, thanks for that.
Erm.... How do I discover my Device Key, please?
Do not want to be rude my friend, but please read the documentation and watch Dr Zzs video. It is pretty simple and is well explained. After that if you still have issues happy to help
Same issue; Detected I/O inside the event loop. on HA 0.109.2 ......
Do not want to be rude my friend, but please read the documentation and watch Dr Zzs video. It is pretty simple and is well explained. After that if you still have issues happy to help
No worries. I've watched DrZ's video but I didn't see anything about discovering a key. I already have it all set up. I should also point out that videos are useless to me unless subtitled as I am profoundly deaf. Auto generated subtitled are pretty hit and miss. Have also read the documentation so unless I've missed how to discover a key on devices that are not picked up with AlexxIT's software, I didn't find anything. Sorry to be a pain. I also tried a Google search and all I could see is that iTead haven't fixed it yet so we can see API keys in the app, despite many requests for this.
Do not want to be rude my friend, but please read the documentation and watch Dr Zzs video. It is pretty simple and is well explained. After that if you still have issues happy to help
No worries. I've watched DrZ's video but I didn't see anything about discovering a key. I already have it all set up. I should also point out that videos are useless to me unless subtitled as I am profoundly deaf. Auto generated subtitled are pretty hit and miss.
Have also read the documentation so unless I've missed how to discover a key on devices that are not picked up with AlexxIT's software, I didn't find anything. Sorry to be a pain.
I also tried a Google search and all I could see is that iTead haven't fixed it yet so we can see API keys in the app, despite many requests for this.
Noted :)
If you specify in the settings your eWeLink user and password the component will connect to the Itead Cloud and will create a JSON file called sonoff which contains 100% of the info for each of your devices. As all JSON files not very easy to read but being a bit patient you will be able to see all the data including the “devicekey” for each of your devices.
I did it, got the info, kept the file in a safe place and delete the file and the use and password in the configuration Yaml. I personally do not want my HA to connect to the cloud. It does no preclude that the status of the devices get updated in the cloud when you action them from HA and viceversa.
Forgot to say sonoff file is created in the config folder of HA
Hope it helps.
0.109.2 and error is still here:
Logger: homeassistant.util.async_
Source: util/async_.py:120
First occurred: 1 maggio 2020, 21:56:20 (1113 occurrences)
Last logged: 16:41:13
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 175: headers=self._headers, json=app_details)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 373: ), headers=self._headers)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/__init__.py, line 220: r = requests.post('https://%s-disp.coolkit.cc:8080/dispatch/app' % self._api_region, headers=self._headers)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for meross_cloud doing I/O at custom_components/meross_cloud/__init__.py, line 55: http_client = MerossHttpClient.from_user_password(email=email, password=password)
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for meross_cloud doing I/O at custom_components/meross_cloud/__init__.py, line 60: http_devices = http_client.list_devices()
1113 occurrences ... Hope that the developer @peterbuga could take a look at it....
Honestly, it is not a hard fix.
Looking at the logs above, it is about 3 lines that currently cause issues. Add/Wrap those calls as a job to the executor and await hem.
https://developers.home-assistant.io/docs/asyncio_working_with_async#calling-sync-functions-from-async
Please note, that the current state of this integration make Home Assistant execution halt/blocked until these calls are finished. Basically, this integration causes hiccups for the whole system now.
TBH i thought HA was enforcing a different paradigm where the information needs to be available more or less directly available inside the component logic. i might give it a go but i don't have the latest env to test it tho' 😅 😬
Forgot to say sonoff file is created in the config folder of HA
Thanks for the info. I was pretty sure I had already discovered and looked through that file but couldn't find anything relating to the Power R2. I even did a Find Search and nothing. I thought I'd check again though and lo and behold, I did indeed discover it now. I don't know why it didn't show before.
Then I noticed that the Power R2 is now showing in my Lovelace panel! So maybe that's why. No idea why it took so long to appear. However, only the switch of the Power R2 is showing and none of the usual Voltage, Current, Power options. They used to work in peterbugas version, should they also work in AlexxIT's version? Then I tried adding the code snippet above you gave me which caused the Power R2 switch to disappear again. The Voltage, Current, Power items remained the same, Entity not available. Screenshot -
The Voltage, Current, Power isn't overly important really but would be nice to still have them as before but the main thing is, my actual switch is working. :-)
Me too on 0.109.3
Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 176: headers=self._headers, json=app_details) Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 374: ), headers=self._headers) Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for sonoff doing I/O at custom_components/sonoff/init.py, line 221: r = requests.post('https://%s-disp.coolkit.cc:8080/dispatch/app' % self._api_region, headers=self._headers)