Solax X3 MIC G2 via local Rest API, complete Solution with most Sensors

I struggled a lot to get the solax inverter to work in Home Assistant. Partially because of advanced discriptions in this community and because solax does not publicly share what each value in the json file means. Some minor problems occured only after a longer use period. These issues have been resolved. For Instance:

  • Solax Inverter sometimes reporting 0 as total energy produced.
  • 16 bit limit (max value 65535) of total energy produced loops around, supposed loop counter is at Data point [23] (might not be correct, i will update once it loops again).

This is specifically for the Solax X3 MIC G2.

My Local IP Adress is http://192.168.178.25 replace it with yours.

My Registration No. is SPXQ3XKSLGP replace it with yours.

You can copy this as is into your configuration.yaml file. You only need the local IP adress of your Solax wifi/LAN USB Module and the Registration No.

sensor:
  #solaxlocalbegin
  - platform: rest
    authentication: digest
    scan_interval: 20
    resource: http://192.168.178.25/
    payload: "optType=ReadRealTimeData&pwd=SPXQ3XKSLGP"
    method: POST
    headers:
      X-Forwarded-For: 5.8.8.8
    name: "solax_rest_local"
    json_attributes:
      - type
      - SN
      - ver
      - Data
      - Information
    value_template: "OK" # dummy value, not used; avoids the "State max length is 255 characters" error
  #solaxlocalend

# curl -d "optType=ReadRealTimeData&pwd=SPXQ3XKSLGP" -X POST http://192.168.178.25

template:
  - sensor:
      #solaxlocalbegin
      - name: solax_local
        state: >
          {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX"  %}{{ now().strftime("%H:%M:%S") }}
          {% else %}{{ (states('sensor.solax_local')) }}{% endif %}
        attributes:
          sn: >-
            {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX" %}{{ (state_attr('sensor.solax_rest_local', 'sn')) }}
            {% else %}{{ (state_attr('sensor.solax_local', 'sn')) }}{% endif %}
          ver: >-
            {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX" %}{{ (state_attr('sensor.solax_rest_local', 'ver')) }}
            {% else %}{{ (state_attr('sensor.solax_local', 'ver')) }}{% endif %}
          type: >-
            {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX" %}{{ (state_attr('sensor.solax_rest_local', 'type')) }}
            {% else %}{{ (state_attr('sensor.solax_local', 'type')) }}{% endif %}
          Data: >-
            {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX" %}{{ (state_attr('sensor.solax_rest_local', 'Data')) }}
            {% else %}{{ (state_attr('sensor.solax_local', 'Data')) }}{% endif %}
          Information: >-
            {% if not state_attr('sensor.solax_rest_local', 'sn') == "XXXXXXX" %}{{ (state_attr('sensor.solax_rest_local', 'Information')) }}
            {% else %}{{ (state_attr('sensor.solax_local', 'Information')) }}{% endif %}

      - name: "Solax Energy today"
        unit_of_measurement: "kWh"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[24] / 10 }}"
        device_class: energy
        state_class: total
        icon: mdi:solar-panel

      - name: "Solax Energy Total"
        unit_of_measurement: "kWh"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[22] / 10 + state_attr('sensor.solax_rest_local', 'Data')[23]*6553.5}}" #22 or 68, 16 bit cannot be higher than 65535 --> loops around, supposedly 23 is loop counter
        availability: "{{ state_attr('sensor.solax_rest_local', 'Data')[22] > 1 }}" #sometimes the inverter report 0 as a values, this messes up HA, this solves the problem
        device_class: energy
        state_class: total_increasing
        icon: mdi:chart-line

      - name: "Solax DC Voltage 1"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[9] /10 | float  }}"
        unit_of_measurement: "V"
        device_class: "voltage"

      - name: "Solax DC Voltage 2"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[10] /10 | float  }}"
        unit_of_measurement: "V"
        device_class: "voltage"

      - name: "Solax DC Current 1"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[12] / 10 }}"
        unit_of_measurement: "A"
        device_class: "current"

      - name: "Solax DC Current 2"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[13] / 10 }}"
        unit_of_measurement: "A"
        device_class: "current"

      - name: "Solax DC Power 1"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[15] }}"
        unit_of_measurement: "W"
        device_class: "power"
        icon: mdi:solar-panel

      - name: "Solax DC Power 2"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[16] }}"
        unit_of_measurement: "W"
        device_class: "power"
        icon: mdi:solar-panel

      - name: "Solax DC Power Total"
        state: "{{ (state_attr('sensor.solax_rest_local', 'Data')[15]) + (state_attr('sensor.solax_rest_local', 'Data')[16]) }}"
        unit_of_measurement: "W"
        device_class: "power"
        icon: mdi:solar-panel

      - name: "Solax Power Efficiency"
        state: "{{ ((state_attr('sensor.solax_rest_local', 'Data')[78] | float) / 
              ((state_attr('sensor.solax_rest_local', 'Data')[15] | float) + 
               (state_attr('sensor.solax_rest_local', 'Data')[16] | float)) * 100) | round(1) }}"
        unit_of_measurement: "%"
        device_class: "power_factor"


      - name: "Solax AC Output Voltage"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[0] / 10 }}"
        unit_of_measurement: "V"
        device_class: "voltage"

      - name: "Solax AC Current"
        state: "{{ (state_attr('sensor.solax_rest_local', 'Data')[3] / 10) + (state_attr('sensor.solax_rest_local', 'Data')[4] / 10) + (state_attr('sensor.solax_rest_local', 'Data')[5] / 10)}}"
        unit_of_measurement: "A"
        device_class: "current"

      - name: "Solax AC Power"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[78] }}"
        unit_of_measurement: "W"
        device_class: "power"
        icon: mdi:power-socket-de

      - name: "Solax AC Frequency"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data')[18] / 100  | float }}"
        unit_of_measurement: "Hz"
        device_class: "frequency"
        icon: mdi:music-clef-treble

      - name: "Solax Inverter Operation Mode"
        state: >
          {%   if state_attr('sensor.solax_local', 'Data')[21] ==  0 %}Waiting
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  1 %}Checking
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  2 %}Normal
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  3 %}Off
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  4 %}Permanent Fault
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  5 %}Updating
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  6 %}EPS Check
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  7 %}EPS Mode
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  8 %}Self Test
          {% elif state_attr('sensor.solax_local', 'Data')[21] ==  9 %}Idle
          {% elif state_attr('sensor.solax_local', 'Data')[21] == 10 %}Standby
          {% else %}I dont know{% endif %}

      - name: "Solax Inverter Nominal Power"
        state: "{{ state_attr('sensor.solax_rest_local', 'Information')[0] | float | round(0) }}"
        unit_of_measurement: "kW"

      - name: "Solax Module SN"
        state: "{{ state_attr('sensor.solax_rest_local', 'sn') }}"

      - name: "Solax module fw version"
        state: "{{ state_attr('sensor.solax_rest_local', 'ver') }}"

      #        - name: "Solax type"
      #          state: "{{ state_attr('sensor.solax_rest_local', 'type') ==  3 %}X1Hybrid-G3 }}"

      - name: "Solax Inverter SN"
        state: "{{ state_attr('sensor.solax_rest_local', 'Information')[2] }}"

      - name: "Solax Inverter Information"
        state: "{{ state_attr('sensor.solax_rest_local', 'Information') }}"

      - name: "Solax Inverter Data"
        state: "{{ state_attr('sensor.solax_rest_local', 'Data') }}"
#solaxlocalend

To check if your Solax wifi/LAN USB Module is connected you can use the following command in Command Prompt or any other Terminal:

curl -d "optType=ReadRealTimeData&pwd=SPXQ3XKSLGP" -X POST http://192.168.178.25

It will return something like this, if everything works:

{"sn":"SPXQ3XKSLGP","ver":"3.006.04","type":16,"Data":[2373,2357,2359,4,4,6,44,25,6,4566,2464,0,1,2,0,72,53,0,4997,4996,4999,2,2625,1,561,10000,42,38,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,76,0,1,5,1,0,13937,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"Information":[10.000,16,"MC540TI6275259",8,1.17,0.00,1.13,1.01,0.00,1]}

Have fun.

Thanks. Very helpful article.
Having same Solax inverter X3 hybrid Mic.
Have you realized all the Data array values?
I am looking for Total power to grid and Total power from grid. Something similar to Total yield: data[22] + data[23] * 65535.
Or colud be it on daily basis like Daily yield on data[24]?
Indexes 74 -77 are also uncovered for me.
Thanks

I got it from here

For an almost complete list of all API values, check out this file:

Only a few array values aren’t documented yet (check block “16” for the X3-MIC G2)