Collect Inverter data from Solarman API

Hi, I have Deye 12 kW hybrid inverter and I have remote configuration permissions. I didn’t found any documentation for custom commands. I want to send custom commands with Solarman API.

1 Like

Hello I did everything exactly according to the instructions, but in the end I don’t see any entity. The URL to the API has changed, so it’s not the same as in the instructions. Do I need to enter anything else in a yaml other than just the configuration.yaml? Unfortunately, I’m an absolute newbie and my English isn’t the best either

I finally managed to configure it properly. Now I would like to get information about the annual and monthly production. Using Solarman API i find somthing like this:

curl --request POST \
  --url 'https://globalapi.solarmanpv.com/device/v1.0/historical?appId=xxxxxxxxxx&language=en&=' \
  --header 'Authorization: bearer <AUTH' \
  --header 'Content-Type: application/json' \
  --data '{
  "timeType": 4,
  "startTime": "2022",
  "endTime":"2022",
  "deviceSn": "TXXXXXXXXXX"
  }'

When I input correct date i recive annual production. My question: How to correctly enter an automatic date in configuration.yaml? Now i have

sensor
  - platform: rest
    resource: https://globalapi.solarmanpv.com/device/v1.0/historical?appId=xxxxxxxxx0&language=en&=
    method: POST
    name: "Year Production Nowy"
    unique_id: "solarman_energy_production_year"
    unit_of_measurement: 'kWh'
    device_class: energy
    state_class: measurement
    scan_interval: 3600
    headers:
     Authorization: bearer xxxxxxxxxxxxxxxxxxx
     Content-Type: application/json
    payload: '{   "timeType": 4, "startTime": "2022", "endTime":"2022", "deviceSn": "T6xxxxxxxxxx"}'
    value_template: "{{ value_json.paramDataList[0].dataList[0].value }}"

I know somthing like now().year but how use this in startTime?

Anyone has a little help on automation of the key rotation during expiration ? I saw the node red overview from @arneb could use a little hand. I got a Trannergy not interested in local API for now.

I am having some fun with chatgtp creating a bashscript for this. I now have a script to detect whether key is correct and renew if is not. Contains too much secrets but I will share it when finished.

That sounds interesting… I am still manually updating the key every 60 odd days…

Hi I am almost there. I now have the script that checks the key in configuration yaml on validity and then gives the option to renew.
Need to build a sed to change it in the configuration yaml itself. For now it only outputs the new key.

2 Likes

fu** i love you :partying_face:
I spent the last 2 weeks trying to make the first authentication via rest without success because the connection info of this thread was not updated, the link was wrong!
Now everything works
thanks for the tip!

curl --request POST \
  --url 'https://globalapi.solarmanpv.com/account/v1.0/token?appId=XXXXXXXXXXX&language=en&=' \
  --header 'Content-Type: application/json' \
  --data '{
	"appSecret": "XXXXXXXXXXXXXXXXXXXXXXXX",
	"email": "[email protected]",
	"password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}'
2 Likes

Anyone else’s stats go crazy today via the API? My battery SOC went to 0% then has steadily climbed to 2000%+ and now back to 0%… Looking on solarman app though, battery SOC is showing correctly?

1 Like

Yup. Same here. AC Voltage A was 4700V few hours ago :sweat_smile: I was shocked when received an alert about overvoltage this morning.
My 10 kwhp installation generated 7000kWh so far today according to the API. Crazy values

It looks like some of the values have “moved”, or they have added/removed something… for me “Total Charging Energy” and “SOC” have flipped… very strange,

Guys

Like lots of you here I battled with the API to get what I wanted and then wake up every now and then to find my sensors stopped working because of the API key.

Seriously. It’s not worth it. Took me 10% of the time I spent on this to setup a modbus connection instead.

I used a Waveshare RS485 to RJ45 Ethernet Converter Module (Amazon 27 GBP), an Exceedconn EC04681-2023-BF (another tenner on ebay for my rebadged k-star inverter) and soldered up a splitter cable to keep the solarman for now.
It just works. Any sample rate I want… it’s local…simpler… and I can write registers to change the mode into charging to pull cheap power overnight on poor forecast days.
(Credit to k-star support who responded with their rs485 manual in under an hour by the way)

Respect the original poster and everyone who’s got their heads round the solarman API method. But my word it’s a PITA and doesn’t work very well at best.

As the first post in this thread is never updated, and I am somewhat a newbie in this game, I had to fiddle quite a bit until I found out how to get this thing to work. Maybe I’m not alone in this regard, so I thought it would be nice to do a short sum up of what I did to collect my inverter data i HA.

  1. Your Solarman login password needs to be hashed using SHA256 Online.

  2. Paste the below code into “Run Curl Commands Online

  3. Change APIID, APKKEY, EMAIL and HASHEDSOLARMANPASSWORD to your personal values, and click “Run”:

curl --request POST \
  --url 'https://globalapi.solarmanpv.com/account/v1.0/token?appId=APIID&language=en&=' \
  --header 'Content-Type: application/json' \
  --data '{
	"appSecret": "APKKEY",
	"email": "EMAIL",
	"password": "HASHEDSOLARMANPASSWORD"
}'
  1. Copy the access token from the resulting code, and paste it into the below code.

  2. Change APIID, ACCESSTOKEN and SERIALNUMBER to your personal values). Paste the adjusted code into Run Curl Commands Online and hit “Run”.

curl --request POST \
  --url 'https://globalapi.solarmanpv.com/device/v1.0/currentData?appId=APIID&language=en&=' \
  --header 'Authorization: bearer ACCESSTOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
  "deviceSn": "SERIALNUMBER"
  }'
  1. The resulting code is to be pasted into JSON Path Finder.

  2. To get the correct sensor reading, find the appropriate value_json. In my example I’m looking at Cumulative Production (Active)

To make the sensors in Home Assistant, place the below code into configuration.yaml. Change the sensor name, unique_id, and number of dataList (in my case 29) to the appropriate name/number for what you want the sensor show in Home Assistant:

sensor:
  - platform: rest
    resource: https://globalapi.solarmanpv.com/device/v1.0/currentData?appId=APIID&language=en&=
    method: POST
    name: "Cumulative production"
    scan_interval: 3600
    unique_id: cumulative_production
    unit_of_measurement: "kWh"
    headers:
      Authorization: bearer ACCESSTOKEN
      Content-Type: application/json
    payload: '{"deviceSn": "SERIALNUMBER"}'
    value_template: "{{ value_json.dataList[29].value }}"
2 Likes

Could you detail it a bit more what you did? Especially the Exceedconn connector i’m not sure what it’s used for.

The connector is just to match the rs485 interface on my inverter that the solarman plugs into. These solerman data loggers seem to come in a whole bunch of variants with different sockets to suit a whole bunch of inverters. And bugger all documentation I could find. I got lucky and noticed my landroid mower had the same type. Without that I was lost hunting round AliExpress and electronics suppliers… and using not very satisfactory crocodile clips. On the interface I have the rs485 A and B were pins 3 and 4. Your installer manual may tell you or you can work it out with a multimeter.

The modbus protocol allows daisy chaining of devices on A&B so long as there are 120 ohm resistors between A&B.

The waveshare converter is just a modbus RTU to TCP ethernet converter. It allows reading of all the information your solarman dongle is reading, plus more, over a networkby TCP. HA modbus doesn’t mind whether setup directly connected (RTU) or network (TCP).

You’ve got to get your hands on the rs485 protocol for your inverter. My inverter settings told me it was using slave address 1 and baud 9600… but you need to know stopbits, parity, flow control the register map for the inverter. If not published somewhere on the web for your inverter then you’ll have to appeal to the tech support for your inverter manufacturer. Mine is badged as Raleigh Instruments but the model number is clearly k-star so I went to them. Inverters have modes for charging and settings for charge/discharge profiles which I guess they meant to be usable… but can’t easily with the things in the roof space and no remote control (solarman)… so I can’t imagine why they wouldn’t be helpful. The solarman system could do so much more, including proper local data, but I’ve concluded it’s basically just crap.

The setup’s pretty straight forward once you’ve plugged in the waveshare, connected it to your network and got the rs485 protocol to hand for your inverter. I tested reading the registers (eg for battery soc, panel generation power, system mode states) using qmodMaster (free, you’ll find on GitHub). The HA setup is fairly straight forward too once you’ve established the communication works. Just follow the documents for the modbus integration. Setup sensors for the data you want to collect and call service scripts from automatons to write register addresses to modify whatever settings. If you can navigate the nightmare solarman API manual for all it’s different calls then trust me, the modbus method is easy.

If my variable rate drops below a threshold and my battery’s low I charge it for later use.
My variable rate import charge rate went super negative yesterday so I charged up and then dumped back to grid on my fixed rate export. Thank you very much. Free money while I cooked Sunday lunch.

Sorry for hijacking the thread by the way. If there’s appetite perhaps I should go to the effort to put a separate thread out.

1 Like

Hi Dillgaf,
I also have two kstar inverters (KSTAR* H5 ESS) and although I managed to get the access token I can’t get any query to work with the solarman api.
I noticed that my inverter has the same connector as the RS486 adapter and I was wondering if you could share the Kstar manual with me…
did you get the modbus address map as well?
thanks

Sure… Seems I can’t attach pdfs here though. PM me and I’ll email it. It’s all in there… all the registers for all the settings available through the panel.

I seem to have reached the limit of k-star’s understanding of some of the settings for the parameters of the self consume mode though (I’d like to change the fraction of battery discharge to grid pull at different times of day and go more or less off-griddy). Bless 'em they try. Might start hassling Raleigh and see if they know what they’re talking about next.

1 Like

Thank you for this excellent guide. I now have my daily production trough the API.

Do you know if it is possible to have only have one request and get all values from all sensors? Don’t think it will be much appreciated to replicate this sensor 35 times.

1 Like

Something like this should work to pull down the whole data list to Attributes of one Sensor. (Need to fill in your own App ID, Bearer Token and Serial Number)
The use individual Template Sensors to split out Attributes into what you want to show in frontend.

 - platform: rest
   resource: https://globalapi.solarmanpv.com/device/v1.0/currentData?appId=XXXXXXXXX&language=en&=
   method: POST
   name: solarman_inverter_datalist
   scan_interval: 60
   headers:
     Authorization: bearer [Your Code] 
     Content-Type: application/json
   payload: '{  "deviceSn": "XXXXXXXX"}'
   json_attributes:
       - dataList
   value_template: 'OK'

If you search this thread for dataList there’s a few mentions of this approach…

Thanks, this does indeed have one sensor with all values, but I would like to have multiple sensors, but with one request to the backend. there are some values i’m just not interested in.