Custom Component: Omnik Inverter Sensor

Hi,

I’ve created a custom component that reads data from your Omnik Inverter using the local network (no omnikportal.com!)

Check it out at https://github.com/robbinjanssen/home-assistant-omnik-inverter

When installed and configured it generates three sensors:

  • sensor.solar_power_current (Watt)
  • sensor.solar_power_today (kWh)
  • sensor.solar_power_total (kWh)

It has been tested and written for an Omnik 4k TL2 but might work on others too, and that’s where I need you! :slight_smile: The only requirement is that your inverter is connected to your local network and you need to know the IP address.

You can either manually install it or use HACS (custom repository at the moment).

The configuration is easy:

sensor:
  - platform: omnik_inverter
    host: 192.168.100.100

I’m working on support for Omnik inverters that output webDeviceArray instead of webData :+1:

Let me know what you think, if you have any questions, feel free to ask :slight_smile:

3 Likes

Works great! Just a shame there is so little info on de status.js

1 Like

Thanks for using! Indeed it is a shame that this is the only info we can get, at least it is reliable though :slight_smile:

1 Like

Hi @robbinjanssen, thanks for this component! As stated in one of the other threads, after some days (now after 2 days since last reboot) the component will no longer give updates; at that moment the log shows the following warning:
WARNING (MainThread) [homeassistant.components.sensor] Updating omnik_inverter sensor took longer than the scheduled update interval 0:00:30
And is unable to connect/retrieve info from then on. A direct call to “http://192.168.xx.xx/js/status.js” returns a JSON file in my browser, to the inverter is reachable. Using three separate calls with a command_line platform and using CURL does not freeze at all. Unsure why this keeps freezing after 2 - 3 days of running after a reboot…

I noticed the same thing today, will investigate soon. Restarting home assistant made it work again, but its probably temporary.

I”ll update when i found something!

So I added some more debug info to the custom component, unfortunately I cannot (immediately) reproduce it yet.

Two things i’ve functionally changed:

  1. Properly close the connection after reading data.
  2. If the result is None, then do not try to update the state.

I’ll see how this holds up in the coming days

So one interesting thing I notice immediately is that my inverter only updates the status.js file every 5 minutes. The component polls the status.js every minute. We can change this to 5 minute to reduce the number of calls already.

Seems like my data has been consistent for the past few days, I did restart home assistant a few times however because of updates. I’ll check a few more things and then wrap up a new release this week, see if it works better :slight_smile:

Hi @Flaker, I haven’t had any problems anymore since I did my update. If you still want to you can try out version 1.3.0 (you need to enable “Show Beta” to see this release).

Other news; I’ve also added support for inverters that output the data via status.json. We can now use use_json: true in the configuration to enable this :tada:

Update: use v1.3.1 :slight_smile:

Hey @robbinjanssen, where the previous version(s) would stop working within 24 hours, the latest version has been running for 8 consecutive days! Seems you nailed the problem. Nice, will now integrate it into the main HA tab. Thanks for your efforts, much appreciated!

Hi, I’ve been using this for a while now, but I have one problem. I’m using this with two inverters, and they don’t reset the daily total at the same time. Is there something I can do to make them both reset at midnight? Thanks in advance!

I’m struggling getting my Omnik work with the Hass utility meter. When the sun is gone, the omnik doesn’t get power and the wifi drops and all (most) sensors turn to “unknown”. So far I’ve been using the other Omnik custom component

I might try this one. But before that, I wanted to know does this component keep outputting all it’s values, even when the Omnik is unavailable, i.e. Actual power = 0, total power remains total power, power today = power today or 0, depending on time of day.

Hi Sjorsja,

I think if you will use the caching option it will work for you. The caching option keeps the total (max) value at least until the next day has passed. It will reset as soon as it is after midnight or the value is something else then the cached value (most of the time 0 :slight_smile: )

See the comments in the code for more details: https://github.com/robbinjanssen/home-assistant-omnik-inverter/blob/8bd6876b598f810b62fede9eb6276917f0c11967/custom_components/omnik_inverter/sensor.py#L237-L261

Hi Spudje, i’m not sure what happens if the inverter becomes unavailable, it might just log an error and keep the current value since it doesn’t update the state at that point.

If I understand correctly your inverter works normally, except when the sun is gone, it becomes unavailable (because of wifi) but you would like to keep the total value until the next day?

Yes, I use the home assistant Utility Meter https://www.home-assistant.io/integrations/utility_meter/
And that epxects a continuous feed of sensor values.

With the other Omnik component, I believe the actual power stays at 0 when the omnik goes offline, however the energy total (and energy today) become unknown when the omnik is offline. This energy total drives (part of) the Utility Meter and hence gives crippled results.

I tried to fix this with additional template sensors, but to no avail. Lovelace: Power wheel card

Yes I’m almost there. Your component keeps state while the converter goes offline so that’s good.

However, the Home Assistant Utility Meter refreshes its daily cycle exactly at 0:00:00 (e.g. for daily total returned energy), where the solar_power_today sensor refreshes at 0:00:45. This results in a max value of (Dagelijks verbruik uit zon) daily local consumption (solar_power_today - daily total returned energy) at the start of the cycle which equals the maximum value of solar_power_today of the previous day :frowning:

solar_consumption_daily:
        friendly_name: Dagelijks verbruik uit zon
        unit_of_measurement: kWh
        value_template: "{{ states('sensor.solar_power_today') | float - states('sensor.solar_returned_total_daily') | float  }}"

localconsumption

Any idea how I can tell a template sensor to stop measuring around midnight for a few minutes?

This is exactly what I was looking for. Great Job

1 Like

Can’t find it in HACS

It should be there, did you click the + button and then searched for it?

It doesn’t work anymore, state unknown