How to access rest-api of a photovoltaic system (documented)?

Hi everybody, hope to find some help!
I recently got a photovoltaic system installed, which can be accessed by rest-api. But I have no clue how to do that…
I have a documentation to that api, with an example for iobroker only; can be found at
So I wonder if anyone can help me setup access to my installation!?

Hi @svenkoeck
Home Assistant provides a RESTful Sensor based on a RESTful integration.
You’ll find everything in those 2 links.

Looking at your documentation, I believe that you’ll find this topic very useful too but be careful that this is a quite old post and it is forcing a restart of Home Assistant every 10 hours to get a new token.

Maybe you can get around that restart constraint with a text helper holding your token.

Ok, I was bored somehow so I read the full doc.

Here is a rest sensor that should work but not tested, based on the ioBroker exemple of the documentation.

In configuration.yaml

  - platform: command_line
    name: Hycube token
    scan_interval: 3600
    command: >
      curl -H "Authorization: Basic hycube:hycube"

  - header: "Bearer: {{ states('sensor.hycube_token') }}"
    scan_interval: 5
      - name: "Current Values"
        json_attributes_path: "$.response.system"
        value_template: "OK"
          - "Battery_C "
          - "Battery_I"
          - "Battery_P"
          - "Battery_V"
          - "Grid_f"
          - "Grid_P"
          - "Grid_V"
          - "Home_P"
          - "Inv 1_I"
          - "Inv 1_P"
          - "Inv 1_V"
          - "Solar 1_P"
          - "Solar 1_I"
          - "Solar 1_V"
          - "solar 2_P"
          - "solar 2_I"
          - "solar 2_V"
          - "solar_total_P"

Hi Olivier,
thank you for your effort and support!
I tried your code and get the following error:
“Invalid config for [rest]: [header] is an invalid option for [rest]. Check: rest->rest->0->header. (See /config/configuration.yaml, line 388).”
What’s wrong?
I really apppreciate your help!
Best regards

headers list | template (optional)
The headers for the requests.

Missed the “s”
Does the token works? This part

  - platform: command_line

“headers list | template (optional)
The headers for the requests.”

What do you mean with this? I can’t follow… what “s” is missing? And where?

I don’t have the sensor added in my configuration.yaml but in sensors.yaml, so I assume, that file isn’t checked, yet…

  - headers: "Bearer: {{ states('sensor.hycube_token') }}"

check if that sensor is in your development interface (Development tools > States)

results in:

Invalid config for [rest]: expected a dictionary for dictionary value @ data[‘rest’][0][‘headers’]. Got “Bearer: {{ states(‘sensor.hycube_token’) }}”. (See /config/configuration.yaml, line 388).

But: the sensor seems to be working --> “OK”

Yes, it is a list, sh*t

  - scan_interval: 5
      Authorization: "Bearer: {{ states('sensor.hycube_token') }}"

… restarting…

Keep in mind that I did that “in the air”, not tested, no way to test it, be ready to face some issues related to the way the specific rest api is working for your panels.

Restarted. How should the values be accessible? What are the entities? I only have “sensor.hycube” and there’s “ok” shown…

Then the sensor is already wrong, it should contain the token
Do you have a command prompt where you can do the curl and post the full reply?

Sorry, no! :frowning:
At least not actually. The company, HyCube, has offered to find a solution next year… :roll_eyes:

I guess, the API is not accessed. I can enter http://IP_ADDR/auth/ and get a login window, but no access, as the credentials seem not to work…

It must be the IP address of your installation, the IP of the inverter probably.
Something from your local network.
Or you’ll have to replace the hycube:hycube by your official credentials if it is cloud based

Hi Oliver,
I can access the web interface of my pv system’s server, but I’m pretty sure the credentials are wrong respectively the needed user does not exist, yet… I’ll come back to you, as soon as the manufacturer has contacted me!
Best regards and thank you deeply for your efforts!

Hi Sven,

“Basic hycube:hycube” must be encoded as a Base64-encoded ASCII string from a string.
HA does not do this automatically, so you get Unathorized.
For example, in javascript, the btoa() method creates a Base64-encoded ASCII string from a binary string: " Authorization " : btoa ( " Basic " + user + " : " +password )

If you want to generate a token with HA, you must:
1- Create a base-64 encoded string from “Basic hycube:hycube”. results: “QmFzaWMgaHljdWJlOmh5Y3ViZQ==”
2- In the headers, add the key " Authorisation " and specify as key: " QmFzaWMgaHljdWJlOmh5Y3ViZQ== ".

A YAML example configuration will look like this:

#Hycube configuration

  - platform: command_line
    name: Hycube Token
    scan_interval: 36000
    command: "curl --request GET 'http://your_ip/auth/' --header 'Authorization: QmFzaWMgaHljdWJlOmh5Y3ViZQ=='"
  - platform: rest
    scan_interval: 5
      Authorization : "{{ states('sensor.hycube_token') }}"
      Accept: application/vnd.github.v3+json
      Content-Type: application/json
      User-Agent: Home Assistant REST sensor
    resource: http://your_ip/get_values/
    value_template: "Bla"
    name: "Hycube Data"
          - Battery_C
          - Battery_I
          - Battery_P
          - Battery_V
          - Grid_f
          - Grid_P
          - Grid_V
          - Home_P
          - Inv 1_I
          - Inv 1_P
          - Inv 1_V
          - Solar 1_P
          - Solar 1_I
          - Solar 1_V
          - solar 2_P
          - solar 2_I
          - solar 2_V
          - solar_total_P
  - platform: template
        value_template: "{{ state_attr('sensor.hycube_data', 'Battery_C') }}"
        device_class: battery

Please test first if you can generate a token in the command line with curl:curl --request GET 'http://your_ip/auth/' --header 'Authorization: QmFzaWMgaHljdWJlOmh5Y3ViZQ=='

Hi HycDev,
I can now access some data with your config… but way less than there are in your cloud.
What data (json_attributes) can also be accessed?
I appreciate your answer!
Best regards

New features and suggestions are always welcome. If you need more data, please feel free to contact us. I assume that your question has been answered for now, but if you have any further questions, please do not hesitate to contact us. Our team checks whether your use case makes sense and plans the integration in the next versions.

Hi @Olivier1974 ,
I’m a complete Noob with this. I tried to follow your instructions, but didn’t get any access.
But I’am receiving this error
“Diese Entität (“sensor.hycube_data”) hat keine eindeutige ID, daher können die Einstellungen nicht über die UI verwaltet werden. Schaue in der Dokumentation nach für mehr Details.”
Any hints?