Solax REST (Hybrid Inverter) failing unauthorised?

Hi all
First help request post, months using HA (so newby). I’ve struggled for several weeks to configure the HA rest sensor to read our Wi-Fi connected (Wi-Fi built-in not a Wi-Fi dongle) Solax SK-TL5000E on my own having read many posts etc but my attempt always failing with ‘401 Unauthorized’ in logs.
Objective is to read Solar data from inverter locally (Lan connect).

I have installed and have working the Solax Power Integration. I wish to have local inverter LAN access (and learn how to do this) hence the REST attempts outlined here.

  1. Inverter is Solax Portal (not Cloud) connected and working fine ie can see read all data in Portal.

  2. I’ve tested, and can from PC, using curl commands, read and retrieve my data from Solax Portal. Accordingly I’ve discovered and retained my account Solax Cloud access ‘id’ and ‘token’. I don’t know if these are required / used when attempting HA Rest to inverter locally?

  3. I have direct access via web to the inverter web menu page.

  4. I can see and read the inverter data via web page eg: http://192.168.1.8/api/realTimeData.htm.

Problem - every variation of REST I’ve tried does NOT appear to access or retrieve the data from HA, the logs indicating (i think?) that the inverter is rejecting the rest request. Im guessing either my rest command is invalid or that I need to include some sort of authorisation as part of the rest request?

Example Log error:
‘’'2024-01-08 18:39:37.214 DEBUG (MainThread) [homeassistant.components.rest.data] Data fetched from resource:

Error

401 Unauthorized.

2024-01-08 18:39:37.214 WARNING (MainThread) [homeassistant.components.rest.util] REST result could not be parsed as JSON 2024-01-08 18:39:37.214 DEBUG (MainThread) [homeassistant.components.rest.util] Erroneous JSON: Error

401 Unauthorized.

'''

I’d be most appreciative for some guidance on my approach / questions above and happy to share my rest / config info if that’s required to assist me.
Thanks

So I’ve made some progress on this, but I’m now encountering issues in the data returned.

My configuration:

rest:
  - authentication: basic
    username: "admin"
    password: "admin"
    scan_interval: 60
    resource: http://192.168.0.123/api/realTimeData.htm # Replace with your IP
    sensor:
     - name: "Inverter 1 Current"
       value_template: "{{value_json['Data'][0]}}"
       unit_of_measurement: A
       device_class: current

With this configuration, the Inverter 1 Current sensor gets created but the value gets set to unknown. I assume the JSON converter is tripped up by the Data array having unset entries, i.e. many commas in a row.
Here’s an example of my data:

"Data":[8.0,8.1,289.1,283.5,17.9,245.0,4386,47,9.7,48538.2,0,2342,2318,,,,,,,,,,,,,,,,,,,,,,,,,,,,,0.00,0.00,,,,,,,,49.96,,,0.0,0.0,0,0.00,0,0,0,0.00,0,8,0,0,0.00,0,8]

I found some documentation of this data at solax-local-api-docs/Data1.txt at fe4d46346fb3936963e8c31ada53b870f0d73b61 · nazar-pc/solax-local-api-docs · GitHub so I can map the numbers to sensors but the JSON returned just isn’t valid.
It would be great if somebody knew how to massage this JSON into something a bit more usable, such as with templating?

I’ve still been playing around with the template for this.
To strip out all the commas I came up with this:

{% set clean = value|regex_replace(',{2,}',",") %}
{{clean}}

This produces a dict in Developer Tools with hardcoded input, but as soon as I attempt to access any data within, it says it’s a string and the method doesn’t exist.

Any help would be greatly appreciated :slight_smile:

did you manage to get this to work as I think you and I have the same issue…

I actually found the built-in Solax integration works for me. I’m unsure why it didn’t work when I initially tried it. That integration seems to have issues staying connected to my inverter (which I thought was a known issue, but I can’t confirm the Github issue), but reloading the integration works.

I’ll give it a shot… the power one connects but I thought it was running through the web api not locally?
Thank you

I went down this path too and it works well. Only issue (reported on GitHub) is when HA reboots the Solax Integration quite regularly fails to complete startup, but since I’m aware I check & if it hasn’t succeeded a manual restart works every time.

1 Like

The Solax Power integration requires you to input the IP address of your inverter. However, some inverter firmware limits the local API to the inverter’s Wifi access point. If that is the case for you, you will need a device that can connect to your actual network and the inverter wifi at the same time, such as a Raspberry Pi with Wifi capabilities that connects to your network via Ethernet, and run Nginx web server to act as a reverse proxy between the networks. The Nginx configuration lines to set up the reverse proxy are at the bottom of the integration documentation.

This is also my experience with the integration. I hope this issue is resolved soon.