Solax X1 Hybrid G4 (local & cloud API)

Hi I managed to get all the code working, so that I can see all the local and cloud data populating nicely. However I couldn’t get this code from configuration.yaml to work:

### Commands for controlling the Solax Local inverter

rest_command:

  solax_local_charge_battery_from_grid:
    url: !secret solax_local_ip
    method: post
    payload: !secret solax_local_set_battery_level_payload

The issue with this code is: “Error loading /config/configuration.yaml: Secret solax_local_set_battery_level_payload not defined”. I’ve looked in the secret.yaml and there is no corresponding entry? I’m a complete novice at Home Assistant and any help would be appreciated.

Hey there I think in the file secret.yaml this entry might be missing.

solax_local_set_battery_level_payload: 'optType=setReg&pwd=YOUR_REG_NUMBER&data={"num":1,"Data":[{"reg":31,"val":"{{ level }}"}]}'

You can find your inverter reg number in the Solax Cloud
image

Thanks very much! :slight_smile:

Do you have a bit more of a detailed guide of how to set this up?

Great stuff!

I also had difficulty with the default integration and as my installation has two inverters, whose statistics have to be added together to make sense (only one has the battery and CT clamp, the other is just PV->AC), I had to create a custom Node Red flow to pull the data.

Very pleased to see that you’ve managed to connect to the local API without needing the pain of a reverse proxy; the only URLs I had previously, needed the proxy to the pocket wi-fi; to find that this URL works on the LAN IP too is much less hassle!

Happy to help with any testing! I have a Hybrid G4 like you and also a X1 mini alongside it.
I have an ‘Agile’ electricity tariff option, so I’m very interested in instructing the battery to charge when grid electricity is cheap and solar is weak and also possibly in controlling the battery discharge periods so that I can save the battery for when the grid is at its most expensive.

Hi All,

I’ve spent a spare hour tweaking settings on my inverter and identifying where those attributes are in the ‘ReadSetData’ response array. Most of those @kamilb hasn’t already incorporated are not of much use, but a few of them might help people with unusual use cases.

I’ve put the results here: X1 Hybrid G4 settings array - Google Sheets ; this is derived from a X1 Hybrid G4 that the cloud app reports as ‘main version number 2.09’, calling the local API ‘ReadSetData’ method over the LAN.

I’ve not tested whether setting any of these by the usual method works, but I guess it will. There are a couple I want to experiment with, so I’ll test setting those later.

Hope this helps someone one day!

1 Like

@rdunbar17507 as part of initial setup you would connect to it via its own SSID and I believe you can do that through the solax app. Once you’ve configured it with your home SSID, then you should see it on your local network. It should tell you its IP, but if not, check your router and list of connected devices.

Hi,
Is anybody aware of any automations to turn forced battery charging on/off triggered by the intelligent octopus EV charging time slots (to avoid draining of the solar battery)?

1 Like

Hello guys, this setReg method actually works for you and changes settings on the inverter?
I am trying to implement this using:
curl -H “‘X-Forwarded-For’:‘5.8.8.8’” -s POST “192.168.50.22” --data ‘optType=setReg&pwd=xxxx&data={“num”:1,“Data”:[{“reg”:29,“val”:27}]}’

but it doesnt return anything (if i put wrong pwd it says unauthorized) and the setting on the inverter is not written, any idea why? Reading data is fine (even the readSetData is fine).

I have a Solax X1 mini 2kW (Firmware 3.009.03, which is latest). I have the solaxcloud API working, but this is not realtime, so was trying to integrate the local real-time solution, stated above, which I just can’t get working. I have also tried running the curl command:

curl -d "optType=ReadRealTimeData&pwd=XXXXXXX" -X POST http://192.168.1.205 -H "X-Forward-For: 5.8.8.8"       
0:code,message:"failed"}%

As above, I get ‘0:code,message:“failed”}%’ returned. At this point I join the built in broadcasted Wifi to check this with the built in default IP of 5.8.8.8, but it turns out 5.8.8.8 is no longer used, its now 192.168.10.10. Changing the curl command, to accomadate the new 192.168.10.10 IP, still results in the same return.
Any ideas as to what to try next please?

For those also having this issue, the ‘XXXXXXX’ should be replaced with the password, obtained from Solax Cloud, on the inverter, there is a small padlock icon, click on that reveals a ‘Backup password’, I used that to replace the ‘XXXXXXX’, and now the curl command works, I also didnt need the “X-Forward-For: 5.8.8.8” bit.

I really thought the OP was masking his password rather than copying and pasting … but I guess I could be wrong.

Hello all HA users!
I have Solax X3 Mic G2 15K inverter,
Can someone help me to solve puzzle with data fields from rest/wifi_dongle?
Hybrid template fields don’t match with my inverter.

I made spreadsheet Solax X3 Mic G2 15K data from cloud and local rest to compare, but can’t solve all needed data fields correct, don’t understand all these power things.
I have already spent a lot of my time to solve data fields , I am asking for help!

How to correct calc

Load/Generator (real time usage)?
Edit: Solved → (sum of AC total power [6+7+8]- feed in 72 + “feed out” 73(65535)
state: “{{ state_attr(‘sensor.solax’, ‘Data’)[6]|int + state_attr(‘sensor.solax’, ‘Data’)[7]|int + state_attr(‘sensor.solax’, ‘Data’)[8]|int - state_attr(‘sensor.solax’, ‘Data’)[72]|int + state_attr(‘sensor.solax’, ‘Data’)[73]|int }}”

1 Like

Hi I have a Solax X1-Fit-G4-5.0. All the code work except the automations. I have error codes:

The automation “Battery - Enable forced charge” (automation.battery_enable_forced_charge ) has an action that calls an unknown service: rest_command.solax_local_set_forced_charge_start .

The automation “Battery - Disable forced charge” (automation.battery_disable_forced_charge ) has an action that calls an unknown service: rest_command.solax_local_set_forced_charge_start .

The automation “Set Solar Battery Target Level” (automation.set_solar_battery_target_level ) has an action that calls an unknown service: rest_command.solax_local_set_charge_battery_from_grid

Any ideas how to fix this? The only related code I can see if in secrets.yalm which is all set up correctly.

1 Like

Hi Kamil,
i just received my Solax X3 and followed your guide. In the secrets.yaml you forgot to update/add the “solax_local_set_battery_level_payload: 'optType=setReg&pwd=REG_NO&data={“num”:1,“Data”:[{“reg”:31,“val”:”{{ level }}"}]}’" which will make HA fail to start normally when people just use the “copy code” function.
All the best
Wolfgang

1 Like

Hi Kamil,

Thanks for this its been great, im just watching it run now over next few days to see if it works well with my setup.
I found where the battery size is configured and daily morning loads etc to help predicate the best battery charge limit over night on off peak tariff.
Is there any other number that need overriding for say the solar panels for example ?

thanks

Does it matter which dongle I buy please? Just about to receive an X1 hybrid G4 and I’ve noticed 3 versions of the dongle. Thanks!

Thanks @kamilb for writing this tutorial up.
Can you share a concrete example with me, how the curl command would look like for setting the local battery grid charge level, please?

My try failed:

curl -d "optType=setReg&pwd=S*********&data={"num":1,"Data":[{"reg":31,"val":"{{ 65 }}"}]}" -X POST http://192.168.x.x

I receive:
curl: (7) Failed to connect to 65 port 80: Connection timed out
curl: (3) unmatched close brace/bracket in URL position 1:
}}}]}
^

502 Bad Gateway

502 Bad Gateway


nginx/1.14.2

A call

curl -d "optType=ReadRealTimeData&pwd=S********" -X POST http://192.168.x.x  

works fine, so I can read data, but currently I cannot set parameter.

Any help is appreciated.
Thanks.

Anyone can help with my question, please?

The curl command uses multiple sets of double qoutes, i.e. the quotes around the string that you want to send and then quotes within that json string.

This means curl is not doing what you expect.

This linux bash shell command avoids the problem by using single quotes around the json string:

curl -d 'optType=setReg&pwd=xxx&data={"num":1,"Data":[{"reg":28,"val":"1"}]}' -X POST http://SOLAX-INVERTER

If you’re using dos then you’ll need to find a way to do something similar or escape the double quoutes in the json string.