Fronius inverter integration

Thanks,
If the URL works then the code should work.
The code is really pretty simple:
It calls the URL with the params
Gets a response back like what you posted.
Then looks for the values for the keys within the body…data section and returns the values.
If you look at the SENSOR_TYPES variable, it tells the system what to return and what the units are.

I’m struggling with why this is not working because I am using your exact data in my test bed.

Needs some more debug lines which I have added to the bottom if you want to see.

Thanks for all your help!

sorry I no good with code but once my friend comes back online this afternoon I call him. he on an diffent time zone so.

I think it might be trying to do maths on strings, so I have added a float.

Will try tonight when home, after last change server did not come back up - Raspberry does that sometimes.

This may also be the way the Fronius handles the request because I cannot replicate this error in any testing environment.

I have added JSON headers to the request.

headers = {'Content-Type': 'application/json', 'Accept': 'application/json'}

Still the same :frowning:

Mon Jul 08 2019 12:27:31 GMT+1000 (Australian Eastern Standard Time) fronius: Error on device update! Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity await entity.async_device_update(warning=False) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 377, in async_device_update await self.hass.async_add_executor_job(self.update) File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/config/custom_components/fronius/sensor.py", line 141, in update self._state = round(self._data.latest_data[self._json_key]["Value"], 1) TypeError: 'NoneType' object is not subscriptable

Capture

Thanks.

This needs more debugging directly on an Inverter, which I don’t have.

On any type of simulation this works perfectly and I have written a similar component for another JSON service that works fine.

This is my test data source:
https://my-json-server.typicode.com/safepay/json/test

Can someone tell me what the difference is between calling the inverter directly and my test data?

I live in brisbane QLD I happy to test at my house if ya like if your close

Maybe that there is something cached.

Refresh your install by deleting the pycache directory and restarting HA

just tryed that. still the same… did you want to test tho teamviewer?

Might be a silly question
but is it possible to write out the full url it is using to grab the data into a log just to confirm it ?, or manually put the full url in the code just to test ??

No, its a great question.

It already logs the URL if you dig through the logs.

The problem is that there is an odd response coming back from the inverter that the code in Home Assistant can’t handle.

It shows no error for receiving a response or even getting values from the result. If this was a problem you would see errors relating to “keys” in the response.

Instead it seems unable to handle the values of the response, which is where I am struggling.

I can fudge a response with the URL I posted earlier and the code handles it no problem.

But as soon as you get the same data from the inverter it gives this TypeError: ‘NoneType’ object is not subscriptable error which I can’t figure out how to fix.

Thanks, hopefully someone can assist, it would be great to get it working

Well this is strange, I had to rebuild my HA then updated to the latest sensor.py. Deleted HA db restarted and guess what
Sensor are there and no errors
Now will have to see if it updates with no issues
how often should it update ??

Strange
Screen shot attached
20%20AM

Oh what did you do. ??? I have to try once I get back home?

Just as above, had to restore HA to previous night due to it crashing Raspberry Pi issue.
Still showed errors.
Updated to the latest sensor.py. - which we did yesterday anyway
Deleted HomeAssisatnt Database. -
Restarted and there is was.
Only thing is, I not sure it is updating (depending how often it supposed to )
ie no change to readings from above as of yet

All the data appears to be data from yesterday ???

Had to reboot as turned of error logging.
Still working (no errors) but definitely not updating, any ideas. ??

Deleted _pycache rebooted
Still not updating from old data, looked at the file in the cache folder and they show errors ??
sensor.cpython-37.pyc
‘utf-8’ codec can’t decode byte 0xd2 in position 9: invalid continuation byte
init.cpython-37.pyc
‘utf-8’ codec can’t decode byte 0xc1 in position 9: invalid start byte
not sure if this means anything ??

Hi @safepay I just wanted to say thank you for this custom component. My Fronius inverter was installed today and the component works great. Now I just need to create a nice Lovelace UI to go with it :slight_smile:

Hi buddy sounds like you got it working I would use InfluxDB with your card… @Kelvin_Sudlow just did an hardware rest too on my raspberry pi and have not got any errors too. Sun is down so can’t test

It looks. Like we have the same numbers