Solar PV intregration

I have followed this thread and failed. But had instant success with
[GitHub - hultenvp/solis-sensor: HomeAssistant integration for the Ginlong Solis PV Monitoring portal. This integration supports the current Platform v2.0 portal (m.ginlong.com) which supports Solis and Solarman PV inverter brands. Also supports new SolisCloud platform]
github.com
https://github.com/hultenvp/solis-sensor
The github site has instructions on how to install. Thank you hultenvp.

It also worked for me. After trying a lot I found this post and it is working now.
image

Hi

I installed this today but I donā€™t get any sensors coming upā€¦how do I fix it?

@lknop

Thanks for this, as a noob to home assistantā€¦this is exactly what I needed and works really well!

I did try for around a day to get various other options working, however there is nothing simpler than your example which just requires adding a few lines of code to your config, job done!

I installed my Solis data logger today and thus ended up reading through all of this. I then found that my Web UI is entirely different again, and the code for configuration.yaml doesnā€™t work. The reason is that the new status.html response has the variable declarations as the code snippets looked for but the values are no longer set there, those declarations draw from an array that must be populated somewhereā€¦anyway simple answer is that I discovered that the data is now exposed through inverter.cgi directly rather than scraping status.html. Much easier.

inverter.cgi responds with (xxx masking some of my serial number as Solis use that as their UID!):

060Exxxxxxxxxxxx;3D0023;E5;35.8;250;5.100000;d;NO;

And as such I now used the much simpler code:


sensor:
  - platform: rest
    resource: http://192.168.1.246/inverter.cgi
    authentication: basic
    username: admin
    password: xxxxx
    timeout: 2
    unit_of_measurement: "W"
    state_class: measurement
    value_template: '{% if value|length < 25 %} {% set value = "0;0;0;0;0;0" %} {% endif %} {{ value.split(";")[4] }}'
    device_class: energy
    name: Solis PV Now
  - platform: rest
    resource: http://192.168.1.246/inverter.cgi
    authentication: basic
    username: admin
    password: xxxxxx
    timeout: 2
    unit_of_measurement: "kWh"
    state_class: total_increasing
    value_template: '{% if value|length < 25 %} {% set value = "0;0;0;0;0;0" %} {% endif %} {{ value.split(";")[5] }}'
    device_class: energy
    name: Solis PV Today
    scan_interval: 300

(edit: I realised that without state_class you canā€™t then use the data in the energy dashboards so added it. Note I have used total_increasing rather than total for the day value as I find my logger reports 0 sometimes. I might change it back to total if I find that the next non zero figure is huge as it means there is a bug in the portal. I might even exclude the sensor eventuallyā€¦ymmv)

(edit 2: this is driving me mad as the logger is just all over the place so i might have to suck it up and use the solis cloud integration instead, but Iā€™ll leave this here in case anyone can make it work for them). But I just found I canā€™t as SOlis cloud is not currently allowing new API keys to be made ā€¦ grr

(edit 3 updated the code here rather than having outdated copies, see post below)

1 Like

Right, having fought to understand what on earth is happening, it dawned on me that an early post talked about the need for a proxy when the inverter is off. Its a rainy day and my inverter kept turning off while I was testing it! This also resets the daily yield counter, stupidly, and hence I use the state_class total_increasing which allows for 0 resets and only considers increments to counters as change.

Furthermore I also discovered that when you set the stick up for the first time the password by default is 123456789 but when you reboot it (or, more fundamentally, the inverter turns off due to lack of sun then turns on again) the password changes to the password for the wifi network.

So I have edited the code above to include some Jinja code in the value template to fix when the response is incorrect, forcing the returned value to be 0, otherwise when the inverter is off HA shows the last received value instead of 0, skewing lots of usage calcs in the interim. It checks the response and if its less tan 25 characters long (a valid response is always more as the serial alone is 16 chars) then it replaces the variable with 0s separated by semicolons, thus meaning the resulting return call of value[4] or value[5] both return 0.

I have also updated the device class to energy so its accepted by the energy dashboard.

There is one last issue which is if HA reboots while the inverter is off, the sensor is not included in HA until the rest connection has at least one successful connection to the server. I donā€™t know what it will do tonight when the inverter turns off but I am hoping it returns 0.

1 Like

Did you manage to find a solution to your ā€œone last issueā€ Chris?
Iā€™ve set my Mam & Dads system up using your solution as all others wouldnā€™t work with the latest Solis WiFi Stick (I have older sticks on my 3 systems so have managed other ways)
As you had pointed out, if HA is restarted during sundown the entities do not show until the inverter next powers up. I have no idea how to rectify this
I was also interested to see was other data was there so tried adding additional entries
0 = Inverter Serial Number
1 = Inverter Version
2 = Inverter Model
3 = Inverter Temperature
4 = Power Now
5 = Yield Today
6 = Total Yield
7 = ??

How can I divide number 5 by 10 in the yaml line

Sorry wasnā€™t watching for replies

Iā€™m on my phone so I canā€™t test the code but to divide by 5 you probably need to just add /10 after the [5]

I havenā€™t fixed the other issue no, I have another question open that hasnā€™t been responded to yet. The code as is handled some error conditions but doesnā€™t set that last 0 we want when unavailable

Chris

1 Like

OK, cheers Chris. Iā€™ll try a bit more research and testing myself but unfortunately Iā€™m pretty crap at it
Iā€™ve also been using an appdaemon addon to scrape 2 of my inverters (I have 5, 3 Solis & 2 Samil Power)
that have a fairly recent version of the Solis Data logging WiFi stick (but not the very latest) that utilizes ā€œ/status.htmlā€ could that be modified to utilize the ā€œ/inverter.cgiā€ for the most current sticks or could the code that deals with NO SUN be adapted for your system?

else:   # no sun, no power
            entity = "sensor.solis_appdaemon_1_current_power"
            self.set_state(entity, state = 0)    

Brilliant, thanks so much for posting this. Not sure why Solis have made it so difficult for people to get their own solar production data. This solution worked perfectly for me, and the tip in one of your other posts about the password for the data logging stickā€™s admin page being set to the same as the wifi network password was a godsend - I donā€™t think Iā€™d have ever got round to guessing that!

Yeah I need to have a play. On another thread templates seem to be an answer. I have been flat out for a few weeks but once I get some downtime I want to fix this so Iā€™ll post what I learn

Hi,
have anybody already tried to contact Modbus TCP Interface on Port 8899 from Solis key ?
Iā€™m totally new with HomeAssistant, but in iobroker Iā€™ve managed to fetch already a few parameter of the interface by contacting certain Modbus addresses.

I know, with the newly available solisCloud API there is maybe an easier way to fetch the data from the cloudā€¦ But for a local solution, the modbus server is maybe the better way :slight_smile:

But unfortunatly, Iā€™ve no experiance now how to use modbus adapter in Home Assistent. Iā€™ve tried already to extend my configuration.yaml by adding these lines:
modbus:

  • type: tcp
    name: ā€œSolisā€
    close_comm_on_error: true
    delay: 5
    timeout: 5
    host: 192.168.3.238
    port: 8899

But this didnā€™t create any adapter on the interface, where I maybe can just add a few modbus addresses.

Maybe somebody else is now motivated to do further investigation together to create a nice solution.
Thanks

Method works fine, display correctly in HA GUI but I see errors in logs, any clue what could it be?:

Logger: homeassistant.helpers.entity
Source: helpers/template.py:1834
First occurred: 13:15:37 (9 occurrences)
Last logged: 13:18:37

    Update for sensor.panels_current_power fails
    Update for sensor.panels_energy_today fails
    Update for sensor.panels_total_production fails

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update
    raise exc
  File "/usr/src/homeassistant/homeassistant/components/rest/entity.py", line 63, in async_update
    self._update_from_rest_data()
  File "/usr/src/homeassistant/homeassistant/components/rest/sensor.py", line 173, in _update_from_rest_data
    value = self._value_template.async_render_with_possible_json_value(
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 625, in async_render_with_possible_json_value
    return _render_with_context(self.template, compiled, **variables).strip()
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2007, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1834, in regex_findall_index
    return regex_findall(value, find, ignorecase)[index]
IndexError: list index out of range

Anybody tried to fetch real time data using http interface? Seems like numbers on inverter.cgi are updated every 5 minutes or so.