PV SolaX inverter cloud sensors via API

Did the 2022.2 update break anybody else’s Energy dashboard? I still get the correct values in my lovelace card and even the template sensor is showing the correct value. But for some reason the energy dashboard doesn’t pick up on the sensor anymore although it’s still configured as a solar input in the energy dashboard settings.

2 Likes

I’ve got the same issue you mentioned.

1 Like

I can’t imagine we are the only two people facing this issue. Anybody else got some tips maybe on how we could get this working again?

Is it also possible to display the output of the individual strings? It is available in Solax Cloud, but I could find it in the documentation.

I get an error trying to add solax to the energy solar configuration:

statistics_not_defined
* sensor.test_energy`

No clue what it means.

I followed the instructions with minor modifications. This works for X1-booster and I have the PV yield showing up on the energy dashboard. As I am new to HA it took a bit of digging through posts. My setup described below. Hope this is of help to anyone struggling with the dashboard integration. Thanks to @Doublet and @heldopsokken.

The configuration is split in 3 parts:

  1. configuration.yaml
sensor: !include_dir_merge_list sensor/
template: !include_dir_merge_list template/
  1. solax.yaml
    Grab data via api, “PV now”, “PV today”, “PV total” are in preparation of a second system I am planning to get this year so I can sum up easily.
- platform: rest
  resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=A&sn=B
  name: "Solax Garage"
  json_attributes_path: "$.result"
  json_attributes:
    - yieldtoday
    - yieldtotal
    - acpower
    - uploadTime
    - inverterStatus
  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_upload_time:
      friendly_name: "Solax Garage upload time"
      value_template: "{{ state_attr('sensor.solax_garage', 'uploadTime') }}"
    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: "PV now"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_now') | float) }}"
    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) }}"
  1. pv_sensors.yaml
    For “device_class: energy” the “state_class” needs to be “total_increasing” as described here Energy Dashboard doesn't work - #5 by francisp
- sensor:
    - name: PV yield (Now)
      state: "{{ states('sensor.solax_now') | float }}"
      unit_of_measurement: "W"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: PV yield (Today)
      state: "{{ states('sensor.solax_today') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: PV yield (Total)
      state: "{{ states('sensor.solax_total') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
3 Likes

Thanks @schnetf changing the sensor state_class did the trick for me as well!!!

Yes you can. I have only one string, so i tested it with the attribute “powerdc1” there are also powerd2/3/4 values, check which one is filled for you.

You need to add “powerdc1” and “powerdc2” to the JSON json_attributes and add add a template sensor for it:

    solax_x1_now_string1:
      friendly_name: "Solax X1 now String1"
      value_template: "{{ state_attr('sensor.solax_x1', 'powerdc1') }}"
      unit_of_measurement: "W"

Keep in mind that is is the “Raw” pv watt and nog excactly what is feeding in to you house. But at least now you can see the data.

Hi
OK, got the test link working no problem, had the coffee… than totally lost you.

“Build the Sensors in HA”

ummmm, what? where? how?

I am totally new to this… did you guess. pretend I am really thick… how do I get to “sensors”?

I found it on Sensor - Home Assistant but no idea how I get this on HA? View source on GitHub? that dosent seem to help me either…

dosent seem to be an add on or integration from within the HA GUI?

Sorry for what is probably a very basic and simple question. I am sure when I know I will roll my eyes at myself as I am sure your doing to me now!

Thanks for any help

2 Likes

Hi

Ok, Got somewhere.

Great guide, and I wouldn’t have got anywhere without it. I am totally new to to this, but here is some stuff thats not obvious to a totally new person like me.

" Build the sensors in HA"
Translation:-
Add this to the configuration.yaml file on your HA.

To do this add the addon “file Editor”, start it, then click open Web UI. click the folder icon and paste the sensors stuff above.

with one exception…
in the configuration stuff above it says sensors: this should be Sensor:

“just add the new sensors:”
Translation
in HA, click overview in side bar, bottom right click add card, click by entity, search for solax and click the items you have just added.

Thanks again for the guide and sorry if my new-ness is just obvious stuff. but if i got stuck there, maybe others did too.

Thanks

3 Likes

I changed the state_class: total_increasing but for some reason it now shows a negative value.

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

Hi,

First of all, great topic and info. It works for me, but the energy dashboard show different values than the entity. I think this has something to do with the energy production dips. Does anyone know how to get the entity and the energy dashboard in-sync?

Energy dashboard:

Energy enity:

that can take 2-4 hours

:wave: Hi community!!

I have a X1 Boost 3.0T inverter. I’d like to share my configuration. It’s based on @schnetf config, so, Thank you!!!
I’ve added more parameters, including the consumption in Watts.
As you know, this is to retrieve parameters from cloud. Can you recommend me a good guide to rertrieve data directly from inverter, in local network?

File solax.yaml

- platform: rest
  scan_interval: 60
  resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=XXXXXXXXXXXXX&sn=YYYYYYYY
  name: "Solax Garage"
  json_attributes_path: "$.result"
  json_attributes:
    - yieldtoday
    - yieldtotal
    - powerdc1
    - uploadTime
    - inverterStatus
    - acpower
    - feedinpower
    - feedinenergy
    - consumeenergy
  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_pv:
      friendly_name: "Solax Garage PV Power"
      value_template: "{{ state_attr('sensor.solax_garage', 'powerdc1') }}"
      unit_of_measurement: "W"
    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_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') }}"
    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: "PV now"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_now') | float) }}"
    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_power:
      friendly_name: "PV Power"
      unit_of_measurement: "W"
      value_template: "{{ (states('sensor.solax_garage_pv') | float) }}"
    solax_feedin_power:
      friendly_name: "FeedIn Power"
      unit_of_measurement: "W"
      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_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) }}"

File pv_sensors.yaml:

- sensor:
    - name: PV yield (Now)
      state: "{{ states('sensor.solax_now') | float }}"
      unit_of_measurement: "W"
      state_class: total_increasing
      device_class: power
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: PV yield (Today)
      state: "{{ states('sensor.solax_today') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: PV yield (Total)
      state: "{{ states('sensor.solax_total') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: PV yield (Total)
      state: "{{ states('sensor.solax_total') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: FeedIn Energy
      state: "{{ states('sensor.solax_feedin_energy') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: FeedIn Power
      state: "{{ states('sensor.solax_feedin_power') | float }}"
      unit_of_measurement: "W"
      state_class: total_increasing
      device_class: power
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: Consume Energy
      state: "{{ states('sensor.solax_consume_energy') | float }}"
      unit_of_measurement: "kWh"
      state_class: total_increasing
      device_class: energy
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'
- sensor:
    - name: Consume Power
      state: "{{ states('sensor.solax_consume_power') | float }}"
      unit_of_measurement: "W"
      state_class: total_increasing
      device_class: power
      attributes:         
        last_reset: '1970-01-01T00:00:00+00:00'

Hi, I have the following script (below) running for my Solax installation. It works fine but when I add new scripts or sensors to my configuration.ymal it doesn’t work anymore. I’m assuming I did something wrong but I’m not able to find what it is.

Do you guys have any suggestions?

#########################################################
#                                                       #
#         SOLAX CLOUD.                                  #
#                                                       #
#########################################################
sensor:
  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=&sn=
    value_template: '{{ ( value_json.result.yieldtotal | round(0) ) }}'
    name: "Solax total"
    unit_of_measurement: "KWh"


  - platform: rest
    scan_interval: 60
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: '{{ ( value_json.result.acpower | round(0) ) }}'
    name: "Solax now"
    unit_of_measurement: "W"

  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: '{{ value_json.result.yieldtoday }}'
    name: "Solax today"
    unit_of_measurement: "KWh"
  
  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: "{{ value_json.result.uploadTime }}"
    name: "Solax upload time"
     
  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: '{{ ( value_json.result.powerdc1 | round(0) ) }}'
    name: "Solax String 1"
    unit_of_measurement: "W"
  
  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: '{{ ( value_json.result.powerdc2 | round(0) ) }}'
    name: "Solax String 2"
    unit_of_measurement: "W"           
  
  - platform: rest
    scan_interval: 120
    resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20220105163654425474254&sn=SWZPGZE2D8
    value_template: >
          {% if value_json.result.inverterStatus == '100' %}Wait
          {% elif value_json.result.inverterStatus == '101' %}Check
          {% elif value_json.result.inverterStatus == '102' %}Normal
          {% elif value_json.result.inverterStatus == '103' %}Fault
          {% elif value_json.result.inverterStatus == '104' %}Permanent Fault
          {% elif value_json.result.inverterStatus == '105' %}Update
          {% elif value_json.result.inverterStatus == '106' %}EPS Check
          {% elif value_json.result.inverterStatus == '107' %}EPS
          {% elif value_json.result.inverterStatus == '108' %}Self-test
          {% elif value_json.result.inverterStatus == '109' %}Idle
          {% elif value_json.result.inverterStatus == '110' %}Standby
          {% elif value_json.result.inverterStatus == '111' %}Pv Wake Up Bat
          {% elif value_json.result.inverterStatus == '112' %}Gen Check
          {% elif value_json.result.inverterStatus == '113' %}Gen Run
          {% else %}I dont know{% endif %}
    name: "Solax status"

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

I am new on home assistant and i am trying to integrate my SOLAX system.
I can’t figure out where i have to install these files.

solax.yaml
pv_sensors.yaml

should both files be placed in the directory config ? Or in a subdirectory?

Hi and thanks!!! after do it… how I can create a dashboard with all information? or where I have the information? I dont have anything in Energy area… thanks!

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) }}"