Solax X3-Hybrid G4 Wifi Firmware Solax module fw version 3.003.02 Home Assistant Integration

I understand, so you need to find the correct api commands for that 2nd one.
my pocket Wifi has firmware version 3.001.02
So there are a lot examples of API commands that worked, here are some links:

Any other noob tearing their hair out… there is a space missing on line 183
state_class: total_increasing

There is a space missing on line 183 in the ### Total values for Energy panel - needs customization in customize.yaml ### section

1 Like

OK I have the solax_rest_data showing… but cant see any sensors or do anything with this data?


Should there not be a new bunch of sensors I can work with now?

thanks, corrected the missing space in line 183

The templates recalculate each time the data changes, so the templates should be filled with data

Finally I can receive attributes from solax_rest. For some freaking reason I have to use backup password from solax cloud site. This V3 dongle is strange anyway… (its a shit)

Now I have to somehow work out the sensors. With the tutorial, I get Invalid config for [template: [name] is an invalid option for [template]. Check: template->name, and no sensor shows up.

If I put sensor on the begging of templates.yaml than I get this:

  • sensor:
    • name: solax
      state: >

jinja2.exceptions.UndefinedError: None has no element 0 and so on.

Can anyone post a latest working teplates.yaml file?

Thanks!

  ###Solax
  - name: solax
    state: > 
            {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR"  %}{{ now() }}
            {% else %}{{ (states('sensor.solax')) }}{% endif %}
    attributes: 
      sn: >-
            {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR" %}{{ (state_attr('sensor.solax_rest_data', 'sn')) }}
            {% else %}{{ (state_attr('sensor.solax', 'sn')) }}{% endif %}
      ver: >-
          {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR" %}{{ (state_attr('sensor.solax_rest_data', 'ver')) }}
          {% else %}{{ (state_attr('sensor.solax', 'ver')) }}{% endif %}
      type: >-
          {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR" %}{{ (state_attr('sensor.solax_rest_data', 'type')) }}
          {% else %}{{ (state_attr('sensor.solax', 'type')) }}{% endif %}
      Data: >-
          {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR" %}{{ (state_attr('sensor.solax_rest_data', 'Data')) }}
          {% else %}{{ (state_attr('sensor.solax', 'Data')) }}{% endif %}
      Information: >-
          {% if state_attr('sensor.solax_rest_data', 'sn') == "SXEYMEEBDR" %}{{ (state_attr('sensor.solax_rest_data', 'Information')) }}
          {% else %}{{ (state_attr('sensor.solax', 'Information')) }}{% endif %}

###SOLAX Integration
###AC detailed information
  - name: "Solax L1 Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[0] | int(default=2300) / 10}}"
    unit_of_measurement: "V"
    device_class: "voltage"

  - name: "Solax L2 Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[1] | int(default=2300) / 10}}"
    unit_of_measurement: "V"
    device_class: "voltage"

  - name: "Solax L3 Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[2] | int(default=2300) / 10 }}"
    unit_of_measurement: "V"
    device_class: "voltage"

  - name: "Solax L1 Current"
    state: >
      {% if state_attr('sensor.solax', 'Data')[3] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[3] - 65536) | int(default=0) / 10 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[3] | int(default=0) / 10 }}{% endif %}
    unit_of_measurement: "A"
    device_class: "current"

  - name: "Solax L2 Current"
    state: >
      {% if state_attr('sensor.solax', 'Data')[4] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[4] - 65536) | int(default=0) / 10 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[4] | int(default=0) / 10 }}{% endif %}
    unit_of_measurement: "A"
    device_class: "current"

  - name: "Solax L3 Current"
    state: >
      {% if state_attr('sensor.solax', 'Data')[5] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[5] - 65536) | int(default=0) / 10 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[5] | int(default=0) / 10 }}{% endif %}
    unit_of_measurement: "A"
    device_class: "current"

  - name: "Solax L1 Power"
    state: >
      {% if state_attr('sensor.solax', 'Data')[6] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[6] - 65536) | int(default=0) }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[6] | int(default=0) }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax L2 Power"
    state: >
      {% if state_attr('sensor.solax', 'Data')[7] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[7] - 65536) | int(default=0) }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[7] | int(default=0) }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax L3 Power"
    state: >
      {% if state_attr('sensor.solax', 'Data')[8] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[8] - 65536) | int(default=0) }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[8] | int(default=0) }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax Total AC Power"
    state: >
      {% if state_attr('sensor.solax', 'Data')[9] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[9] - 65536) | int(default=0) }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[9] | int(default=0) }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax L1 Frequency"
    state: "{{ state_attr('sensor.solax', 'Data')[16] | int(default=5000) / 100}}"
    unit_of_measurement: "Hz"
    device_class: "frequency"

  - name: "Solax L2 Frequency"
    state: "{{ state_attr('sensor.solax', 'Data')[17] | int(default=5000) / 100}}"
    unit_of_measurement: "Hz"
    device_class: "frequency"

  - name: "Solax L3 Frequency"
    state: "{{ state_attr('sensor.solax', 'Data')[18] | int(default=5000) / 100}}"
    unit_of_measurement: "Hz"
    device_class: "frequency"

### Solax Summary and statistic sensors ###
  - name: "Solax Feed-in Power"
    state: >
      {% if state_attr('sensor.solax', 'Data')[34] > 32767 %}{{ state_attr('sensor.solax', 'Data')[34] - 65536 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[34] }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax Consumption"
    state: >
      {% if state_attr('sensor.solax', 'Data')[47] > 32767 %}{{ state_attr('sensor.solax', 'Data')[47] - 65536 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[47] }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax Energy total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[69] * 65536) + state_attr('sensor.solax', 'Data')[68]) | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

### Today's statistics ###
  - name: "Solax Grid out today"
    state: "{{ state_attr('sensor.solax', 'Data')[90] | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Grid in today"
    state: "{{ state_attr('sensor.solax', 'Data')[92] | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Battery discharge today"
    state: "{{ state_attr('sensor.solax', 'Data')[78] | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Battery charge today"
    state: "{{ state_attr('sensor.solax', 'Data')[79] | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Energy today"
    state: "{{ state_attr('sensor.solax', 'Data')[82] | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Energy incl battery today"
    state: "{{ state_attr('sensor.solax', 'Data')[70] | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

### Total values for Energy panel - needs customization in customize.yaml ###
  - name: "Solax Solar energy total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[81] * 65536) + state_attr('sensor.solax', 'Data')[80]) | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Solar energy total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[81] * 65536) + state_attr('sensor.solax', 'Data')[80]) | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Grid out total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[87] * 65536) + state_attr('sensor.solax', 'Data')[86]) | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Grid in total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[89] * 65536) + state_attr('sensor.solax', 'Data')[88]) | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Consumption total"
    state: "{{ state_attr('sensor.solax', 'Data')[88] | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Battery discharge total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[75] * 65536) + state_attr('sensor.solax', 'Data')[74]) | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Battery charge total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[77] * 65536) + state_attr('sensor.solax', 'Data')[76]) | float / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

### PV detailed information ###      
  - name: "Solax PV1 Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[10] | int(default=0) / 10}}"
    unit_of_measurement: "V"
    device_class: "voltage"

  - name: "Solax PV2 Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[11] | int(default=0) / 10}}"
    unit_of_measurement: "V"
    device_class: "voltage"
    
  - name: "Solax PV1 Current"
    state: "{{ state_attr('sensor.solax', 'Data')[12] | int(default=0) / 10 }}"
    unit_of_measurement: "A"
    device_class: "current"
    
  - name: "Solax PV2 Current"
    state: "{{ state_attr('sensor.solax', 'Data')[13] | int(default=0) / 10 }}"
    unit_of_measurement: "A"
    device_class: "current"

  - name: "Solax PV1 Power"
    state: "{{ state_attr('sensor.solax', 'Data')[14] | int(default=0) }}"
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax PV2 Power"
    state: "{{ state_attr('sensor.solax', 'Data')[15] | int(default=0) }}"
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax Total PV Power"
    state: "{{ (states('sensor.solax_pv1_power')|int + states('sensor.solax_pv2_power')|int) }}"
    unit_of_measurement: "W"
    device_class: "power"

### Battery detailed information ###      
  - name: "Solax Battery Voltage"
    state: "{{ state_attr('sensor.solax', 'Data')[39] | float / 100}}"
    unit_of_measurement: "V"
    device_class: "voltage"

  - name: "Solax Battery Current"
    state: >
      {% if state_attr('sensor.solax', 'Data')[40] > 32767 %}{{ (state_attr('sensor.solax', 'Data')[40] - 65536) / 100 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[40] / 100 }}{% endif %}
    unit_of_measurement: "A"
    device_class: "current"

  - name: "Solax Battery Power"
    state:  >
      {% if state_attr('sensor.solax', 'Data')[41] > 32767 %}{{ state_attr('sensor.solax', 'Data')[41] - 65536 }}
      {% else %}{{ state_attr('sensor.solax', 'Data')[41] }}{% endif %}
    unit_of_measurement: "W"
    device_class: "power"

  - name: "Solax Battery SoC"
    state: "{{ state_attr('sensor.solax', 'Data')[103] | int(default=0) }}"
    unit_of_measurement: "%"

  - name: "Solax Battery Remain Energy"
    state: "{{ state_attr('sensor.solax', 'Data')[106] | int(default=0) / 10 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"

  - name: "Solax Battery Temperature"
    state: "{{ state_attr('sensor.solax', 'Data')[105] | int(default=0) }}"
    unit_of_measurement: "°C"
    device_class: "temperature"

  - name: "Solax Battery BMS status"
    state:  >
      {% if state_attr('sensor.solax', 'Data')[45] | int == 1 %}OK
      {% else %}Fail{% endif %}
    unit_of_measurement: "%"

### Invertor modes, states ###
  - name: "Solax Battery Operation Mode"
    state: >
      {%   if state_attr('sensor.solax', 'Data')[168] == 0 %}Self Use Mode
      {% elif state_attr('sensor.solax', 'Data')[168] == 1 %}Force Time Use
      {% elif state_attr('sensor.solax', 'Data')[168] == 2 %}Back Up Mode
      {% elif state_attr('sensor.solax', 'Data')[168] == 3 %}Feed-in Priority
      {% else %}I dont know{% endif %}

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

### Invertor and management module information ###
  - name: "Solax Module SN"
    state: "{{ state_attr('sensor.solax', 'sn') }}"

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

  - name: "Solax type"
    state: >  # Other Solax invertor type are described in web API manual
      {% if state_attr('sensor.solax', 'type') == 14 %}X3-Hybrid G4
      {% else %}Other{% endif %}

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

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

### Test parameters ###
  - name: "Solax Inverter Temperature inner ?"
    state: "{{ state_attr('sensor.solax', 'Data')[46] | int(default=0) }}"
    unit_of_measurement: "°C"
    device_class: "temperature"

  - name: "Solax Inverter Temperature ?"
    state: "{{ state_attr('sensor.solax', 'Data')[54] | int(default=0) }}"
    unit_of_measurement: "°C"
    device_class: "temperature"

Thanks, for some reason if I use this in templates.yaml I get an error for ever -name tag:

ERROR (MainThread) [homeassistant.config] Invalid config for [template]: [name] is an invalid option for [template]. Check: template->name. (See /config/templates.yaml, line 1)

And no sensor showing up. I’ve no luck to fix it till, any suggestion?

it says your template.yaml is not correct.
template.yaml needs to start like this:

sensor:
###Solax
  - name: solax

Yes, that is what I did, and ended up the above mentioned errors in the log. (all sensors are not responding)

2023-03-21 09:33:47.172 ERROR (MainThread) [homeassistant.helpers.event] Error while processing template: Template("{{ state_attr('sensor.solax', 'Data')[0] | int(default=2300) / 10}}")
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 458, in async_render
    render_result = _render_with_context(self.template, compiled, **kwargs)
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 2007, in _render_with_context
    return template.render(**kwargs)
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 1301, in render
    self.environment.handle_exception()
  File "/usr/local/lib/python3.10/site-packages/jinja2/environment.py", line 936, in handle_exception
    raise rewrite_traceback_stack(source=source)
  File "<template>", line 1, in top-level template code
  File "/usr/src/homeassistant/homeassistant/helpers/template.py", line 1788, in forgiving_int_filter
    result = jinja2.filters.do_int(value, default=default, base=base)
  File "/usr/local/lib/python3.10/site-packages/jinja2/filters.py", line 957, in do_int
    return int(value)
jinja2.exceptions.UndefinedError: None has no element 0

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

And so on for all of them.

Yaml is very strict on the blanks in front, so you need to have the correct structure. Best to use a very good yaml editor that shows you if you are inline.
You cann add the “Studio Code Server” addon in Home Assistant, this is a good start.

I think its not an yaml error, I’ll go and analyze what templates do, and fix it.

Do you have v2 or v3 stick btw?

Thanks!

I ended up running a VM with a wifi dongle and setup nginx and I can access the both inverters on my local network, now to figure out how to aggregate the data into 1 control panel. Thank you for the help.

Guys, I was not able set up this one, but found this which is working fine for me with V3 wifi stick, fw 3.001.02. Hope this helps out someone else also:

BR
Zoltan

1 Like

Thank you somogyvari.zoltan, I spent a few days, finally getting the local API to work, didnt think the ModBus would work over V3 Wifi, :slight_smile: .

What you mean? Modbus over wifi working?

I am overlooking something in this thread?
What would i need to add to customize.yaml to get this? Right now HA is telling me i have no sensors that i can add to my energy dashboard.

something like this:

sensor.solax_solar_energy_total:
  state_class: total_increasing

sensor.solax_grid_out_total:
  state_class: total_increasing

sensor.solax_grid_in_total:
  state_class: total_increasing

sensor.solax_consumption_total:
  state_class: total_increasing

sensor.solax_battery_discharge_total:
  state_class: total_increasing

sensor.solax_battery_charge_total:
  state_class: total_increasing

I just started with HA for my new Q-Cells H3-Hybrid-G4 (a SolaX rebrand) with type id 34, so I’m very thankful for your work.
But I think there’s an other error in the template section:

  - name: "Solax Grid in total"
    state: "{{ ((state_attr('sensor.solax', 'Data')[89] * 65536) + state_attr('sensor.solax', 'Data')[88]) | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

  - name: "Solax Consumption total"
    state: "{{ state_attr('sensor.solax', 'Data')[88] | float / 100 }}"
    unit_of_measurement: "kWh"
    device_class: "energy"
    state_class: total_increasing

Both use [88], so one must be wrong. I assume the second (“Solax Consumption total”).