Great article. Would definitely be useful for beginners like me.
Fantastic work! I will definitely go through it and see if I can adopt it a bit. Only thing I miss is the Fronius Battery integration, but I guess that is not needed when you don’t have a battery. I will come back to you later when I did some testing on my setup.
I have just pushed an update to my fork. This contains a bugfix for the handling of values in some of the endpoints when the value is ‘null’ or ‘0’. This should take care of all the problems when sensor data from this integration was used as input to utility meter sensors.
I have been running this version for the last 4 days and I have not seen any issues with it. Historic data for sensors does not show any “dips” down to 0.
What I haven’t tested is if this causes any problems for those who have logging turned off in the inverter at night. But I don’t think this introduces anything new. There will still be errors logged when the inverter is not responding. And if you restart HA when the inverter is off (but still logging) some of the sensors will be “missing” since they are not present in the API endpoints when the inverter in not working.
So if you would be so kind and grab sensor.py from my fork and use it for a while that would be nice. If I can get positive feedback on it I can ask for this change to be merged into the real version that lives in HACS.
Just updated my sensor.py. Will let you know if there are any issues. Thanks!
Do you have a battery? I wish I had. I was under the impression this was very expensive?
Yes I have a battery and you are right it is expensive. Reason why I bought it was that where I live there are quite many power outages and with the Battery I can run aslmost all devices even during power outage. If you want I can share my fronius solarweb with you as a guest so you get an idea how it works, I just need your email address and will add you to my Solarweb.
my email address: [email protected]
Have you noticed any issues with this new version of sensor.py?
I’m creating a pull-request now so I would appreciate if you have some feedback
It has been running fine. No issues even after multiple reboots during day and night.
Only thing is, for the yearly stats, i find the number will get too big for kWh. Might want to convert it to mWh? This has been there since day one. Not an issue but probably something to improvise?
Great! @safepay merged the pull-request and released a new version this morning.
As for the conversion of yearly stats I will leave that discussion to @safepay . But we all probably want it differently and changing the code so I suites everyone will take some effort. And it can be handled with templates outside of the integration.
Not sure if this is a concern. I’ve been seeing the following errors in the logs.
Log Details (WARNING)
Logger: homeassistant.util.async_
Source: util/async_.py:120
First occurred: 1:47:21 PM (469 occurrences)
Last logged: 4:28:40 PM
- 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()
- 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 356: result = requests.get(self._build_url(), timeout=10).json()
- 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()
Same here, the same error that wasnt showing itself on previous versions.
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:
- All I/O requests towards the inverter are now async (no more warnings in HA).
- Sensor updates are now pushed to HA instead of pulled from HA.
- Support for
scan_interval
so you can configure how often you want to pull data from the inverter (default is 60s). - Updated README with instructions for how to configure the energy view in the Power Wheel card in Lovelace.
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.
I have receive 3 positive feedbacks so I have created a pull-request now.
It has been running fine yesterday and I’ve just saw this in the logs this morning
Logger: homeassistant.core
Source: custom_components/fronius_inverter/sensor.py:333
First occurred: May 4, 2020, 10:39:13 PM (78 occurrences)
Last logged: 5:12:17 AM
Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File “/config/custom_components/fronius_inverter/sensor.py”, line 116, in fetch_data
await fetcher.async_update()
File “/config/custom_components/fronius_inverter/sensor.py”, line 319, in async_update
await self._update()
File “/config/custom_components/fronius_inverter/sensor.py”, line 393, in _update
self._data = (await self.fetch_data(self._build_url()))[‘Body’][‘Data’]
File “/config/custom_components/fronius_inverter/sensor.py”, line 333, in fetch_data
response = await self._session.get(url, timeout=10)
File “/usr/local/lib/python3.7/site-packages/aiohttp/client.py”, line 504, in _request
await resp.start(conn)
File “/usr/local/lib/python3.7/site-packages/aiohttp/client_reqrep.py”, line 860, in start
self._continue = None
File “/usr/local/lib/python3.7/site-packages/aiohttp/helpers.py”, line 586, in exit
raise asyncio.TimeoutError from None
concurrent.futures._base.TimeoutError
Grab the latest version again. I did not catch the timeout so I added that now.
Thanks!
Just applied the new version
Will monitor and keep you posted.
Your logger in the inverter is on 24/7 right? Just curious about why there were so many timeouts.
Yes
Logging during night-time hours is set to ‘Yes’
You can search for this string in the log if you want to monitor how frequently this timeout happens.
“: request timeout”
I haven’t seen it myself in my logs so far.