Created
October 25, 2023 01:36
-
-
Save bjeanes/37005713f8e9a6ba3a7a3e483e9a96fb to your computer and use it in GitHub Desktop.
sungrow battery maintenance home assistant
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
automation: | |
- id: dbd6c805-f5cf-4c8b-9224-6163a460d620 | |
alias: Inverter - battery maintenance # full cycle discharge and re-charge | |
trigger: | |
# TODO trigger when the battery charge/discharge today registers are below some threshold (however these registers | |
# aren't resetting the way they should currently) | |
# In meantime, we'll just do this at the once per month | |
- platform: time | |
at: "01:00:00" # 1 am | |
condition: | |
- condition: template | |
value_template: "{{ now().day == 1 }}" # but only on first of the month | |
variables: | |
ems_mode: | | |
{% set ems = states('sensor.inverter_ems_mode_raw') | int(default=0) %} | |
forced_battery_mode: | | |
{% set mode = states('sensor.inverter_forced_battery_mode_raw') | int(default=0) %} | |
action: | |
# snapshot scene of current charge/discharge power and reserve battery % | |
- service: scene.create | |
data: | |
scene_id: inverter_battery_maintenance | |
snapshot_entities: | |
- input_number.inverter_forced_mode_battery_power | |
- input_number.inverter_battery_reserve | |
# set reserve battery power to 0 | |
- service: input_number.set_value | |
target: | |
entity_id: input_number.inverter_battery_reserve | |
data: | |
value: 0 | |
# set charge/discharge power to 1kW | |
- service: input_number.set_value | |
target: | |
entity_id: input_number.inverter_forced_mode_battery_power | |
data: | |
value: 1000 | |
- service: script.inverter_force_battery_discharge | |
- delay: 00:00:30 | |
# Wait until no further battery power to become idle | |
- wait_for_trigger: | |
- platform: state | |
entity_id: sensor.inverter_battery_power_raw | |
to: 0 | |
for: | |
minutes: 5 | |
# Start charging steadily at charge power until it becomes idle (reaches its max) | |
- service: script.inverter_force_battery_charge | |
- delay: 00:00:30 | |
# Wait until no further battery power to become idle | |
- wait_for_trigger: | |
- platform: state | |
entity_id: sensor.inverter_battery_power_raw | |
to: 0 | |
for: | |
minutes: 5 | |
- service: script.inverter_force_battery_stop | |
- delay: 00:00:10 | |
# Apply snapshotted scene from beginning of automation | |
- service: scene.apply | |
data: | |
scene_id: inverter_battery_maintenance | |
# Reset the battery mode to whatever it was before | |
- service: modbus.write_register | |
data_template: | |
address: 13049 # 13050-13051 | |
slave: 1 | |
value: | |
- "{{ ems_mode }}" | |
- "{{ forced_battery_mode }}" | |
hub: SungrowSHx |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment