Skip to content

Instantly share code, notes, and snippets.

@jamesog
Created December 5, 2024 18:31
Show Gist options
  • Save jamesog/0b1f097de0165d259383da5438990c5b to your computer and use it in GitHub Desktop.
Save jamesog/0b1f097de0165d259383da5438990c5b to your computer and use it in GitHub Desktop.
Home Assistant automation for force charging FoxESS batteries based on Octopus Agile price and time window
alias: Agile price charge
description: >-
Set the inverter to force charge when we're in the time window and the
Octoppus Agile price is at or below the threshold.
trigger:
- platform: state
entity_id:
- binary_sensor.charge_window
from: "off"
to: "on"
- platform: state
entity_id:
- binary_sensor.charge_window
from: "on"
to: "off"
- platform: state
entity_id:
- sensor.octopus_energy_electricity_xxx_xxx_current_rate
condition:
- condition: state
entity_id: input_boolean.agile_charging_enabled
state: "on"
- condition: state
entity_id: schedule.force_charge
state: "off"
action:
- if:
- condition: state
entity_id: input_boolean.agile_charging_enabled
state: "on"
- condition: state
entity_id: binary_sensor.charge_window
state: "on"
- condition: template
value_template: >-
{% set cur_price =
states('sensor.octopus_energy_electricity_xxx_xxx_current_rate')
| float %}
{% set threshold = states('input_number.agile_price_threshold') |
float / 100 %}
{{ cur_price <= threshold }}
alias: Confirm Agile price meets threshold
then:
- action: notify.mobile_app_phone
metadata: {}
data:
message: Agile price is below threshold and is in time window
title: Starting charge
- action: select.select_option
metadata: {}
data:
option: Force Charge
target:
entity_id: select.work_mode
else:
- condition: state
entity_id: binary_sensor.charge_window
state: "off"
enabled: false
- condition: state
entity_id: select.work_mode
state: Force Charge
- action: notify.mobile_app_phone
metadata: {}
data:
title: Stopping charge
message: Window has ended
- action: select.select_option
metadata: {}
data:
option: Self Use
target:
entity_id: select.work_mode
mode: single
trace:
stored_traces: 48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment