Collect Inverter data from Solarman API

Good morning i’m in step
curl --request POST \

–url 'https://api.solarmanpv.com/device/v1.0/currentData?appId=&language=

–header 'Authorization: bearer ’ \

–header ‘Content-Type: application/json’ \

–data '{

“deviceSn”: “”

}’
I put my appId, my accessToken and my deviceSerial, but I always get a window that says

Submit

×

Please enter a correct Curl command and try again.

Error: Unmatched quote

What can I do wrong, can you help me. Thanks

Ya lo he solucionado.

I got to adding the JSON Path Finder file to configuration.yaml:

Pasting it into the configuration.yaml file gives me this error:

Failed to call service homeassistant/restart. The system cannot restart because the configuration is not valid: Platform error calendar.rest - No module named ‘homeassistant.components.rest.calendar’

When I change it to this (add Solarman:):

it gives me another error when restarting:

Failed to call service homeassistant/restart. The system cannot restart because the configuration is not valid: Integration error: solarman - Integration ‘solarman’ not found.

What am I missing?

Solve it with this example:

sensor:
  - platform: rest
    etc.

Thanks a lot! I added this sensor to my other sensors, and this fixed the error. Now waiting for value-input from the API.

Hi,

I haven’t been around so haven’t been able to respond to questions sorry.

My sensors stopped working this weekend, I suspect this is due to not using the refresh token. Does anyone who has already used this guide understand refresh tokens? At the moment we will all need to generate new tokens but it would be better if I can work out how to do it automatically.

Hi,

Indeed, I had the same that the token was expired. Now I am trying to make it work with this project below, so you don’t have to care about the token refresh. I have it partially working with the docker container.

Hello @lechk82

Many thanks for sharing your project. I am experimenting with your docker image and retrieve data. The container log shows:
INFO:root:2021-12-13 21:25:37 - 1.0 kWH day total and currently 0.0 W
etc… but no errors

The MQTT explorer shows only:
solar/energy
solar/power

I was expecting to see more topics.

  • Do you have any idea`s what could cause this?
  • Where can I see more log information? I did also enable debug in config.json but don`t know where to look for those logs.

It’s working! Turns out I forgot to add my token to the Rest Sensor.

Can I combine the code for 2 sensors?

### Solarman ###
  - platform: rest
    resource: https://api.solarmanpv.com/device/v1.0/currentData?appId=xxxxxxx&language=en&=
    method: POST
    name: "Total AC Output Power"
    scan_interval: 3600
    headers:
     Authorization: bearer xxxxxxx
     Content-Type: application/json
    payload: '{  "deviceSn": "xxxxxxx"}'
    value_template: "{{ value_json.dataList[14].value }}"
  - platform: rest
    resource: https://api.solarmanpv.com/device/v1.0/currentData?appId=xxxxxxx&language=en&=
    method: POST
    name: "Cumulative Production kWh"
    scan_interval: 3600
    headers:
     Authorization: bearer xxxxxxx
     Content-Type: application/json
    payload: '{  "deviceSn": "xxxxxxx"}'
    value_template: "{{ value_json.dataList[16].value }}"

Hi people.

I’m new to these forum.

I don’t understand where I can get my appSecret.

Someone can help me.

Thanks

Hi Alexandre, you have to email [email protected] and ask for API access. They will send you the app_id and the app_secret.

1 Like

Thanks…

I’ve already sent an email…
I will wait for the answer

Thanks

Trying to use this project but keep getting an error when spinning up the Docker container

“ERROR:root:Error on start: ‘dataList’”

Any ideas @trialanderror or @lechk82

Thanks in advance for the help

@Damian_Nelson, after spending much time trying to make the docker container working I gave up. I use the python script instead and this works perfect!

UPDATE: Found that the docker container also works perfect. I tested it with the exact settings as described in github project page.

1 Like

I added a datalist check since it appears to be sometimes unpopulated by the solarman api.

What architecture (x64? arm?) are you trying to run the docker image on? the base image currently does not support arm

EDIT:
Docker Image now available for platforms: linux/amd64 linux/arm/v7 linux/arm64
(Tested on odroidn2+ (arm64) and PC (linux/amd64)

Could you please post the whole output with debug enabled.

Thank you skully for this guide. Quite new with HA, but your guide put me through!
Probably 1 stupid question from my side but I have a feeling I am almost there!
At step 6. Everything is in the configuration.yaml file, but i do not know what I should put behind 'bearer ’
If I fill in the huge “Access token” I get the following message while Validating the configuration.

Invalid config for [sensor.rest]: expected a dictionary for dictionary value @ data[‘headers’]. Got None
extra keys not allowed @ data[‘Authorization’]. Got 'bearer example
extra keys not allowed @ data[‘Content-Type’]. Got ‘application/json’. (See ?, line ?).

What Do I do wrong?

I have a separate sensor.yaml file with the following entry:

### Solarman ###
  - platform: rest
    resource: https://api.solarmanpv.com/device/v1.0/currentData?appId= 'xxxxxxxxxxxxx'&language=en&=
    method: POST
    name: "Total AC Output Power"
    scan_interval: 3600
    headers:
     Authorization: bearer 'the huge Access token'
     Content-Type: application/json
    payload: '{  "deviceSn": "TGL4000Nxxxxxxxx"}'
    value_template: "{{ value_json.dataList[14].value | round(0) }}"
  - platform: rest
    resource: https://api.solarmanpv.com/device/v1.0/currentData?appId='xxxxxxxxxxxxx'&language=en&=
    method: POST
    name: "Cumulative Production kWh"
    scan_interval: 3600
    headers:
     Authorization: bearer 'the huge Access token'
     Content-Type: application/json
    payload: '{  "deviceSn": "TGL4000Nxxxxxxxx"}'
    value_template: "{{ value_json.dataList[16].value | round(0) }}"

That works fine.

Screen Shot 2021-12-28 at 12.03.09