Important: to save you time, make sure your inverter has a “status.html” page with these lines:
var webdata_now_p = “xxx”;
var webdata_today_e = “x.xx”;
var webdata_total_e = “xxx.x”;
The ‘x’ are your values. The script won’t work if that does not exist and, unfortunately, there seem to be many versions of that firmware. Back to the original post:
Hi,
this is a solution to get current power, daily & total yield from a Solis S6-GR1P type inverter with a wireless stick.
There is no need for a cloud with this setup.
What you need: the inverter with Wifi stick, the IP of the stick and your login information. Appdaemon with the requests module installed.
The script is pretty straightforward and not very elegant. It will run every minute, log into the inverter, get the “status.html” page and filter the three values from it. They will be stored in “sensor.solis_current_power”, “sensor.solis_energy_today” & “sensor.solis_total_energy” and can be accessed by HA as usual.
In the script, you need to change the IP address and the login info.
The script only does anything when the sun is up. It will write the values into the log and also if it fails to reach the inverter.
import appdaemon.plugins.hass.hassapi as hass
import requests
from requests.auth import HTTPBasicAuth
#
# scrape the inverters web page
#
# Args:
#
class SolisScrape(hass.Hass):
def initialize(self):
self.log("Solis scrape started")
self.run_in(self.update, 0)
# update every minute
self.run_every(self.update, "now", 60)
def update(self, kwargs):
if self.sun_up(): # no sun, no fun
# get the status page
URL = "http://192.168.0.111/status.html"
try:
page = requests.get(URL, auth = HTTPBasicAuth('admin', 'admin'))
# split it
liste = page.text.split()
# check were the interesting data is
now_p_index = liste.index('webdata_now_p')
today_e_index = liste.index('webdata_today_e')
total_e_index = liste.index('webdata_total_e')
# the values are always two indices behind, snip off excess "" & ;
current_power = float(liste[now_p_index+2][1:-2])
energy_today = float(liste[today_e_index+2][1:-2])
total_energy = float(liste[total_e_index+2][1:-2])
# Build the HA sensor entity with the values returned
entity = "sensor.solis_current_power"
self.set_state(entity, state = current_power)
entity = "sensor.solis_energy_today"
self.set_state(entity, state = energy_today)
entity = "sensor.solis_total_energy"
self.set_state(entity, state = total_energy)
logstring = f"Solis: Current: {current_power}W Today: {energy_today}kWh Total: {total_energy}kWh"
self.log(logstring)
except:
self.log("Failed to reach inverter") # do nothing
else: # no sun, no power
entity = "sensor.solis_current_power"
self.set_state(entity, state = 0)
Save it as “solisscrape.py”. Put this in your Apps.yaml:
solis_scrape:
module: solisscrape
class: SolisScrape
That should be it.