I’ve gone through a lot of configurations on energy meter and solax but struggled to get a comprehensive view so I’m listing how I have configured to help others. Part of the code is borrowed from different posts as every post adds some knowledge to the configuration that I’ve used and thanks for all who have shared their configurations
I’ve two standard solax inverters and 1 hybrid inverter connected to battery. So even if no solar output is produced the ac output of the Solax hybrid will still have output getting the value from battery.
I thought that Energy dashboard gives real time info just like solax
But it DOESN’T, it shows real time moving dots but these are the load, consumption and generation of the observation window (day, week…)
so you need to provide that info.
I don’t get total grid or battery info and the only total is for solar so I have to create integration sensors to get the total values. I used the total solar but can’t recall an issue with that and decided to create a total solar as well.
You have to add customisation to these sensors otherwsie they won’t appear in the dashboard.
This how it looks like
The following code needs to go in configuration file under
sensor:
## X1a ##
- platform: rest
scan_interval: 60
resource: https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202109xxxx&sn=yyy
name: "Solax X1a"
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_x1a_today:
friendly_name: "Solax X1a today"
value_template: "{{ state_attr('sensor.solax_x1a', 'yieldtoday') }}"
unit_of_measurement: "kWh"
solax_x1a_total:
friendly_name: "Solax X1a total"
value_template: "{{ state_attr('sensor.solax_x1a', 'yieldtotal') }}"
unit_of_measurement: "kWh"
solax_x1a_now:
friendly_name: "Solax X1a now"
value_template: "{{ state_attr('sensor.solax_x1a', 'acpower') }}"
unit_of_measurement: "W"
solax_x1a_upload_time:
friendly_name: "Solax X1a upload time"
value_template: "{{ state_attr('sensor.solax_x1a', 'uploadTime') }}"
solax_x1a_status:
friendly_name: "Solax X1 status"
value_template: >
{% if state_attr('sensor.solax_x1a', 'inverterStatus') == '100' %}Wait
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '101' %}Check
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '102' %}Normal
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '103' %}Fault
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '104' %}Permanent Fault
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '105' %}Update
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '106' %}EPS Check
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '107' %}EPS
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '108' %}Self-test
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '109' %}Idle
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '110' %}Standby
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '111' %}Pv Wake Up Bat
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '112' %}Gen Check
{% elif state_attr('sensor.solax_x1a', 'inverterStatus') == '113' %}Gen Run
{% else %}I dont know{% endif %}
## X1b ##
- platform: rest
scan_interval: 60
resource: https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202109xxxx&sn=yyy
name: "Solax X1b"
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_x1b_today:
friendly_name: "Solax X1b today"
value_template: "{{ state_attr('sensor.solax_x1b', 'yieldtoday') }}"
unit_of_measurement: "kWh"
solax_x1b_total:
friendly_name: "Solax X1b total"
value_template: "{{ state_attr('sensor.solax_x1b', 'yieldtotal') }}"
unit_of_measurement: "kWh"
solax_x1b_now:
friendly_name: "Solax X1b now"
value_template: "{{ state_attr('sensor.solax_x1b', 'acpower') }}"
unit_of_measurement: "W"
solax_x1b_upload_time:
friendly_name: "Solax X1b upload time"
value_template: "{{ state_attr('sensor.solax_x1b', 'uploadTime') }}"
solax_x1b_status:
friendly_name: "Solax X1b status"
value_template: >
{% if state_attr('sensor.solax_x1b', 'inverterStatus') == '100' %}Wait
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '101' %}Check
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '102' %}Normal
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '103' %}Fault
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '104' %}Permanent Fault
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '105' %}Update
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '106' %}EPS Check
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '107' %}EPS
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '108' %}Self-test
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '109' %}Idle
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '110' %}Standby
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '111' %}Pv Wake Up Bat
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '112' %}Gen Check
{% elif state_attr('sensor.solax_x1b', 'inverterStatus') == '113' %}Gen Run
{% else %}I dont know{% endif %}
## X1h ##
- platform: rest
scan_interval: 60
resource: https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202109xxxx&sn=yyy
name: "Solax X1h"
json_attributes_path: "$.result"
json_attributes:
- yieldtoday
- yieldtotal
- acpower
- feedinpower
- powerdc1
- powerdc2
- batPower
- soc
- uploadTime
- inverterStatus
value_template: '1' # dummy value, not used; avoids the "State max length is 255 characters" error
- platform: template
sensors:
solax_x1h_today:
friendly_name: "Solax X1h today"
value_template: "{{ state_attr('sensor.solax_x1h', 'yieldtoday') }}"
unit_of_measurement: "kWh"
solax_x1h_total:
friendly_name: "Solax X1h total"
value_template: "{{ state_attr('sensor.solax_x1h', 'yieldtotal') }}"
unit_of_measurement: "kWh"
solax_x1h_ac:
friendly_name: "Solax X1h ac"
unit_of_measurement: "W"
value_template: "{{ state_attr('sensor.solax_x1h', 'acpower') }}"
solax_x1h_feedin:
friendly_name: "Solax X1h feedin"
unit_of_measurement: "W"
value_template: "{{ state_attr('sensor.solax_x1h', 'feedinpower') }}"
solax_x1h_dc1:
friendly_name: "Solax X1 dc1"
value_template: "{{ state_attr('sensor.solax_x1h', 'powerdc1') }}"
unit_of_measurement: "W"
solax_x1h_dc2:
friendly_name: "Solax X1h dc2"
value_template: "{{ state_attr('sensor.solax_x1h', 'powerdc2') }}"
unit_of_measurement: "W"
solax_x1h_soc:
friendly_name: "Solax X1h soc"
value_template: "{{ state_attr('sensor.solax_x1h', 'soc') }}"
unit_of_measurement: "%"
#Solar output of Hybrid inverter
solax_x1h_solar:
friendly_name: "Solax X1h solar"
value_template: >
{% if (state_attr('sensor.solax_x1h', 'powerdc1') | float) > 0 and
(state_attr('sensor.solax_x1h', 'powerdc2') | float ) > 0 %}
{{ (((states('sensor.solax_x1h_ac') | float ) - (states('sensor.battery_out') | float)
+ (states('sensor.battery_in') | float)) | float | abs) }}
{% else %}
0
{% endif %}
unit_of_measurement: "W"
#A/C output of Hybrid inverter
solax_x1h_now:
friendly_name: "Solax X1h now"
value_template: "{{ (states('sensor.solax_x1h_ac') | float ) }}"
unit_of_measurement: "W"
solax_x1h_batpower:
friendly_name: "Solax X1h batPower"
value_template: "{{ state_attr('sensor.solax_x1h', 'batPower') }}"
unit_of_measurement: "W"
solax_x1h_upload_time:
friendly_name: "Solax X1h upload time"
value_template: "{{ state_attr('sensor.solax_x1h', 'uploadTime') }}"
solax_x1h_status:
friendly_name: "Solax X1h status"
value_template: >
{% if state_attr('sensor.solax_x1h', 'inverterStatus') == '100' %}Wait
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '101' %}Check
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '102' %}Normal
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '103' %}Fault
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '104' %}Permanent Fault
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '105' %}Update
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '106' %}EPS Check
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '107' %}EPS
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '108' %}Self-test
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '109' %}Idle
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '110' %}Standby
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '111' %}Pv Wake Up Bat
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '112' %}Gen Check
{% elif state_attr('sensor.solax_x1h', 'inverterStatus') == '113' %}Gen Run
{% else %}I dont know{% endif %}
#Sum of all invertors
- platform: template
sensors:
solar_total:
friendly_name: Solar total
unit_of_measurement: "kWh"
value_template: "{{ (states('sensor.solax_x1a_total') | float) + (states('sensor.solax_x1b_total') | float) + (states('sensor.solax_x1h_total') | float) }}"
solar_today:
friendly_name: Solar today
unit_of_measurement: "kWh"
value_template: "{{ (states('sensor.solax_x1a_today') | float) + (states('sensor.solax_x1b_today') | float) + (states('sensor.solax_x1h_today') | float)}}"
solar_now:
friendly_name: Solar now
unit_of_measurement: W
value_template: "{{ (states('sensor.solax_x1a_now') | float) + (states('sensor.solax_x1b_now') | float) + (states('sensor.solax_x1h_solar') | float) }}"
total_ac_now:
friendly_name: Total AC now
unit_of_measurement: W
value_template: "{{ (states('sensor.solax_x1a_now') | float) + (states('sensor.solax_x1b_now') | float) + (states('sensor.solax_x1h_now') | float) }}"
# Calculate power in and out
battery_in:
friendly_name: Battery in
unit_of_measurement: W
value_template: >
{% if (states('sensor.solax_x1h_batpower') | float ) > 0 %}
{{ (states('sensor.solax_x1h_batpower') | float | abs) }}
{% else %}
0
{% endif %}
battery_out:
friendly_name: Battery out
unit_of_measurement: W
value_template: >
{% if (states('sensor.solax_x1h_batpower') | float ) < 0 %}
{{ (states('sensor.solax_x1h_batpower') | float | abs) }}
{% else %}
0
{% endif %}
house_load:
friendly_name: House Load
value_template: >
{% if (states('sensor.solar_now') | float ) == 0 %}
{{ (states('sensor.solax_x1h_now') | float)
+ (states('sensor.grid_in') | float) - (states('sensor.grid_out') | float) }}
{% else %}
{{ (states('sensor.total_ac_now') | float)
+ (states('sensor.grid_in') | float) - (states('sensor.grid_out') | float) }}
{% endif %}
unit_of_measurement: W
# Grid power in and out
grid_out:
friendly_name: Grid out
unit_of_measurement: W
value_template: >
{% if (states('sensor.solax_x1h_feedin') | float ) > 0 %}
{{ (states('sensor.solax_x1h_feedin') | float | abs)}}
{% else %}
0
{% endif %}
grid_in:
friendly_name: Grid in
value_template: >
{% if (states('sensor.solax_x1h_feedin') | float ) < 0 %}
{{ (states('sensor.solax_x1h_feedin') | float | abs) }}
{% else %}
0
{% endif %}
unit_of_measurement: W
# Integrating Export and Import Grid
- platform: integration
source: sensor.grid_in
name: total_grid_in
unit_prefix: k
round: 2
method: left
- platform: integration
source: sensor.grid_out
name: total_grid_out
unit_prefix: k
round: 2
method: left
- platform: integration
source: sensor.battery_in
name: total_battery_in
unit_prefix: k
round: 2
method: left
- platform: integration
source: sensor.battery_out
name: total_battery_out
unit_prefix: k
round: 2
method: left
- platform: integration
source: sensor.house_load
name: total_house_load
unit_prefix: k
round: 2
method: left
- platform: integration
source: sensor.solar_now
name: total_solar
unit_prefix: k
round: 2
method: left
This has to go in the customize.yaml
sensor.total_grid_out:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
sensor.total_grid_in:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
sensor.total_battery_out:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
sensor.total_battery_in:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
sensor.total_house_load:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
sensor.total_solar:
last_reset: '2021-10-10T00:00:00+00:00'
state_class: total
device_class: energy
value_template: '{{value|round(2)}}'
provided you have defined customize.yaml in configuration.yaml file
homeassistant:
customize: !include customize.yaml
Hope this helps others