Solax X1 Hybrid G4 (local & cloud API)

@Freakandel
I just reviewed the code and it seems that you don’t need the solax_local_settings part, it doesnt have a reference anywhere, so you could remove it.
I also compared the data from solax_local and Solaxcloud.com and the following mapping differs between us:

Your code:

solax_local_pv_output > 'Data')[11]
solax_local_voltage_ac > 'Data')[5]
solax_local_voltage_dc > 'Data')[2]
solax_local_current_dc > 'Data')[0]

I think that these should change to:

Data 11 > solax_local_pv1_power
Data 5 > solax_local_network_voltage
Data 2 > solax_local_pv1_voltage
Data 0 > solax_local_pv1_current

Beside total yield and daily yield should contain state class total_increasing, so you can use this data in the energy dashboard and for long term statics.

One last thing: You’re missing the operation mode of the inverter so you know the status:

    - name: "Solax Local Inverter Operation Mode"
      unique_id: solax_local_inverter_operation_mode
      icon: mdi:solar-power-variant
      state: >
        {% if state_attr('sensor.solax_local', 'Data')[68] ==  0 %}Wait
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  1 %}Check
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  2 %}Normal
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  3 %}Fault
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  4 %}Permanent Fault
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  5 %}Update
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  6 %}EPS Check
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  7 %}EPS
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  8 %}Self-test
        {% elif state_attr('sensor.solax_local', 'Data')[68] ==  9 %}Idle
        {% elif state_attr('sensor.solax_local', 'Data')[68] == 10 %}Standby
        {% elif state_attr('sensor.solax_local', 'Data')[68] == 11 %}Pv Wake Up Bat
        {% elif state_attr('sensor.solax_local', 'Data')[68] == 12 %}Gen Check
        {% elif state_attr('sensor.solax_local', 'Data')[68] == 13 %}Gen Run
        {% else %}Unknown{% endif %}    

Do whatever you want with this information :slight_smile:

2 Likes

Has anyone had this problem? My X1 Hybrid G4 is being very strange with the ‘setReg’ API call to the LAN (wi-fi) IP. The URL formats used by @kamilb and others earlier in this thread, just don’t want to work.

If I make a simple operation like unlocking, it’s fine:

$ curl -d 'optType=setReg&pwd=SVVxxxxxxx&data={"num":1,"Data":[{"reg":0,"val":"2014"}]}' -X POST http://192.168.8.170
Y:code,message:"success"}

And if I set the operating mode, register 27, to 0 (self-use), it’s happy:

$ curl -d 'optType=setReg&pwd=SVVxxxxxxx&data={"num":1,"Data":[{"reg":"27","val":"0"}]}' -X POST http://192.168.8.170
Y:code,message:"success"}

(Notice that I have to quote the register number, else I get '0:code,message:“failed” as the response).

If I try to set the mode to something else - e.g. manual, it fails every time:

$ curl -d 'optType=setReg&pwd=SVVxxxxxxx&data={"num":1,"Data":[{"reg":"27","val":"3"}]}' -X POST http://192.168.8.170
0:code,message:"failed"}

Register 35, the manual operation mode, gives similar results; value 0 is okay, anything else creates an error.

Making a REST call from HA gets similar results, ranging from HTTP/401 (unauthorised) to some more random stuff. NodeRed gets ‘ECONNRESET’ for any attempt to hit the setReg API.

The read data API headers show: “sn”:“SVVxxxxxxx”,“ver”:“3.012.01”,“type”:15. Pocket wifi web page reports version 3.001.02.

Does anyone have any ideas? I’m stumped!

@jefft4 Do you happen to be running curl from Windows / dos? I remember odd behaviour when I was testing from a PC; I switched to a raspberry pi and it started working as expected.

Ubuntu Linux.

Hi,
Really like this. I just had solar installed and this is the first time I have used home assistant.
Not fully setup powercalc however the automation triggered last night and failed due to this error - Any ideas what the issue is?

Battery - Disable forced charge uses an unknown service
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.

Set Solar Battery Target Level uses an unknown service
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.

type or paste code here

Solved it! The register numbers for ‘setReg’ are not a zero-based array, they’re a 1-based array. So it’s 28 and 36 to set, rather than the 27 and 35 that I read!
Gotta love Solax, feels like they’re never knowingly logical or consistent.

That looks like HA doesn’t know those REST commands, which suggests they’re not in your configuration or the names are mis-typed. Have you added kamilb’s rest_command definitions to your configuration somewhere and did you reload or restart HA after adding them?

If you think they’re okay, enable the developer tools and try calling the service from the services page there.

I’ve implemented the Solax local settings and these are great - thank you! I’m on Intelligent Octopus so when my car is charging, to stop the battery discharging I set the Minimum State of Charge to 100% - this works fine! However, when the car stops charging and I go to reset the minimum State of Charge parameter back to the usual 10% it fails. Looking into this in more detail, it fails because the inverter has gone into idle mode. According to Solax, idle mode will be exited when either the battery starts charging (this won’t happen as it’s at 100%) or the PV starts generating power - but at 6:00am it’s dark!! Is there a way I can stop it going into idle mode or alternatively is there another way to stop the battery discharging whilst the car is charging!?

Bonjour à tous

Merci Kamilb pour tous vos recherches, elle mon été très bénéfique.
J’ai démarré Home assistante il y a 6 mois et je m’intéresse sur la suite de l’intégration avec la gestion intelligente de la batterie.
Cependant je ne comprends pas pourquoi mon code ne fonctionne pas.
Je souhaite juste passer l’état :

  • “solax_local_set_inverter_mode”
    - “Self Use” vers “Manual” respectivement “0” vers “3”
    -“solax_local_set_manual_mode_behaviour”
    - “Do Nothing” vers “Forced charge” respectivement “0” vers “2”

Comme je ne suis pas alèse avec le codage j’utilise NODE-RED pour tous les déclanchement et gestion qui suivrons.

- id: '3008'
  alias: Battery - Saving Sessions - Return to Self-Use
  description: Stop forced discharge and return to normal operation
  trigger:
  - platform: time
    at: '17:30:00'
  condition:
  - condition: template
    value_template: '{{ (states(''sensor.solax_local_inverter_mode'') == ''Manual''
      ) }}    '
  action:
  - repeat:
      sequence:
      - delay:
          hours: 0
          minutes: 0
          seconds: 15
          milliseconds: 0
      - service: rest_command.solax_local_set_inverter_mode
        data:
          value: '{{ 0 }}

            '
      - delay:
          hours: 0
          minutes: 0
          seconds: 15
          milliseconds: 0
      - service: rest_command.solax_local_set_manual_mode_behaviour
        data:
          enabled: '{{ 0 }}

            '
      - delay:
          hours: 0
          minutes: 0
          seconds: 15
          milliseconds: 0
      - service: homeassistant.update_entity
        entity_id: sensor.solax_rest_local_settings
      until:
      - condition: template
        value_template: '{{ (states(''solax_local_manual_mode_behaviour'') == ''Do
          Nothing'' and states(''sensor.solax_local_inverter_mode'') == ''Self Use'')
          or repeat.index == 3 }}'
  mode: single

Pour information si je modifie a la main les paramètre sur l’onduleur ou sur solax cloud j’ai bien les modification des ID suivent:
- “sensor.solax_local_inverter_mode”
- “sensor.solax_local_manual_mode_behaviour”
- “sensor.solax_local_manual_mode_behaviour”

Je ne comprends pas trop mon erreur ci quelqu’un veux bien prendre de temps de me lire merci a vous :slight_smile:

@doudou49000 I’ve described changing the modes in this article - maybe this will help: Automated Octopus Saving Sessions with Solax X1 Hybrid G4

Merci Kamilb
La seule erreur que j’avais c’était le PWD :frowning:
je vais pourvoir avancer.

@kamilb really thanks for the help to integrate solax into Home Assistant, i followed your instruction and i have no issue haveing both cloud and local values, but… after a system restart i don’t see cloud values, only local and i don’t know how to debug it…

image

The url for cloud values is working of course…

Amazing work! Used all your insights to build my own automation for X1 G4.
Have you found a way to update advanced settings registers via local API. Due to cold weather I’m looking to automate battery heating management, however API always response with failed status.

I use a different solution that is totally local and uses TCP.

This is what I get to play with for battery heating :

image

image

Here’s the link (do not assume it is modbus only like others have - it is 100% TCP compliant as well and I use it with PocketWifi)

https://github.com/wills106/homeassistant-solax-modbus

It installs through HACS and all you need for TCP is the IP address it has on your network. That’s it. Simple.

I poll every 5 seconds :slight_smile:

Thanks for the reference. I’ve read your comments on Modbus and tried it. But for some reason it shows Disabled even when I enable it via the app. I’m a bit concerned about reliability of Modbus over tcp that I saw in several discussions. So I decided to go with http api.
I’ve sorted the issue - totally forgot that with HTTP API reading and writing registers are zero-based and not zero-based accordingly.
Now it’s working perfectly

Glad you got it sorted. I’ve been using the modbus/tcp solution for almost 12 months and have had zero issues :slight_smile:

1 Like

That’s interesting, that’s different to how my SolaX behaves. I have two inverters - the one with the battery is always online. What model is yours? It seems that no two SolaX models behave the same way!
Another way to achieve what you want, is to change the operating mode to ‘backup’ while charging the car. That should stop the battery discharging unless the grid power fails. Then set it back to ‘self-use’ when done.
Whether that will keep the inverter online for API access, though, only testing will find out!

I have found the problem:
image
The sensor does not exist even if is in the sensor.yaml with “solax_rest_local” and “solax_rest_local_settings” (both working)… any suggestion?
Thanks for all

Problem solved adding some other sensor to sensor.yaml… i haven’t touch the solax_rest_cloud sensor…i don’t understand…

Hi, Solax Hybrid G4 7.5kw with pocket LAN 3.0 works with Home Assistant ? Can I use official integration?

Thanks a lot