Collect Inverter data from Solarman API

Hi Atitej, that’s exactly what I was looking for as well. The other explained solution above is great but is not taking the expiration of the token in account. I have been looking to the AppDeamon integration to get python support. Being still too fresh in Home Assistant, I still need to find my way.
Nevertheless, I have also found: GitHub - lechk82/solarman-mqtt: Send Solarman Smart PV platform metrics (W/kWh) to MQTT which looks to be a solution as well

Hello All.

I managed to setup Solarman via API, is working but still is using the cloud, I am not a big fan of cloud services.
I found a way to obtain data from the logger via a curl command:

curl -s -u admin:admin http://10.0.0.70/status.html | grep -E "\webdata_now_p(\s|$)" | cut -d'"' -f 2

And if you want to get all the data from the logger here are the variables you need to grep:

</script>\r\n<script type="text/javascript">\r\
nvar webdata_sn = "I0120C007166";\r\
nvar webdata_msvn = "V2.41.76";\r\
nvar webdata_ssvn = "V2.41.76";\r\
nvar webdata_pv_type = "";\r\
nvar webdata_rate_p = "";\r\
nvar webdata_now_p = "1175";\r\
nvar webdata_today_e = "9.92";\r\
nvar webdata_total_e = "108.3";\r\
nvar webdata_alarm = "";\r\
nvar webdata_utime = "0";\r\
nvar cover_mid = "1753292631";\r\
nvar cover_ver = "LSW3_14_8401_1.17";\r\
nvar cover_wmode = "APSTA";\r\
nvar cover_ap_ssid = "AP_1753292631";\r\
nvar cover_ap_ip = "10.10.100.254";\r\
nvar cover_ap_mac = "30:EA:E7:36:5F:0C";\r\
nvar cover_sta_ssid = "Home";\r\
nvar cover_sta_rssi = "100%";\r\
nvar cover_sta_ip = "10.0.0.70";\r\
nvar cover_sta_mac = "34:EA:E7:36:5F:0C";\r\
nvar status_a = "1";\r\
nvar status_b = "0";\r\
nvar status_c = "0";\r\n\r\

Is any way to create a sensor using curl and add this data to HA.

5 Likes

Was so simple:

  - platform: command_line  
    command: curl -s -u admin:admin http://10.0.0.70/status.html | grep -E "\webdata_now_p(\s|$)" | cut -d'"' -f 2
    name: power_solar
    unit_of_measurement: 'W'
    scan_interval: 10
  - platform: command_line  
    command: curl -s -u admin:admin http://10.0.0.70/status.html | grep -E "\webdata_total_e(\s|$)" | cut -d'"' -f 2
    name: power_solar_total
    unit_of_measurement: 'kWh'
    scan_interval: 60
  - platform: command_line  
    command: curl -s -u admin:admin http://10.0.0.70/status.html | grep -E "\webdata_today_e(\s|$)" | cut -d'"' -f 2
    name: power_solar_today
    unit_of_measurement: 'kWh'
    scan_interval: 60
6 Likes

Just use quotation marks around stationId and inverterId like “stationId”: “1******”

Can someone help me please. I modified configuration.yaml as shown on the top of this tread:

Solarman API

sensor:
  - platform: rest
    resource: https://api.solarmanpv.com/account/v1.0/token?appId=xxxxxxxxxxxxx&language=en&=
    method: POST
    name: "Total AC Output Power (Active)"
    scan_interval: 60
    headers:
      Authorization: Bearer xxxxxxxxxxxxx
      Content-Type: application/json
    payload: '{"deviceSn":"SF4xxxxxxxx"}'
    value_template: "{{ value_json.dataList[20].value }}"

I know that my credentials and the data of the inverter are OK, getting proper json information on JSON Path Finder

But in the HA entity I see no data, just “Unknown”:
image

What am I doing wrong?

Awesome; this indeed prevents to need to get (and update) the access token and gives a much higher update frequency of the sensor data (even faster than shown directly at solarman.com). LIKE!

Is this last_reset updated?

Hello all,

After I managed to get the information from the logger directly I have another problem.

The energy dashboard has an issue when is showing the solar consumed energy , but the problem is very strange, energy dashboard is showing much bigger values for solar consumed energy but only for the 08:00 to 09:00 hour and from 09:00 to 10:00.

For example:
30.03.2022


29.03.2022

28.09.2022

In grafana I have the correct values:

30.03.2022

also the value is almost the same on PV cloud:

Dos some one have this issue? Or some one have any idea where is the problem.

  - platform: command_line  
    command: curl -s -u admin:admin http://10.0.0.50/status.html | grep -E "\webdata_today_e(\s|$)" | cut -d'"' -f 2
    name: solar_energy_today
    unit_of_measurement: 'kWh'
    scan_interval: 60

template:
  - sensor:
    - name: "energy_production_today"
      state: "{{ states('sensor.solar_energy_today')}}"
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: "kWh"

1 Like

Hi, great idea!
I have accessed from my local network and I can see the data of the inverter but all the values related to consumption appear at 0 W.
From the Solarman API I can get the data correctly but with some delay, that’s why I wanted to access it locally.
Does anyone know why the values don’t appear?

Anyone collected station historical data? item 4.3 from solarman API guide.
I’m interested in irradiation information.

This worked perfectly fine with me, Thanks :+1:

Hi there,

You can solve this issue by using the total solar power. For now this is the most reliable way for cumulative value.

This is my config

configuration.yaml

  - platform: command_line  

    command: curl -s -u admin:admin http://*****/status.html | grep -E "\webdata_now_p(\s|$)" | cut -d'"' -f 2

    name: solarmanlocal_power_solar

    unit_of_measurement: 'W'

    scan_interval: 10

  - platform: command_line  

    command: curl -s -u admin:admin http://******/status.html | grep -E "\webdata_total_e(\s|$)" | cut -d'"' -f 2

    name: solarmanlocal_power_solar_total

    unit_of_measurement: 'kWh'

    scan_interval: 60

  - platform: command_line  

    command: curl -s -u admin:admin http://*****/status.html | grep -E "\webdata_today_e(\s|$)" | cut -d'"' -f 2

    name: solarmanlocal_power_solar_today

    unit_of_measurement: 'kWh'

    scan_interval: 60

template.yaml

- sensor:

## Solarman local logger

  - name: "solarmanlocal_production_daily"
    state: "{{ states('sensor.solarmanlocal_power_solar_total')}}"
    unit_of_measurement: kWh
    device_class: energy
    state_class: total_increasing
    unique_id:  solarmanlocal_production_daily

Next restart home assistant and choose solarmanlocal_production_daily as the desired meter for solardashboard.

2 Likes

I think it is still not working properly, indeed between specific time the value is higher than expected…

Hi there, got it working now! Please refer to my previous config!

I dont know if its a difference between Solarman and Trannergy or just me, but I couldn’t get the status.html working for my Trannergy Inverter. I did however found the /js/status.js script which contains also the (raw) values. I have the feeling it can be done nicer, but this is what I got it to work with on my Trannergy Inverter:
Current Power (in W):

curl -s http://x.x.x.x/js/status.js | grep -o '<Inverter serial number>.*\";' | cut -d',' -f 6

Yield today (in kWh):

echo "scale=2; $(curl -s http://x.x.x.x/js/status.js | grep -o '<Inverter serial number>.*\";' | cut -d',' -f 7)/100" | bc

Needed to divide the value by 100 and include 2 decimals to get it correct from the raw value.

Total yield (in kWh):

echo "scale=1; $(curl -s http://x.x.x.x/js/status.js | grep -o '<Inverter serial number>.*\";' | cut -d',' -f 8)/10" | bc

Needed to divide the value by 10 and include 1 decimal to get it correct from the raw value.

Also notice that you don’t need to authenticate to access the js file.

2 Likes

Hello.

My configuration still doesn’t work…I still have the initial configuration, where it was working fine…

Now what do I need to change to get the values ​​back?

Thanks
Alexandre Oiveira

So after a lot of fiddling I managed to get the Solarman-MQTT script working and sending data from my inverter to HA. I have, however, fallen at the last hurdle - I cannot work out how to use the sensor data in the Energy dashboard!

I have one station with 2 inverters - a main hybrid inverter with battery and a smaller second inverter. The station reports total power and grid power, but if I am using solar alone the grid power value is unavailable, and value can be negative (e.g. battery discharge).

Can anyone post an example of a working setup using the values from the API in the energy dashboard? Which sensors do you use, and are any templates required to get the data into the correct format? Thanks!

1 Like

Hello people.

Is anyone able to generate the token? I’m not getting it anymore, has anything changed? Did I miss something? I’ve been getting this message: “msg”: “appId insufficient allowance”.
If anyone has any tips I would appreciate it.

Hi, Yes had the same issue. You should e-mail solarman with this exact message. They can and will increase your allowance.

I switched however to the integration from Solarman and now I don’t have to use MQTT anymore.

What integration you are using now?