automation/charge_battery.yaml

60 lines
2 KiB
YAML

alias: charge battery
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.very_cheap_electricity
- platform: state
entity_id:
- sensor.octopus_energy_electricity_17l0054650_1100015280504_current_rate
- platform: state
entity_id:
- input_boolean.keep_battery_charged
condition: []
action:
- alias: Charge if very cheap or if we really need it
if:
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.very_cheap_electricity
state: "on"
- condition: state
entity_id: input_boolean.keep_battery_charged
state: "on"
alias: very cheap electricity or manual charge forced
then:
- service: script.charge_battery
data: {}
else:
- alias: Charge if cheap-ish and we really need it
if:
- condition: state
entity_id: binary_sensor.octopus_energy_target_cheapest_2h_before_morning
state: "on"
- condition: numeric_state
entity_id: sensor.house_energy_left
below: sensor.average_daily_electricity_consumption
then:
- service: script.charge_battery
data: {}
else:
- alias: continue charging if still relatively cheap or stop
if:
- condition: and
conditions:
- alias: relatively cheap electricity still
condition: numeric_state
entity_id: >-
sensor.octopus_energy_electricity_17l0054650_1100015280504_current_rate
below: 0.1
- condition: numeric_state
entity_id: sensor.growatt_batterystateofcharge
above: 94
then:
- service: script.charge_battery
data: {}
else:
- service: script.go_back_to_normal_battery_charging
data: {}
mode: single