Giter Site home page Giter Site logo

robbinjanssen / home-assistant-omnik-inverter Goto Github PK

View Code? Open in Web Editor NEW
55.0 10.0 21.0 839 KB

Read the current, daily and total Wh from your Omnik Inverter via local network (no cloud!)

License: MIT License

Python 100.00%
home-assistant home-assistant-sensor hacktoberfest python3 homeassistant hacs

home-assistant-omnik-inverter's Introduction

hacs_badge Project Stage

Project Maintenance Maintainability Code Quality

Omnik Inverter Integration for Home Assistant

The Omnik Inverter integration will scrape data from an Omnik inverter connected to your local network. It has been tested and developed on the following inverters:

Supported models

Brand Model Datasource
Omnik Omniksol 1000TL JS
Omnik Omniksol 1500TL JS
Omnik Omniksol 2000TL JS
Omnik Omniksol 2000TL2 JSON
Omnik Omniksol 2500TL HTML
Omnik Omniksol 3000TL JS/TCP
Omnik Omniksol 4000TL2 JS
Ginlong Solis-DLS-WiFi JSON/HTML
Hosola 1500TL JS
Bosswerk BW-MI300 HTML
Bosswerk BW-MI600 HTML
Sofar 3600TLM HTML
Huayu HY-600-Pro HTML

After installation you can add the inverter through the integration page. The values will be presented by two devices in Home Assistant. One is the inverter containing the actual solar power, and one is the device containing information about the wifi signal.

Requirements

Your Omnik Inverter needs to be connected to your local network, as this custom integration will utilise the web interface of the Omnik inverter to read data. All you need to know is the IP address of the Omnik inverter and you are good to go.

HACS installation

Add this integration using HACS by searching for Omnik Inverter Solar Sensor (No Cloud) on the Integrations page.

Manual installation

Create a directory called omnik_inverter in the <config directory>/custom_components/ directory on your Home Assistant instance. Install this integration by copying all files in /custom_components/omnik_inverter/ folder from this repo into the new <config directory>/custom_components/omnik_inverter/ directory you just created.

This is how your custom_components directory should be:

custom_components
├── omnik_inverter
│   ├── translations
│   │   ├── de.json
│   │   ├── en.json
│   │   └── nl.json
│   ├── __init__.py
│   ├── binary_sensor.py
│   ├── config_flow.py
│   ├── const.py
│   ├── coordinator.py
│   ├── diagnostics.py
│   ├── manifest.json
│   ├── models.py
│   ├── sensor.py
│   └── strings.json

Configuration

ha_badge

To configure the integration, add it using Home Assistant integrations. This will provide you with a configuration screen where you can first select the data source. Again, most inverters use JS. Some use JSON and in some rare cases HTML is used. The TCP backend contains additional electrical statistics but lacks information about the WiFi module.

After selecting the data source, enter a name and IP address as host and you're good to go!

Optionally you can update the scan interval in the integration settings.

Examples

Config flow

Entities

What data source do I use?

The web interface has a javascript, JSON or HTML file that contains the actual values. These values are updated every few minutes.

  • Most inverters have a JS file, try accessing http://<your omnik ip address>/js/status.js in your browser.
  • Some inverters use a JSON status file to output the values. Check if your inverter outputs JSON data by navigating to: http://<your omnik ip address>/status.json?CMD=inv_query.
  • A few inverters don't have JS or JSON but output the values directly in a HTML files. Check if your inverter supports the following URL: http://<your omnik ip address>/status.html. Note that this will work for almost all inverters, but you need to check the HTML source for a <script> tag that contains the relevant webData.

If none of the methods work, please open a new issue and we might be able to make it work for your inverter 😄 Make sure you let us know what inverter you use.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Thanks

Special thank you to @klaasnicolaas for taking this integration to the next level 🚀 and @relout for testing 👍

References

home-assistant-omnik-inverter's People

Contributors

cfenner avatar dependabot[bot] avatar gerard33 avatar klaasnicolaas avatar marijns95 avatar mvdwetering avatar raymanp avatar rmvandiepen avatar robbinjanssen avatar trizz avatar wrt54g avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

home-assistant-omnik-inverter's Issues

omnik_inverter no longer supported in latest "core-2021.6.3"?

Since upgrading to the latest core (absolutely NO other changes), the omnik_inverter custom integration seems no longer supported? Check config file results in "Platform error sensor.omnik_inverter - Integration 'omnik_inverter' not found.". Can anyone confirm / deny? Much appreciated! - Bob

Data received but parsed as empty data

See #16 (comment)

2020-05-05 15:22:39 ERROR (SyncWorker_11) [custom_components.omnik_inverter.sensor] Empty data from Omnik Inverter 192.168.0.58
2020-05-05 15:22:39 DEBUG (SyncWorker_11) [custom_components.omnik_inverter.sensor] Data = ['IELN1520178F5210', 'V4.08Build215', 'V4.12Build246', 'Omnik1500tl ', '1500', '862', '625', '24700', '', '1', '']

Unexpected error fetching omnik_inverter data: coroutine ignored GeneratorExit

I get this error every now and then since switching to TCP mode for my Omnik 3000TL:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/omnik_inverter/__init__.py", line 125, in _async_update_data
    SERVICE_INVERTER: await self.omnikinverter.inverter(),
  File "/usr/local/lib/python3.9/site-packages/omnikinverter/omnikinverter.py", line 186, in inverter
    fields = await self.tcp_request()
RuntimeError: coroutine ignored GeneratorExit

Unknown omnik fields in Homeassistant

The fields "inverter temperature" and "Solar production uptime" show a value of Unknown in Homeassistant after i added this integration.
Other fields are shown correctly:

image

Here is the javascript output from my inverter:

var version="H4.01.36Y1.0.05W1.0.04";var m2mMid="605677026";var wlanMac="AC:CF:23:12:90:98";var m2mRssi="100%";var wanIp="192.168.2.1";var nmac="ACCF2312909B";var fephy="off";var webData="NLDN3020138T1242,NL1-V1.0-0061-4,V2.0-0024,omnik3000tl ,3000,1837,1264,261313,,4,";function initPageText(){var A=window.parent.reList("status");fileText("st1",A["t1"]);fileText("st2",A["t2"]);fileText("st3",A["t3"]);for(var B=1;B<=27;B++){if(B!=14){fileText("tx"+B,A[B])}}init_main_page();initStatus();changeFont();child_getH()}function upfold(A){if(document.getElementById("up_"+A+"_div").style.display=="none"){show("up_"+A+"_div");document.getElementById("up_"+A).src="image/up.png"}else{hide("up_"+A+"_div");document.getElementById("up_"+A).src="image/down.png"}if(A==3){if(document.getElementById("ser_status").src==""){document.getElementById("ser_status").src="server_status.html"}}}function init_main_page(){var E=document.form_cover_setting;cfg2Form(E);var C;var D;var B;var A;B=window.parent.reTip("1");A=window.parent.reTip("2");document.getElementById("cover_ver").innerHTML=version;document.getElementById("cover_mid").innerHTML=m2mMid;if(E.wifi_on.value=="disable"){document.getElementById("cover_ap_status").innerHTML=A;document.getElementById("cover_ap_mac").innerHTML="";document.getElementById("cover_ap_ssid").innerHTML="";document.getElementById("cover_ap_ip").innerHTML="";document.getElementById("cover_sta_status").innerHTML=A;document.getElementById("cover_sta_rssi").innerHTML="";document.getElementById("cover_sta_ip").innerHTML="";document.getElementById("cover_sta_mac").innerHTML="";document.getElementById("cover_sta_ssid").innerHTML=""}else{if(E.sta_enable.value=="1"){document.getElementById("cover_ap_status").innerHTML=B;document.getElementById("cover_ap_mac").innerHTML=wlanMac;document.getElementById("cover_ap_ssid").innerHTML=E.ap_ssid.value;document.getElementById("cover_ap_ip").innerHTML=E.lan_ip.value;document.getElementById("cover_sta_status").innerHTML=B;document.getElementById("cover_sta_rssi").innerHTML=m2mRssi;document.getElementById("cover_sta_ip").innerHTML=wanIp;C=wlanMac.substring(0,16);D="0x"+wlanMac.charAt(16);D=D*1+1;D=D.toString(16);D=D.toUpperCase();C=C+D;document.getElementById("cover_sta_mac").innerHTML=C;document.getElementById("cover_sta_ssid").innerHTML=E.sta_ssid.value}else{document.getElementById("cover_ap_status").innerHTML=B;document.getElementById("cover_ap_mac").innerHTML=wlanMac;document.getElementById("cover_ap_ssid").innerHTML=E.ap_ssid.value;document.getElementById("cover_ap_ip").innerHTML=E.lan_ip.value;document.getElementById("cover_sta_status").innerHTML=A;document.getElementById("cover_sta_rssi").innerHTML="";document.getElementById("cover_sta_ip").innerHTML="";document.getElementById("cover_sta_mac").innerHTML="";document.getElementById("cover_sta_ssid").innerHTML=""}}}function init_webdata_form(){var E=webData;var B="";var A,C,D;A=E.length;C=0;D=0;while(C<A){if(E.charAt(C)==","){C+=1;D+=1;web_data_show(D,B);B=""}else{B=B+E.charAt(C);C+=1}}}function web_data_show(D,A){var C=new Array("webdata_sn","webdata_msvn","webdata_ssvn","webdata_pv_type","webdata_rate_p","webdata_now_p","webdata_today_e","webdata_total_e","webdata_alarm","webdata_utime");if(D>10||D<=0){return}var B=document.getElementById(C[D-1]);if(A==""&&B!=null){B.innerHTML="---";return}if(B!=null){if(D==5){B.innerHTML=A+" W"}else{if(D==6){B.innerHTML=A+" W"}else{if(D==7){sv=A*1/100;B.innerHTML=sv.toString()+" kWh"}else{if(D==8){sv=A*1/10;B.innerHTML=sv.toString()+" kWh"}else{if(D==10){if(document.getElementById("webdata_sn").innerHTML=="---"){B.innerHTML="---"}else{B.innerHTML=A+window.parent.reTip("5")}}else{B.innerHTML=A}}}}}}else{alert(C[D])}};

I added this integration manually to homeassistant as described in the README.

I am using Home Assistant Core 2022.6.6 and Frontend-versie: 20220601.0 - latest

Integration does not show up in home assistant

I have installed this manually in my home assistant docker image as described in the readme but the integration does not show up in the list of integrations in home assistant.

I tried restarting the docker image and the docker container but that makes no difference.

If i look in the home assistant logfile i do see the following entry:

2022-06-16 21:11:48 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration omnik_inverter which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant

So it looks like the integration is found but not loaded?

I am using the following versions:
Home Assistant Core 2022.6.6
Frontend-versie: 20220601.0 - latest

repositroy.json missing

When adding the repository in HACS, the log shows the following error:

20-04-29 07:22:04 ERROR (MainThread) [supervisor.utils.json] Can't read json from /data/addons/git/055ed765/repository.json: [Errno 2] No such file or directory: '/data/addons/git/055ed765/repository.json'
20-04-29 07:22:04 WARNING (MainThread) [supervisor.store.data] Can't read repository information from /data/addons/git/055ed765/repository.json

Request: Implement Alert Sensor

Hello, Thanks a lot for your beautiful Project :-D
Works really well.
just one thing sometimes in my HomeAssistant log i have this error log:
Empty data from Omnik Inverter 192.168.0.58
But i can see the kwh etc in homeassistant so i think that the addon work because can take the info from my inverter.
can i send to you some stuff to identify why sometimes won't work?
Thanks a lot
Stefano

Omnik is not working in HA PermissionError: [Errno 13] Permission denied: '.powertoday.pickle'

I get the following error:

2020-06-18 20:57:03 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up omnik_inverter platform for sensor
Traceback (most recent call last):
  File "/home/ha/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/ha/homeassistant/custom_components/omnik_inverter/sensor.py", line 73, in setup_platform
    entities.append(OmnikInverterSensor(data, sensor_type, cache))
  File "/home/ha/homeassistant/custom_components/omnik_inverter/sensor.py", line 174, in __init__
    self.update()
  File "/home/ha/homeassistant/custom_components/omnik_inverter/sensor.py", line 264, in update
    pickle.dump([cacheValue, cacheDay], open(cacheName, 'wb'))
PermissionError: [Errno 13] Permission denied: '.powertoday.pickle'

Ginlong stick password

Get "Failed to connect". I have probably overseen something basic here, but when I try to access my Ginlong stick via the browser, I'm asked for user/ password. I can't see how the integration could get pass that with the GUI installation using JSON (I understand that is the correct mode, as you stated in the docs).

Energie monitor

I can't get the right production from the solarsystem to monitor in home assistant.
In the Energy pulldown menu I see two options: production.today or production.total. Both give 0 kWh.
But the entity sensor.omnik_solar_energy_today seems to give the right output. Unfortunately this one is not in the pulldown list.
Am I doing something wrong?

Current production not in new energy dashboard visible

I updated to the 2.0 version and as was written in the update info on the HACS page it would be compatible with the new energy dashboard. I could only find the solar production today there (settings > energie > solar) but not the current production. I suppose I need there the current production isn't?

error while omnik off

my omnik shutsdown when there is not enough light anymore. The script starts throwing following error message 3 in a row every couple of minutes:

2021-01-21 19:32:27 ERROR (SyncWorker_9) [custom_components.omnik_inverter.sensor] Unable to fetch data from Omnik Inverter 192.168.x. x
2021-01-21 19:32:27 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.solar_power_total fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 278, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 474, in async_device_update
raise exc
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/omnik_inverter/sensor.py", line 215, in update
self._data.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 239, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/omnik_inverter/sensor.py", line 104, in _update
fp.close()
UnboundLocalError: local variable 'fp' referenced before assignment

From my no coder knowlege, I think some error handling can be improved to a state when there is no data fetched to parse (for instance) value 0 back to HA.

I also notice that when HA is restarted during the omnik being shutdown, the sensors are not created and starts reporting "not available" in lovelace cards......by adding above error catching likely it will also keep creating the sensors during nightly restart of HA.

No data inverter

Hi,

I have a Omnik 2.0 TL3-S inverter.
When I do the configuration I get the error code: Error occurred while communicating with Omnik Inverter device.

I have tried the three options below, but no result.

  • Most inverters have a JS file, try accessing http:///js/status.js in your browser.
  • Some inverters use a JSON status file to output the values. Check if your inverter outputs JSON data by navigating to: http:///status.json?CMD=inv_query.
  • A few inverters dont have JS or JSON but output the values directly in a HTML files. Check if your inverter supports the following URL: http:///status.html. Note that this will work for almost all inverters, but you need to check the HTML source for a <script> tag that contains the relevant webData.

Any idea how I can receive data

A username/password is missing error after update to 2.4.0

Detailed description

After updating from 2.3.0 to 2.4.0 the integration does not load anymore. It shows the following error in HA.

Config entry 'Solis Omvormer' for omnik_inverter integration not ready yet: A username and/or password is missing from the request; Retrying in background

This is with a Ginlog Solis Wifistick that used to work before the update.

There are a username and password in the config entry and they are still valid (checked with a browser)

            {
                "entry_id": "30c76ef9eb2272bbf72832b70d4c700f",
                "version": 2,
                "domain": "omnik_inverter",
                "title": "Solis Omvormer",
                "data": {
                    "host": "192.168.178.32",
                    "source_type": "html",
                    "username": "**username**",
                    "password": "**password**"
                },
                "options": {},
                "pref_disable_new_entities": false,
                "pref_disable_polling": false,
                "source": "user",
                "unique_id": null,
                "disabled_by": null
            },

I did a quick scan through the changes, but nothing obvious popped out.

Context

Not sure what to write here.

Diagnostics

I don't see the diagnostics option for this integration?

No connection to Sofar inverter 3.6ktlm-g2

I am trying to connect to my Sofar inverter with Wifi stick (serial 0528...). Al the the methods do not make a connection.

I can connect to my logger with 192.168.86.194/status.html and see this info in the source:

edit:
copy past part status.html deleted and added as attachment
status html.txt

Retrying Setup

Hi,

I'm running into some issues: i've tried all three options to connect. It turns out that the data is there in the status.html file, under a script in the header. When I inspect the page, I can also see the variables. From there I thought it would be easy to get it to work. Installing the integration worked flawlessly, but setting it up is causing me issues. I selected HTML during the setup, and also provided the necessary data (ip address and auth stuff). Am I missing something?

HA Version 10 Possible BUG

Logger: homeassistant.helpers.template
Source: helpers/template.py:1210
First occurred: 16:18:11 (13 occurrences)
Last logged: 16:19:46

Template warning: 'float' got invalid input 'unavailable' when rendering template '{% if states('sensor.fotovoltaico_solar_current_power') | float > states('sensor.shellyem_f4cfa2e45ce7_channel_1_power') | float -%} {{ states('sensor.fotovoltaico_solar_current_power') | float - states('sensor.shellyem_f4cfa2e45ce7_channel_1_power') | float }} {%- else -%} 0 {%- endif %}' but no default was specified. Currently 'float' will return '0', however this template will fail to render in Home Assistant core 2021.12

Not connecting to Ginlong Solis

Hello,

I have been trying to add a Ginlong Solis inverter with a Ginlong stick but when using the "Integration Add..." button it failed to add and displays the error "Kon niet verbinden"/"Could not connect". The data is retrievable via JS and via JSON and if needed I could post that here. Could you help me with this?

Thanks.

Use of requests

Hi Robbin, I have switched over from this custom integration to an Appdaemon script to get the data locally from my inverter. Mostly because that way I can use the same moment on which the data from the inverter and from DSMR is updated. One of the advantages of Appdaemon is that you can change code and directly use it, without restarting HA.
I re-used a lot of your code in the Appdaemon app. Recently I switched from urlopen to requests and to me that seems to work more stable. The number of errors in the log has dropped a lot.

There are e.g. no errors with fp.close() when there is no data and also I am using a timeout.
The change to requests should be rather simple. If you are interested I can share my code so you can make a separate branch to test that version. Let me know your thoughts.

Support for Bosswerk MI600

Hello,

I was looking for a local method to get data from my inverter and stumbled upon this project. Right now I'm using the solarman api, sadly cloud based.

Out of the 3 methods listed in the readme only the HTML method would be available on the Bosswerk MI600. Here i can use a simple
curl --user username:pass "http://ip-address/status.html"
to get the data including the <script> with the webdata:
var webdata_sn = "abc";
var webdata_msvn = "";
var webdata_ssvn = "";
var webdata_pv_type = "";
var webdata_rate_p = "";
var webdata_now_p = "1";
var webdata_today_e = "2.0";
var webdata_total_e = "3.0";
var webdata_alarm = "";
var webdata_utime = "0";
var cover_mid = "def";
var cover_ver = "MW3_15_5406_1.35";
var cover_wmode = "APSTA";
var cover_ap_ssid = "";
var cover_ap_ip = "";
var cover_ap_mac = "";
var cover_sta_ssid = "***";
var cover_sta_rssi = "";
var cover_sta_ip = "#.#.#.#";
var cover_sta_mac = "";
var status_a = "1";
var status_b = "0";
var status_c = "0";

But the integration fails to connect to the inverter with the following message:
"Config entry 'Home' for omnik_inverter integration not ready yet: Error occurred while communicating with Omnik Inverter device; Retrying in background"

Would it be possible to add the MI600 to the integration?

Thanks in advance.

Beta 3 Won’t Work

Hello, after I have updated to beta 3 I have this error in the log

Error setting up entry Fotovoltaico for omnik_inverter
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 304, in async_setup
    result = await component.async_setup_entry(hass, self)  # type: ignore
  File "/config/custom_components/omnik_inverter/__init__.py", line 37, in async_setup_entry
    coordinator = OmnikInverterDataUpdateCoordinator(hass, scan_interval)
  File "/config/custom_components/omnik_inverter/__init__.py", line 92, in __init__
    if self.config_entry.data[CONF_SOURCE_TYPE] == "html":
KeyError: 'source_type

Feature request: Add automated upload functionality to PVoutput.org

Detailed description

HA recently got a data consumer integration to fetch information from PVOutput (which was uploaded by your solar photovoltaic (PV) system). It got me thinking that it would be nice of this omnik plugin has the option to push data to PVOutput.org.

Context

This feature could secure our PV data, as it could serve as a backup. I'm a HA user for almost 2 years now and have lost most of my PV data collected over this time due to user error and 'bugs'. Migration from SD to SSD, from NAS to Raspberry, going from SQLite to MariaDB. I guess things many users do, but not oversea the consequences of their 'playing around' until the data is already lost.

Error message when installing and setting up the integration

Hi there,

Just found out this solution to read my PV panels information in Home Assistant.
When setting up I ran into some problems.
The first was the "config flow could not be loaded".
Found out it was an MQTT issue, didn't install it yet.
When i installed MQTT I get the set up page, when I add my to inverters it works great.
But when I wan't to add the entity's to my Energy dashboard, can not find them.
Searching a little bit further gives me this error message:

"Logger: homeassistant.setup
Source: setup.py:317
First occurred: 23:22:28 (2 occurrences)
Last logged: 23:22:45

Unable to prepare setup for platform omnik_inverter.sensor: Platform not found (cannot import name 'SensorDeviceClass' from 'homeassistant.components.sensor' (/usr/src/homeassistant/homeassistant/components/sensor/init.py))."

What am I doing wrong? Still learning the magic of Home Assistant and programming, But when Googling this error, can't get any further.

Thanks in advance!

Error occurred while communicating with Omnik Inverter device; Retrying in background

i own the 2500 TL; Status.html.

This integration did work for a time, but then it wouldnt connect all of a sudden. i got the following error:
`[homeassistant.config_entries] Config entry 'omnik_pv' for omnik_inverter integration not ready yet: Error occurred while communicating with Omnik Inverter device; Retrying in background.

Nothing ever happens again except for the same error. It does not start, it does not create entities.

This may be something locally related or not.

Nice custom component

Looks good. Thanks for sharing this.
Maybe you can also add the total power as that is available in the js as well?

2 inverters

How to handle 2 inverters? I know have added 2 inverters but in the graph they will stand next to each other. Can I get it as a total and add it to the new energy dashboard? If I create a ne sensor I cannot add it to the new energy dashboard.....

Caching is not reset properly if the time is set incorrect.

When the time on the inverter has not been set correctly, it could cause your system not te reset the power today to 0 at 00:00. For this scenario we don't have solution yet:

For example, in the "perfect" case:

2159 -> cache: 5, value: 5 -> output 5
2200 -> cache: 5, value: 0 -> output 5
...
0000 -> cache: 5, value: 0 -> cache reset -> output/cache: 0
0100 -> cache: 0, value: 0 -> cache reset -> output/cache: 0
...
0700 -> cache: 0, value: 0.1 -> cache reset -> output/cache: 0.1

But if your inverter doesn't output 0 before or after 00:00, we don't reset the cache properly:

2159 -> cache: 5, value: 5 -> output 5
2200 -> cache: 5, value: 5 -> output 5
...
0000 -> cache: 5, value: 5 -> cache reset -> output/cache: 5
0100 -> cache: 5, value: 5 -> cache reset -> output/cache: 5
...
0700 -> cache: 5, value: 0.1 -> cache reset -> output/cache: 5

To deal with this we need to extend the cache to:
[day, time, value]

Example 1, default situation:

# Cache value:
cacheDay = 20200331
cacheTime = 2358
cacheValue = 5.0

# Current
currentDay = 20200331
currentTime = 2359
currentValue = 5.0

if (
    currentDay == cacheDay 
    and currentTime > cacheTime 
    and currentValue >= cacheValue
):
    nextValue = currentValue

Example 2, the system does not reset the power today value at 00:00

# Cache value:
cacheDay = 20200331
cacheTime = 2359
cacheValue = 5.0

# Current
currentDay = 20200401
currentTime = 0
currentValue = 5.0

if (
    currentDay == cacheDay # This is false now.
    and currentTime > cacheTime 
    and currentValue >= cacheValue
):
    nextValue = currentValue
elif (currentDay > cacheDay and currentValue == cacheValue):
    # Output 0 but keep the cache the same as the last known state.
    nextValue = 0

Example 3, at a later time the system doet reset the power today value to 0.0

# Cache value:
cacheDay = 20200331
cacheTime = 2359
cacheValue = 5.0

# Current
currentDay = 20200401
currentTime = 341
currentValue = 0.0

if (
    currentDay == cacheDay # This is false now.
    and currentTime > cacheTime 
    and currentValue >= cacheValue
):
    nextValue = currentValue
elif (currentDay > cacheDay and currentValue == cacheValue): # This is false now.
    nextValue = 0
elif (currentDay > cacheDay and currentValue != cacheValue):
    # Use the currentValue again and store in cache!
    nextValue = currentValue

I think something along this way should fix it.

Add caching layer for inverters that go offline after dark

We've learned that some inverters go offline after dark. Meaning the status.js/json file is no longer reachable. Instead of throwing errors and exceptions we would like to introduce a caching layer. As discussed in the python client for this package we need to add the caching layer to this integration.

@sander76 reached out and pointed us in the right direction. Unfortunately I don't have much time right now, it would be awesome if anyone would like to give it a go!

Instructions here:
klaasnicolaas/python-omnikinverter#24 (comment)

This would solve #39

Leave old value instead of Unavailable

Hello,
We have some problem with this inverter that goes in unavailable state very often, instead of go in unavailble also in HA sensors could we leave the latest value readed?
Se we don't have all this sensors unavailable also in HA, a little explanation:
If inverter not reply:
solar_current_power = 0
solar_energy_today = last value before connection lost
solar_energy_total = last value before connection lost
Best Regards
Stefano

Feature request: configurable update interval

Great project! I've done the same using a Bash script that parses the web page of the Omnik inverter and publishes the result to MQTT.

Because I like your approach (custom component) I would like to use this HA integration instead of my own Bash script. The only thing I'm missing is a variable update interval. At the moment I'm executing my Bash script every minute. I've read that your component updates the state every 5 minutes (in your code it seems 500 seconds).

Is it possible to move this hard-coded interval to some kind of configurable setting?

Status.html support?

i use an omnik 2500tl. this inverter does not has a json or js page but it just posts it in a status.html. is it possible to support this? as it is webdata is directly visible in the html code? any suggestions?

Optimal "minimum time between entity updates"

Hi - not an issue as such, more a request for assistance.

Is there an optimal setting for the "minimum time between entity updates" in the Configure settings ?

I have tried 4 and 5 minutes and on either I see the following type of results - notice the frequent inability to get any results. The wifi doesn't seem to be dropping to the inverter so I just thought there might be a 'better' value to be using for more consistent results.

image

Thanks.

Config flow not working

Plugin: v2
Home Assistant: 2021.10.6

Problem Description

When installing via HACS the config flow (the configuration window) never shows up. Since the documentation doesn't show what the config could potentially look like, I don't really know how to configure the component.

Solution

  • Make the config flow work again?
  • Document the default configuration in YAML in the readme.md

Solis inverter with YingZhen datalogger not working

When I try to add my Solis (Ginlong) inverter with YingZhen datalogger (WiFi stick) my HA tells me the following at the integration configuration.

Opnieuw proberen in te stellen: A username and/or password is missing from the request

I have added it via the HTML way, I can reach the WiFi stick at status.html and it has a <script> tag with the webData.

HA log says the following:

Config entry 'Solis' for omnik_inverter integration not ready yet: A username and/or password is missing from the request; Retrying in background

I have filled in the username & password when I configured the integration in HA (default admin, admin)

image
image
image

No data found

Thanks for this promising addon!
For me unfortunately it doesn't work yet, hope you can help.

The addon logs:
Empty data from Omnik Inverter 192.168.1.28

In configuration.yaml I set the IP address as per the instructions (so 192.168.1.28)

http://192.168.1.28/js/status.js returns:
var txt;var opt;function initPage(){txt=window.parent.reList().page.status;opt=window.parent.reList().page.option;for(var A=1;A<13;A++){inner("t"+A,txt["t"+A]);inner("p1_"+A,txt.pg1[A]);inner("p2_"+A,txt.pg2[A]);inner("p3_"+A,txt.pg3[A]);inner("p4_"+A,txt.pg4[A])}inner("p3_1_1",txt.pg1[6]);inner("p3_2_1",txt.pg1[6]);inner("p3_1_2",txt.pg3[6]);inner("p3_2_2",txt.pg3[6]);inner("p3_1_3",txt.pg3[4]);inner("p3_2_3",txt.pg3[4]);inner("p3_2_4",txt.pg3[5]);inner("p3_2_5",txt.pg3[7]);changeFont();child_getH()}function initData(){child_getH();ajax("status.json?CMD=inv_query&rand="+Math.random())}function ajaxReturn(B){if(B.time!=null){inner("gtype",txt.pg1["s3"]);inner("gsn",B.g_sn);inner("ver",B.g_ver);inner("time",new Date(B.time*1000).toString());inner("worktime",B.g_time+" "+txt.pg1["s4"]);inner("error",B.g_err);inner("mac",B.mac);inner("auto_ip",enb_txt(B.auto_ip));inner("ip",B.ip);inner("sub",B.sub);inner("gate",B.gate);inner("auto_dns",enb_txt(B.auto_dns));inner("dns",B.dns);inner("dns_bak",B.dns_bak);inner("type",reInvBrand(B.i_type));if(B.i_num==null||B.i_num==0){}else{show("inv_data",true);inner("list",B.i_sn);var A=[B.i_sn,B.i_ver_m,B.i_ver_s,B.i_modle,B.i_pow,B.i_pow_n,B.i_eday,B.i_eall,B.i_alarm,B.i_last_t];inv_data_show(A)}inner("ip_a",B.l_a_ip);inner("port_a",B.l_a_port);inner("agreement_a",agr_txt(9,B.l_a_agr));if(B.ip_b!=null){show("server_b",true);inner("ip_b",B.ip_b);inner("port_b",B.port_b);inner("domain_b",B.ipdm_b);inner("agreement_b",agr_txt(9,B.agr_b))}if(B.i_status!=null){if(B.i_status==0){show("inv_data",false)}else{show("inv_data",true)}}}if(B.conn_a!=null){initStatus("status_0",B.conn_a)}if(B.conn_b!=null){initStatus("status_1",B.conn_b)}}var sels=1;function upfold(A){var B=getCon("pg"+A);if(B.style.display=="none"){B.style.display="";getCon("p"+A).src="image/up.png"}else{B.style.display="none";getCon("p"+A).src="image/down.png"}child_getH();if(A==3&&B.style.display!="none"){ajax("s_ping.json?CMD=inv_query&server=110&rand="+Math.random())}}function inv_data_show(A){var D=new Array("list","mver","sver","inv_tp","rate_p","now_p","day_e","all_e","alarm","uptime");if(A!=null){for(var B=1;B<10;B++){if(A[B]==""){if(isNaN(parseInt(A[B]))){inner(D[B],"---");continue}}var C=A[B];switch(B){case 4:C+=" W";break;case 5:if(C*1==4294967295){C="---"}else{C+=" W"}break;case 6:if(C*1==4294967295){C="---"}else{C+=" kWh"}break;case 7:if(C*1==4294967295){C="---"}else{C+=" kWh"}break;case 9:if(getCon("list").innerHTML=="---"){C="---"}else{C+=txt.pg2["s2"]}break}inner(D[B],C)}}}function initStatus(C,B){var A=txt.pg3["s1"];var D=txt.pg3["s2"];if(B==1){getCon(C).innerHTML=A}else{getCon(C).innerHTML=D}}function enb_txt(A){var B=txt.pg2["s4"];if(A==1){B=txt.pg2["s3"]}return B}function agr_txt(C,A){var B="";if(C==1){B=opt[1];if(A==1){B=opt[2]}}if(C==3){B=opt[3];if(A==1){B=opt[4]}}if(C==5){B=opt[5];if(A==1){B=opt[6]}}if(C==7){B=opt[7];if(A==1){B=opt[8]}}if(C==9){if(A==2){B=opt[11]}else{if(A==1){B=opt[10]}else{B=opt[9]}}}return B};

If I open manually http://192.168.1.28 I see the data (I have removed the SN).
omnik

Looking for Beta Testers

Me and @klaasnicolaas are looking for users that have enabled the use_json option to test out the new version of this component. It seems that there is a difference in JSON output between several inverters and we would like to gather as much data as possible.

What we would like to know is:

  • Your inverter model/type
  • Your firmware version the inverter
  • Your (obscured) JSON output (http:///status.json?CMD=inv_query&rand=0.1234567)

Please help us out so we can make updating as smooth as possible! :-)

Omink liquidation closedown omnikportal

Hi, as most of us have been informed omnik is not able to pay for the hosting services. This is now done by Solarman, you need to pay for their services.

Is it possible to no change the code in a way, the data is directly pulled from the inverter?

and or make use of traffic over the wifi network?

No devices in status.js when no power is generated

When my inverter (PowerOne + iGEN Wi-Fi external logger) does not generate any power for a while, the inverter disappears from the status.js source, causing errors and resulting in 'Unavailable' sensors.

status.js with sun:

var yz_device_num="1";
var myDeviceArray=new Array();
myDeviceArray[0]="xxxxxx          ,xxxx,,-xxxx-,,xxx,x,xxxxxx,,x,";
;
function initPageText()

status.js without sun:

var yz_device_num="0";
var myDeviceArray=new Array();
;
function initPageText()

Possible fix:
This issue could be resolved by using the cache when the source is retrievable (status.js found), but the regex for the data fails (or yz_device_num value is 0). The power_current sensor could be forced to 0, and the power_today and power_total values could be retrieved from cache.

Sensor states unavailable since update to v2.0.0

Since the update to the latest version and removing the old config from the yaml and moving to the integration I have the issue that all the sensor states become unavailable quite often. With the old method I never had that, anyone else with the same issues?

Kind regards,

Jeroen

Component stops working after connection issues.

I've had this issues about 10 times now. When the inverter doesn't respond in time (within 10 seconds) or the component receives 'empty' data from the inverter the component stops working after some time.

It seems like it's freezing (out of connections?). They only way to get it working again is to restart Home Assistant. In that case it looks like the component is preventing HA to shutdown because I have to kill the process manually from the command line. When I start HA again the component works fine.

These are the last lines of my home-assistant.log file

2020-06-10 12:08:21 ERROR (SyncWorker_1) [custom_components.omnik_inverter.sensor] Unable to fetch data from Omnik Inverter 192.168.1.18
2020-06-10 12:10:20 ERROR (SyncWorker_4) [custom_components.omnik_inverter.sensor] Empty data from Omnik Inverter 192.168.1.18
2020-06-10 12:20:28 ERROR (SyncWorker_1) [custom_components.omnik_inverter.sensor] Empty data from Omnik Inverter 192.168.1.18
2020-06-10 12:27:35 ERROR (SyncWorker_1) [custom_components.omnik_inverter.sensor] Empty data from Omnik Inverter 192.168.1.18

A couple of hours later I manually tried to open the web interface of the inverter and that worked fine.

No output with js or json.

Hello,

I have two onmik convertors in my house. The newest convertor is working perfectly and the oldest one has an issue. After I run the javascript I have to log in and after the logging in nothing happens. I get only Access Error: Site or Page Not Found. Can you assist me with this. With json I don't have to login but the result is the same.

Regards,

Peter

Weird behavior when reading from two inverters

I have two inverters that I read using:

# Omnik Inverter 3k
  - platform: omnik_inverter
    host: 192.168.1.248
# Omnik Inverter 1.5K
  - platform: omnik_inverter
    host: 192.168.1.249

HA creates unique ID's, for example 'sensor.solar_power_today' and 'sensor.solar_power_today_2'. Yet, the data showed for 'sensor.solar_power_today_2' is the same as 'sensor.solar_power_today'. I know for a fact this amount should be very different.

The odd thing is that it only happens with 'sensor.solar_power_today'.

'sensor.solar_power_total(_2)' and 'sensor.solar_power_current(_2)' are showing their correct values per inverter. Perhaps this is just luck?

I read in a different issue that the ID's are not pre-defined, but created dynamically when the inverter becomes online. Could this cause this issue when reading from >1 inverters with this plugin?

Can't add Omnik omnisol 1.5k-TL

I can't seem to add the omnisol1.5k-TL, none of the protocols seems to work, none of the test links for checking the status seem to work either. I'm submitting my data to solarman smart, so there is data to be found somewhere. Is my inverter of 2013, too old?

Detailed description

Context

Diagnostics

"Copy here the code or upload the file"

Not loading Entities

Hello,

I"ve added via HACS, afterwards added below in the configuration.

sensor:
    - platform: omnik_inverter
      host: 192.168.1.114

Omnik folder is present in custom_components,how ever no Omnik solar entities showing up.

Best Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.