PV SolaX inverter cloud sensors via API

I have in config

Hi Miguel!! Or hola. After do it, where I can see the information? I need to create dashboard or aim going to have in energy section? Im lost in this point

Hi all, many thanks to those who posted their configs - I have this mostly working apart from some weird issues in the energy tab where it appears total yield values drop to 0 occasionally, leading to massive spikes on the next reading on the energy tab. E.g.

image

Anyone know the cause of these or how to prevent them?

Here’s my config

- platform: rest
  scan_interval: 90
  resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=XXXXXXXXXXXXXXX&sn=XXXXXXXXXXXX
  name: "Solax"
  json_attributes_path: "$.result"
  json_attributes:
    - yieldtoday
    - yieldtotal
    - acpower
    - uploadTime
    - inverterStatus
  value_template: "1" # dummy value, not used; avoids the "State max length is 255 characters" error
- platform: template
  sensors:
    solax_yield_today:
      friendly_name: "Solax yield today"
      value_template: "{{ state_attr('sensor.solax', 'yieldtoday') }}"
      unit_of_measurement: "KWh"
      device_class: energy
    solax_yield_total:
      friendly_name: "Solax yield total"
      value_template: "{{ state_attr('sensor.solax', 'yieldtotal') }}"
      unit_of_measurement: "KWh"
      device_class: energy
    solax_power_now:
      friendly_name: "Solax power now"
      value_template: "{{ state_attr('sensor.solax', 'acpower') }}"
      unit_of_measurement: "W"
      device_class: power
    solax_yield_delta:
      friendly_name: "Solax yield delta"
      value_template: "{{ state_attr('sensor.solax', 'acpower') /12000 }}"
      unit_of_measurement: "kWh"
      device_class: energy
    solax_upload_time:
      friendly_name: "Solax update time"
      value_template: "{{ state_attr('sensor.solax', 'uploadTime') }}"
    solax_status:
      friendly_name: "Solax status"
      value_template: >
        {% if state_attr('sensor.solax', 'inverterStatus') == '100' %}Wait
        {% elif state_attr('sensor.solax', 'inverterStatus') == '101' %}Check
        {% elif state_attr('sensor.solax', 'inverterStatus') == '102' %}Normal
        {% elif state_attr('sensor.solax', 'inverterStatus') == '103' %}Fault
        {% elif state_attr('sensor.solax', 'inverterStatus') == '104' %}Permanent Fault
        {% elif state_attr('sensor.solax', 'inverterStatus') == '105' %}Update
        {% elif state_attr('sensor.solax', 'inverterStatus') == '106' %}EPS Check
        {% elif state_attr('sensor.solax', 'inverterStatus') == '107' %}EPS
        {% elif state_attr('sensor.solax', 'inverterStatus') == '108' %}Self-test
        {% elif state_attr('sensor.solax', 'inverterStatus') == '109' %}Idle
        {% elif state_attr('sensor.solax', 'inverterStatus') == '110' %}Standby
        {% elif state_attr('sensor.solax', 'inverterStatus') == '111' %}Pv Wake Up Bat
        {% elif state_attr('sensor.solax', 'inverterStatus') == '112' %}Gen Check
        {% elif state_attr('sensor.solax', 'inverterStatus') == '113' %}Gen Run
        {% else %}I dont know{% endif %}
    solax_now:
      friendly_name: "PV now"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_power_now') | float) }}"
    solax_today:
      friendly_name: "PV today"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_yield_today') | float) }}"
    solax_total:
      friendly_name: "PV total"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_yield_total') | float) }}"

here’s the total yield graph showing a drop to 0
image

Thanks for sharing! This is what I was looking for. Just received my Solax yesterday and needed a quick fix, before I am going to build an integration.

One thing though: you are sharing your token. Not sure if that is a security/privacy issue.

:man_facepalming:

Thanks yes, can you delete it from yours? It’s read only of course but still…

For anybody looking for how to eliminate those odd zero entries it’s something like this

- sensor:
    - name: PV yield (Total)
      state: "{{ states('sensor.solax_total') | float }}"
      availability: "{{ states('sensor.solax_total') | float > 0 }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'

Done! I kind of assumed it would happen automatically, since I referenced your post. My mistake :wink:

Does anyone know how you can increase the update time on the readings? Every 5 minutes seems too long.

You can’t, if you want faster updates you have to use Modbus.

I had a feeling that was the case, unfortunately Modbus isn’t an option for me.

I’ve adopted parts of this thread. Among other sensors I’ve the solax_total_yield which shows the total kwh yield of my solar panels all-time. None of these sensors can be used in the Energy dashboards though. So I took the above snippet:

template:
  - sensor:
      - name: test_energy
        state: "{{ states('sensor.solax_total_yield') }}"
        availability: "{{ states('sensor.solax_total_yield') | float > 0 }}"
        unit_of_measurement: "kWh"
        state_class: total_increasing
        device_class: energy
        attributes:
          last_reset: "1970-01-01T00:00:00+00:00"

The sensor works. It’s slowly counting the kwh throughout the day. I can add it to the energy dashboard just fine, but the dashboard never shows any solar panel activity.

What have I done wrong?

1 Like

Hi, my second day venturing down the home assistant rabbit hole because I wanted to have some automation based on Solax X1 Hybrid G4 outputs.
I have managed to get the information from the cloud and did some slight customization to get the information I want for automation like total PV power and House consumption.
Next step Modbus.
One thing I have learnt/misunderstood. The serial number is the dongle serial number not the inverter for the API query
Thanks to all who have done the hard work to make this happen
Below is what the UI looks like.

PS I hope that I have posted the code correctly

- platform: rest
  scan_interval: 60
  resource: https://www.solaxcloud.com/proxyApp/proxy/api/getRealtimeInfo.do?tokenId=xxxxxxxxxxxxxxx&sn=SVTxxxxx
  name: "Solax Garage"
  json_attributes_path: "$.result"
  json_attributes:
    - yieldtoday
    - yieldtotal
    - powerdc1
    - powerdc2
    - uploadTime
    - inverterStatus
    - acpower
    - feedinpower
    - feedinenergy
    - soc
    - consumeenergy
    - batPower
  value_template: "1" # dummy value; not used; avoids error
- platform: template
  sensors:
    solax_garage_today:
      friendly_name: "Solax Garage today"
      value_template: "{{ state_attr('sensor.solax_garage', 'yieldtoday') }}"
      unit_of_measurement: "kWh"
    solax_garage_total:
      friendly_name: "Solax Garage total"
      value_template: "{{ state_attr('sensor.solax_garage', 'yieldtotal') }}"
      unit_of_measurement: "kWh"
    solax_garage_now:
      friendly_name: "Solax Garage now"
      value_template: "{{ state_attr('sensor.solax_garage', 'acpower') }}"
      unit_of_measurement: "W"
    solax_garage_pv1:
      friendly_name: "Solax Garage PV Power1"
      value_template: "{{ state_attr('sensor.solax_garage', 'powerdc1') }}"
    solax_garage_pv2:
      friendly_name: "Solax Garage PV Power2"
      value_template: "{{ state_attr('sensor.solax_garage', 'powerdc2') }}"
      unit_of_measurement: "W"
      icon_template: mdi:solar-panel
    solax_garage_pin:
      friendly_name: "Solax Garage FeedIn Power"
      value_template: "{{ state_attr('sensor.solax_garage', 'feedinpower') }}"
      unit_of_measurement: "W"
    solax_garage_ein:
      friendly_name: "Solax Garage FeedIn Energy"
      value_template: "{{ state_attr('sensor.solax_garage', 'feedinenergy') }}"
      unit_of_measurement: "kWh"
    solax_garage_soc:
      friendly_name: "Solax Garage Battery Charge level"
      value_template: "{{ state_attr('sensor.solax_garage', 'soc') }}"
      unit_of_measurement: "%"
    solax_garage_econ:
      friendly_name: "Solax Garage Consume Energy"
      value_template: "{{ state_attr('sensor.solax_garage', 'consumeenergy') }}"
      unit_of_measurement: "kWh"
    solax_garage_upload_time:
      friendly_name: "Solax Garage upload time"
      value_template: "{{ state_attr('sensor.solax_garage', 'uploadTime') }}"
      icon_template: mdi:alarm-check
    solax_garage_bat_power:
      friendly_name: "Solax Battery Power"
      value_template: "{{ state_attr('sensor.solax_garage', 'batPower') }}"  
    solax_garage_status:
      friendly_name: "Solax Garage status"
      value_template: >
        {% if state_attr('sensor.solax_garage', 'inverterStatus') == '100' %}Wait
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '101' %}Check
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '102' %}Normal
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '103' %}Fault
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '104' %}Permanent Fault
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '105' %}Update
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '106' %}EPS Check
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '107' %}EPS
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '108' %}Self-test
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '109' %}Idle
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '110' %}Standby
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '111' %}Pv Wake Up Bat
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '112' %}Gen Check
        {% elif state_attr('sensor.solax_garage', 'inverterStatus') == '113' %}Gen Run
        {% else %}I dont know{% endif %}
    solax_now:
      friendly_name: "Inverter Power"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_now') | float) }}"
      icon_template: mdi:lightning-bolt-circle
    solax_today:
      friendly_name: "PV today"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_garage_today') | float) }}"
    solax_total:
      friendly_name: "PV total"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_garage_total') | float) }}"
    solax_pv_power1:
      friendly_name: "PV Power1"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_pv1') | float) }}"
      icon_template: mdi:solar-power-variant-outline
    solax_pv_power2:
      friendly_name: "PV Power2"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_pv2') | float) }}"
      icon_template: mdi:solar-power-variant-outline
    solax_pv_power_total:
      friendly_name: "PV Power Total"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_pv2') | float) + (states('sensor.solax_garage_pv1') | float) }}"
      icon_template: mdi:solar-power-variant
    solax_house_cons:
      friendly_name: "House Power"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_now') | float) - (states('sensor.solax_garage_pin') | float) }}"
      icon_template: mdi:home-lightning-bolt-outline
    solax_feedin_power:
      friendly_name: "Grid Power"
      unit_of_measurement: "W"
      icon_template: mdi:transmission-tower
      value_template: "{{ (states('sensor.solax_garage_pin') | float) }}"
    solax_feedin_energy:
      friendly_name: "FeedIn Energy"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_garage_ein') | float) }}"
    solax_soc_level:
      friendly_name: "Battery Charge level"
      unit_of_measurement: "%"
      value_template: "{{ (states('sensor.solax_garage_soc') | float) }}"
      icon_template: mdi:home-battery
    solax_batt_power:
      friendly_name: "Battery Power"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_bat_power') | float) }}"
      icon_template: mdi:battery
    solax_consume_energy:
      friendly_name: "Consume Energy"
      unit_of_measurement: "kWh"
      value_template: "{{ (states('sensor.solax_garage_econ') | float) }}"
    solax_consume_power:
      friendly_name: "Consume Power"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_now') | float) - (states('sensor.solax_garage_pin') | float) }}"

Did you find a Solution?
Same problem here. :roll_eyes:

little confused on how this works can someone help knew to home assitant and not sure if im doing this right. Can somone explain how i create the sensor as i get a UndefinedError: ‘value_json’ is undefined error message

Hi.
I have a Solax X3 Hybrid 10.0 D and used your yaml. The problem is that I cannot select it for the energy dashboard - the sensors are simply not visible. What do I need to do to make it available for the energy dashboard? I can use the sensors on my own dashboards, but it is not available in the dropdown menu for the energy dashboard.

I’m running into the same problem, have you found a solution yet?

just add state_class: total_increasing to the template/sensor that has the total kWh

  - 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

and by the way, i did adapt a local API that works with the actual pocket wifi 2.0

Hello, I need your help. I’m still relatively new to HA. I would like to integrate my Solax WR. I copied the code with my data into the configuration.yaml. There is a green tick on it. When testing the configuration I get the following message “Integration error: sensors - Integration ‘sensors’ not found.” Can someone tell me where the problem is. Many Thanks