Thanks for this @Doublet !
The default scan interval for the rest sensor is 30 seconds. The update frequency is 5 minutes on Solax side, so the scan interval isn’t going to change things.
I have two Solax inverters (X1 and X3) and I saw in the API documentation there is a request limit of 10000/day. So I changed the sensor a bit, with the purpose of making one rest call and extracting the data I need for the sensors.
## X3 ##
- platform: rest
resource: https://www.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=202102060300yyyyyyy&sn=SWXXXXXXX
name: "Solax X3"
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_x3_today:
friendly_name: "Solax X3 today"
value_template: "{{ state_attr('sensor.solax_x3', 'yieldtoday') }}"
unit_of_measurement: "KWh"
solax_x3_total:
friendly_name: "Solax X3 total"
value_template: "{{ state_attr('sensor.solax_x3', 'yieldtotal') }}"
unit_of_measurement: "KWh"
solax_x3_now:
friendly_name: "Solax X3 now"
value_template: "{{ state_attr('sensor.solax_x3', 'acpower') }}"
unit_of_measurement: "W"
solax_x3_upload_time:
friendly_name: "Solax X3 upload time"
value_template: "{{ state_attr('sensor.solax_x3', 'uploadTime') }}"
solax_x3_status:
friendly_name: "Solax X3 status"
value_template: >
{% if state_attr('sensor.solax_x3', 'inverterStatus') == '100' %}Wait
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '101' %}Check
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '102' %}Normal
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '103' %}Fault
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '104' %}Permanent Fault
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '105' %}Update
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '106' %}EPS Check
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '107' %}EPS
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '108' %}Self-test
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '109' %}Idle
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '110' %}Standby
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '111' %}Pv Wake Up Bat
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '112' %}Gen Check
{% elif state_attr('sensor.solax_x3', 'inverterStatus') == '113' %}Gen Run
{% else %}I dont know{% endif %}
## X1 ##
- platform: rest
resource: https://www.eu.solaxcloud.com:9443/proxy/api/getRealtimeInfo.do?tokenId=20210517200601yyyyyyyyyyyy&sn=SWXXXXXXXXX
name: "Solax X1"
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_x1_today:
friendly_name: "Solax X1 today"
value_template: "{{ state_attr('sensor.solax_x1', 'yieldtoday') }}"
unit_of_measurement: "KWh"
solax_x1_total:
friendly_name: "Solax X1 total"
value_template: "{{ state_attr('sensor.solax_x1', 'yieldtotal') }}"
unit_of_measurement: "KWh"
solax_x1_now:
friendly_name: "Solax X1 now"
value_template: "{{ state_attr('sensor.solax_x1', 'acpower') }}"
unit_of_measurement: "W"
solax_x1_upload_time:
friendly_name: "Solax X1 upload time"
value_template: "{{ state_attr('sensor.solax_x1', 'uploadTime') }}"
solax_x1_status:
friendly_name: "Solax X1 status"
value_template: >
{% if state_attr('sensor.solax_x1', 'inverterStatus') == '100' %}Wait
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '101' %}Check
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '102' %}Normal
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '103' %}Fault
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '104' %}Permanent Fault
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '105' %}Update
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '106' %}EPS Check
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '107' %}EPS
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '108' %}Self-test
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '109' %}Idle
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '110' %}Standby
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '111' %}Pv Wake Up Bat
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '112' %}Gen Check
{% elif state_attr('sensor.solax_x1', 'inverterStatus') == '113' %}Gen Run
{% else %}I dont know{% endif %}
And sensors to sum both inverters:
- platform: template
sensors:
solax_today:
friendly_name: Solax today
unit_of_measurement: kWh
value_template: "{{ (states('sensor.solax_x1_today') | float) + (states('sensor.solax_x3_today') | float) }}"
solax_now:
friendly_name: Solax now
unit_of_measurement: W
value_template: "{{ (states('sensor.solax_x1_now') | float) + (states('sensor.solax_x3_now') | float) }}"
solax_total:
friendly_name: Solax total
unit_of_measurement: KWh
value_template: "{{ (states('sensor.solax_x1_total') | float) + (states('sensor.solax_x3_total') | float) }}"