Fronius inverter integration

Seems to be running solid over night. No errors :+1:

1 Like

I am using this component sensors and also having this issue approximately 1-2 per minute:

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()

Refreshed component to latest version (0.9.2) resrtarted HA and the issue is still there.
Reported also on github.

is there away that we can dfo an scan_interval on a time of day… like at night we scan_interval every 4 hours?

Not sure it helps, but I’m trying to figure out if I can get the line voltage readings from the inverter (they’re available on the Fronius website for my inverter, so figure they must be accessible somehow!).

I tried adding some sensors with some random names and that’s when I started getting a similar message in my log files - so maybe it’s tied to s sensor that’s no longer available/visible?

My config is pretty simple, so it’s pretty obvious when I make a change what’s bugged it out!:

  - platform: fronius_inverter
    ip_address: (InsertIpHere)
    scan_interval: 60
    monitored_conditions:
      - ac_power
      - ac_current
      - ac_voltage
      - ac_frequency
      - dc_current
      - dc_voltage
      - day_energy
      - year_energy
      - total_energy

Hi There.
I know this is rather old post but need some advice.
I use HA since… yesterday :slight_smile: - installed on Pi4 / venv / manual install.
Seems to work fine, I managed to install HACS and fronius integration to custom_components.
It shows correct data, except for current load (sensor.fronius_house_load), which has negative value no matter what.
Grid usage works fine - when I’m feeding the grid it is negative, when I’m pulling energy from the grid, it is positive. But house_load is always negative…
I tryed to add this to configuration.yaml:

sensor:
  - platform: template
      sensors:
        fronius_house_load_pos:
          value_template: "{{ (states('sensor.fronius_house_load') |float) | abs }}"

but after restart, HA went to kind of red panic mode, saying that config is bad.
So what I’m doing wrong and how to get this value positive ?
Many thanks for help :slight_smile:

my configuration.yaml:

# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: fronius_inverter
    ip_address: 192.168.0.133
    powerflow: True
    power_units: kW
    scan_interval: 10
    monitored_conditions:
      - ac_power
      - day_energy
      - year_energy
      - grid_usage
      - house_load
      - panel_status
      - rel_autonomy
      - rel_selfconsumption

Hi, Can you please consider sharing the code for this graphs? They look awsome :slight_smile: Thank you

It’s available in this post:

Hi everyone,
So I am new to home assistant.
I got my fronius inverter setup in HA and I love it. (Basically a new system running on RP3)

But… I’m getting a really strange problem and wondering if anyone can offer some suggestions.
Depending on the configuration of OTHER sensors. Fronius_inverter sometimes breaks. (ie it stops gathering data and I get little red icons next to the entities)

eg
My config looks like this.

sensor:

  - platform: fronius_inverter
    name: Fronius
    ip_address: 192.168.0.37
    scan_interval: 60
    smartmeter: True
    units: MWh
    power_units: kW
    powerflow: True

  - platform: foobot
    token: <token here>
    username: <token here>

  - platform: bom
    station: IDW60901.94608
    monitored_conditions:
      - apparent_t
      - cloud
      - delta_t
      - gust_kmh
      - air_temp
      - dewpt
      - press
      - rain_trace
      - rel_hum
      - vis_km
      - weather
      - wind_dir
      - wind_spd_kmh

#  - platform: snmp
#    name: 'Internet Status'
#    host: 192.168.0.254
#    baseoid: 1.3.6.1.2.1.2.2.1.8.4
#    community: 'public'
#    accept_errors: true
#    version: '2c'
#    scan_interval: 30
#    value_template: "{%if value|int(base=16) == 1 %}OK{% else %}Failed{% endif %}"

Now… if I uncomment the snmp section below. The fronius_inverter metrics fail to collect.
Also… I have found that the configuration of other items (zwave etc) also can break the gathering.
No other sensors fail, just fronius_inverter and the config passes the standard tests.

Here is the error I get when I uncomment snmp

2020-10-28 11:58:53 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up fronius_inverter platform for sensor
Traceback (most recent call last):
  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 367, in _update
    self._data = (await self.fetch_data(self._build_url()))['Body']['Data']
  File "/config/custom_components/fronius_inverter/sensor.py", line 335, in fetch_data
    response = await self._session.get(url, timeout=10)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/usr/local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 860, in start
    self._continue = None
  File "/usr/local/lib/python3.8/site-packages/aiohttp/helpers.py", line 596, in __exit__
    raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
    await asyncio.shield(task)
  File "/config/custom_components/fronius_inverter/sensor.py", line 121, in async_setup_platform
    await fetch()
  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 322, in async_update
    except asyncio.TimeoutError:
NameError: name 'asyncio' is not defined

I expect this might not be a fault with fronius_inverter. But just looking to see if anyone has some ideas.

Note: I have deleted my database to see if that’s the problem. (No change)

I’m new to HA so would be great to get some ideas on how to debug this.
Weird that its ONLY the fronius_inverter plugin getting impacted.

-Ben

I am attempting to add smartmeter_energy_ac_consumed and smartmeter_energy_ac_sold to my fronius request in config.yaml. I am getting the following error when I check configuration,

Invalid config for [sensor.fronius_inverter]: value is not allowed @ data[‘monitored_conditions’][0]. Got ‘smartmeter_energy_ac_consumed’
value is not allowed @ data[‘monitored_conditions’][1]. Got ‘smartmeter_energy_ac_sold’. (See ?, line ?).

I can add other “smartmeter” fields eg smartmeter_current_ac_phase_two without issue. This is on a RaspPi installation. Interesting that on my Synology NAS instal the fields are coming through ok.

I have checked both Fronius_inverter directories and have confirmed files are the same in both cases.
Any assistance would be appreciated.

By default they’re enabled with the smartmeter true. Just leave them out. My integration is below with some other things I have added.

  - platform: fronius_inverter
    ip_address: 192.168.x.x
    units: kWh
    power_units: kW
    smartmeter: true
    powerflow: true

Hi Ben, did you find a solution to your problem. I’m seeing the same issue with my fronius integration.

I have data being gathered via SNMP from my internet gateway and nas. But with the nas SNMP config it breaks the fronius integration - i get timeout errors. When I comment it out it starts to work again.

Can someone please help?

Hi @rybackisback
Not really… Because of the issue I dont use SNMP.
I spent a couple of hours trying to figure it out and eventually gave up.

Hi sini180,

Are you able to share your costing codes? I am curious how you get the ‘$’ sign in front of the figures.

Below snapshot is my output.

image

Hey mate, put $ in front of your template sensor.

${{code here}}

      daily_grid_cost:
        friendly_name: 'Daily Grid Cost'
        value_template: >
               {% set value = (states('sensor.grid_consumed_energy_day') | float * 0.23932 | round(2) ) %}
               ${{ '{:.2f}'.format(value) }}
1 Like

Cheers mate. Your code seems to be more complicated than mine.

total_power_today_cost:
     friendly_name: "Today's Cost"
     value_template: "$ {{ (states('sensor.grid_consumed_energy_day')|float * 0.292699)| round(2) }}"
1 Like

Mine will give the two decimals instead of $2.0 and $0.1 yours shows. Otherwise same same.

1 Like

I have upgraded to 2 Fronius Inverters so changed configuration.yaml to
scope: System

  - platform: fronius_inverter
    ip_address: 192.168.0.196
    powerflow: True
    power_units: kW
    units: kWh    
    scope: System

But after restarting HA, some of the entities get broken.
Removing ‘scope: System’ fixes them but then is only reporting on the first inverter, not the sum of both. Any advice?

Thanks for the code sini180. I created one for ‘daily grid cost’ and ‘daily grid sold’.

How would I calculate the net cost? i.e Cost less sold less daily fixed fee ($1.089 in my case).

daily_grid_cost:
        friendly_name: 'Daily Grid Cost'
        value_template: >
               {% set value = (states('sensor.grid_consumed_energy_day') | float * 0.1956 | round(2) ) %}

               ${{ '{:.2f}'.format(value) }}
daily_grid_sold:
        friendly_name: 'Daily Grid Sold'
        value_template: >
               {% set value = (states('sensor.grid_sold_energy_day') | float * 0.11 | round(2) ) %}
               ${{ '{:.2f}'.format(value) }}

Give this a whirl…

      daily_cost_less_sold:
        friendly_name: 'Daily Cost less Sold'
        value_template: >
               {% set value = ((states('sensor.grid_consumed_energy_day') | float * 0.1956) - (states('sensor.grid_sold_energy_day') | float * 0.11 )) %}
               ${{ '{:.2f}'.format(value) }}

2 Likes

Thank you!
I added in my power company’s fixed daily fee at the end. Hopefully that’s correct math?

daily_cost_less_sold:
        friendly_name: 'Daily Cost less Sold'
        value_template: >
               {% set value = ((states('sensor.grid_consumed_energy_day') | float * 0.1956) - (states('sensor.grid_sold_energy_day') | float * 0.11 )) + 1.09 %}
               ${{ '{:.2f}'.format(value) }}

2 Likes