safepay / sensor.fronius

A Fronius Sensor for Home Assistant
MIT License
80 stars 32 forks source link

Error after update to Ha .109.0 #28

Closed suds32 closed 4 years ago

suds32 commented 4 years ago

Error Detected I/O inside the event loop. This is causing stability issues. Please report issue to the custom component author for fronius_inverter doing I/O at custom_components/fronius_inverter/sensor.py, line 325: result = requests.get(self._build_url(), timeout=10).json()

malcolmrbnsn commented 4 years ago

I have the same issue running the latest version of fronius from HACS.

nagyrobi commented 4 years ago

Something must have been changed in Home Assistant as this warning appears for multiple components

2020-05-01 20:50:41 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 fronius_inverter doing I/O at custom_components/fronius_inverter/sensor.py, line 389: result = requests.get(self._build_url(), timeout=10).json()

lrybak commented 4 years ago

Have the same Begining 0.109 Home Assistant is checking for integrations with code which may cause potential stability and performance issue. Each time it should be reported to integration author

2020-05-01 21:12:53 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 fronius_inverter doing I/O at custom_components/fronius_inverter/sensor.py, line 325: result = requests.get(self._build_url(), timeout=10).json()

nilrog commented 4 years ago

Something must have been changed in Home Assistant as this warning appears for multiple components

Yes, as @lrybak wrote HA started to pinpoint integrations that are not fully async in 0.109. Everything still works but this integration should be updated to fix this issue to avoid causing unnecessary strain on HA's event loop.

I may take a stab at doing that if I get some time over unless someone else does it.

nagyrobi commented 4 years ago

Well, only this warning generates 1.3MB of log/day....

nilrog commented 4 years ago

If someone is eager to test a version that has a fix for the above new warnings that HA started logging in 0.109 I have prepared an update here: https://github.com/nilrog/sensor.fronius/tree/async-io

Just make sure that you grab the sensor.py version that is in the branch async-io that I linked to and not master and replace your local copy with that one.

Apart from making the requests async this version also contains some other changes compared to the current version available in HACS:

I have been running it for the past day in a test setup with HA 0.109, since my main setup is still on 0.108.9, and it seems to work fine. But before I prepare a pull-request for this change I would appreciate if a few more people tried it out first and reported back here if all is ok or something is not ok.

Deez73 commented 4 years ago

I'll install the asyncio testversion right away, will get back in a day or so after the inverter gets back online when there's sunshine :)

lrybak commented 4 years ago

Thanks for prompt reaction. I will test and report issues if any

lrybak commented 4 years ago

Installed the asyncio version. Till now it works good. No I/O warning on event loop. Let's wait until sunshine for more valuable tests.

Btw. I found that sensors like PAC, UAC reports as "unknown" in case the values are not returned by inverter API. Not sure if this is intended aproach. @nilrog wouldn't you consider returning in this case as 0. Unknown value is causing showing NaN value in power-wheel-card for example and I have to deal with extra template sensors to filter unknown values. Thanks

nilrog commented 4 years ago

@lrybak If you are using Power Wheel you should be using the powerflow sensors from the inverter. They are designed to support that use case and will always return a value, even when the inverter is down. See the readme for the supported way of configuring the Power Wheel.

The other APIs in the inverter may have parts, as you have discovered, that are omitted completely, or return "null", when that part of the internals in the inverter is not operational. Like when the sun is down the actual inverter circuitry is down.

Deez73 commented 4 years ago

Looking good so far, readings are coming in as expected, no errors so far (since last night after installing the asyncio version).

Good job @nilrog ... thanks mate!

nagyrobi commented 4 years ago

Looking good here too. No more errors in the log, values feeding correctly the power wheel card and all my other usual graphs. This is ready to be pushed in. Thank you.

nilrog commented 4 years ago

Thanks for the feedback :) I have created a pull-request now.

lrybak commented 4 years ago

Hello. Didn't noticed any issues with async version. Thank you

safepay commented 4 years ago

I've merged this in to the master branch. Let's wait a few days before a release.