I thought I’d have another bash at extracting data directly from my Solis 4G Inverter
as I hadn’t had a go in ages and I like to think my skills with Home Assistant have improved SLIGHTLY
So I’ve one again tried just about every method mentioned on this thread and they all seem to have the same sticking point
One example here from Node-Red
Node-Red reports “TypeError: Cannot read properties of null (reading ‘1’)”
It gives this error for all 3 of the grab nodes
This is an entry from 1 of the grab nodes which pretty much maches the info I get if I log into the inverter from my web browser then select “inspect”
var parts = msg.payload.match(/webdata_now_p\s=\s"(\d+)"/); msg.payload = { value: parts[1], }; return msg;
I can log into the inverter via its web address
I have the HACS “Ginlong Solis PV portal integration” working Ok but I don’t like relying on a cloud and it only reports about every 6 minutes which I dont like
I’ve also tried severl different REST sensor methods in my config.yaml without success
Can anyone offer any assistance with this issue please
I became so frustrated with the woeful Solis website & instructions etc that I just bought a Shelly EM c/w a CT sensor and use that to measure generation. Potentially less accurate, but at least it works!
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.
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!):
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)
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.
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 = ??
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
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
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:
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