Skip to content

Instantly share code, notes, and snippets.

@jonmunson
Last active October 24, 2025 18:03
Show Gist options
  • Select an option

  • Save jonmunson/d81935b066cc521f346a68539b8999d0 to your computer and use it in GitHub Desktop.

Select an option

Save jonmunson/d81935b066cc521f346a68539b8999d0 to your computer and use it in GitHub Desktop.
πŸ™ Free Electricity session blueprint
blueprint:
name: Octopus Energy Free Electricity Session Manager (Interactive)
description: >
Automatically manage devices during Octopus Energy free electricity sessions with optional confirmation prompts.
Charges batteries, controls heating based on temperature, and runs dehumidifiers when needed.
domain: automation
input:
calendar_entity:
name: Free Electricity Calendar
description: Your Octopus Energy free electricity session calendar
selector:
entity:
domain: calendar
notification_device:
name: Mobile Device for Notifications
description: Mobile app notification service (e.g., mobile_app_iphone)
selector:
text:
warning_time:
name: Warning Time (minutes)
description: How many minutes before session starts to send a warning notification
default: 5
selector:
number:
min: 0
max: 60
unit_of_measurement: minutes
require_confirmation:
name: Require Confirmation
description: Ask for confirmation before starting actions (you'll have 2 minutes to respond)
default: true
selector:
boolean:
battery_charge_service:
name: Battery Charge Start Service
description: Service to call to start battery charging (e.g., foxess_em.enable_force_charge)
default: ""
selector:
text:
battery_charge_entity:
name: Battery/Inverter Entity
description: The entity to control for battery charging
default: ""
selector:
entity:
battery_stop_service:
name: Battery Charge Stop Service
description: Service to call to stop battery charging (e.g., foxess_em.disable_force_charge)
default: ""
selector:
text:
heating_entity:
name: Heating/Climate Entity
description: Climate entity to control (leave empty to disable)
default: ""
selector:
entity:
domain: climate
heating_boost_temp:
name: Heating Boost Temperature
description: Temperature to set during free electricity
default: 22
selector:
number:
min: 15
max: 30
unit_of_measurement: "Β°C"
heating_normal_temp:
name: Normal Heating Temperature
description: Temperature to return to after free electricity
default: 19
selector:
number:
min: 15
max: 30
unit_of_measurement: "Β°C"
outdoor_temp_sensor:
name: Outdoor Temperature Sensor
description: Only heat if outdoor temp is below threshold (leave empty to use winter months only)
default: ""
selector:
entity:
domain: sensor
device_class: temperature
heating_temp_threshold:
name: Heating Temperature Threshold
description: Only enable heating if outdoor temp is below this (Β°C)
default: 12
selector:
number:
min: 0
max: 20
unit_of_measurement: "Β°C"
heating_months:
name: Heating Months (if no temp sensor)
description: Only enable heating control during these months
default: [11, 12, 1, 2, 3]
selector:
select:
multiple: true
options:
- January
- February
- March
- April
- May
- June
- July
- August
- September
- October
- November
- December
dehumidifier_switches:
name: Dehumidifier Switches
description: Switches to turn on for dehumidifiers (leave empty to disable)
default: []
selector:
entity:
multiple: true
domain: switch
humidity_sensor:
name: Indoor Humidity Sensor
description: Only run dehumidifiers if humidity is above threshold
default: ""
selector:
entity:
domain: sensor
device_class: humidity
humidity_threshold:
name: Humidity Threshold
description: Only run dehumidifiers if humidity is above this (%)
default: 60
selector:
number:
min: 40
max: 80
unit_of_measurement: "%"
dehumidifier_exclude_months:
name: Don't Run Dehumidifiers In
description: Don't run dehumidifiers during these months (e.g., summer)
default: [6, 7, 8]
selector:
select:
multiple: true
options:
- January
- February
- March
- April
- May
- June
- July
- August
- September
- October
- November
- December
mode: queued
max_exceeded: silent
variables:
calendar: !input calendar_entity
notify_service: !input notification_device
warning_mins: !input warning_time
needs_confirmation: !input require_confirmation
battery_entity: !input battery_charge_entity
battery_start_service: !input battery_charge_service
battery_stop_service: !input battery_stop_service
heating_entity: !input heating_entity
heating_boost: !input heating_boost_temp
heating_normal: !input heating_normal_temp
outdoor_temp_sensor: !input outdoor_temp_sensor
heating_threshold: !input heating_temp_threshold
heating_months: !input heating_months
dehumidifier_switches: !input dehumidifier_switches
humidity_sensor: !input humidity_sensor
humidity_threshold: !input humidity_threshold
dehumidifier_exclude_months: !input dehumidifier_exclude_months
trigger:
- platform: calendar
entity_id: !input calendar_entity
event: start
offset: "-00:{{ warning_mins | int | abs }}:00"
id: warning
- platform: calendar
entity_id: !input calendar_entity
event: start
id: start
- platform: calendar
entity_id: !input calendar_entity
event: end
id: end
- platform: event
event_type: mobile_app_notification_action
event_data:
action: CONFIRM_BATTERY
id: confirm_battery
- platform: event
event_type: mobile_app_notification_action
event_data:
action: CONFIRM_HEATING
id: confirm_heating
- platform: event
event_type: mobile_app_notification_action
event_data:
action: CONFIRM_DEHUMIDIFIER
id: confirm_dehumidifier
action:
- choose:
- conditions:
- condition: trigger
id: warning
sequence:
- service: "notify.{{ notify_service }}"
data:
title: "⚑ Free Electricity Starting Soon"
message: >
Free electricity starts in {{ warning_mins }} minute{{ 's' if warning_mins|int != 1 else '' }}!
Window: {{ state_attr(calendar, 'start_time') | as_timestamp | timestamp_custom('%H:%M') }} - {{ state_attr(calendar, 'end_time') | as_timestamp | timestamp_custom('%H:%M') }}
- conditions:
- condition: trigger
id: start
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ needs_confirmation }}"
sequence:
# Battery
- if:
- condition: template
value_template: "{{ battery_start_service != '' and battery_entity != '' }}"
then:
- service: "notify.{{ notify_service }}"
data:
title: "πŸ”‹ Charge Batteries?"
message: "Free electricity is active. Charge house batteries?"
data:
actions:
- action: CONFIRM_BATTERY
title: "Yes, Charge"
- action: DENY_BATTERY
title: "No"
tag: battery_confirm
# Heating
- if:
- condition: template
value_template: "{{ heating_entity != '' }}"
- condition: template
value_template: >
{{ (outdoor_temp_sensor != '' and (states(outdoor_temp_sensor) | float(99)) < heating_threshold)
or (outdoor_temp_sensor == '' and now().month in heating_months) }}
then:
- service: "notify.{{ notify_service }}"
data:
title: "πŸ”₯ Boost Heating?"
message: >
{% if outdoor_temp_sensor != '' %}
Outdoor temp: {{ states(outdoor_temp_sensor) }}Β°C. Boost heating to {{ heating_boost }}Β°C?
{% else %}
Boost heating to {{ heating_boost }}Β°C during free electricity?
{% endif %}
data:
actions:
- action: CONFIRM_HEATING
title: "Yes, Heat"
- action: DENY_HEATING
title: "No"
tag: heating_confirm
# Dehumidifiers
- if:
- condition: template
value_template: >
{{ dehumidifier_switches | length > 0 and
now().month not in dehumidifier_exclude_months and
((humidity_sensor != '' and (states(humidity_sensor) | float(0)) > humidity_threshold)
or (humidity_sensor == '')) }}
then:
- service: "notify.{{ notify_service }}"
data:
title: "πŸ’§ Run Dehumidifiers?"
message: >
{% if humidity_sensor != '' %}
Humidity: {{ states(humidity_sensor) }}%. Run dehumidifiers?
{% else %}
Run dehumidifiers during free electricity?
{% endif %}
data:
actions:
- action: CONFIRM_DEHUMIDIFIER
title: "Yes, Run"
- action: DENY_DEHUMIDIFIER
title: "No"
tag: dehumidifier_confirm
- service: "notify.{{ notify_service }}"
data:
title: "⚑ Free Electricity Active"
message: >
Session active until {{ state_attr(calendar, 'end_time') | as_timestamp | timestamp_custom('%H:%M') }}.
Respond to prompts above to enable actions.
- conditions:
- condition: template
value_template: "{{ not needs_confirmation }}"
sequence:
- parallel:
- if:
- condition: template
value_template: "{{ battery_start_service != '' and battery_entity != '' }}"
then:
- service: "{{ battery_start_service }}"
target:
entity_id: "{{ battery_entity }}"
- if:
- condition: template
value_template: >
{{ heating_entity != '' and ((outdoor_temp_sensor != '' and (states(outdoor_temp_sensor) | float(99)) < heating_threshold)
or (outdoor_temp_sensor == '' and now().month in heating_months)) }}
then:
- service: climate.set_temperature
target:
entity_id: "{{ heating_entity }}"
data:
temperature: "{{ heating_boost }}"
- if:
- condition: template
value_template: >
{{ dehumidifier_switches | length > 0 and
now().month not in dehumidifier_exclude_months and
((humidity_sensor != '' and (states(humidity_sensor) | float(0)) > humidity_threshold)
or (humidity_sensor == '')) }}
then:
- service: switch.turn_on
target:
entity_id: "{{ dehumidifier_switches }}"
- service: "notify.{{ notify_service }}"
data:
title: "⚑ Free Electricity Active"
message: "All enabled actions started automatically."
- conditions:
- condition: trigger
id: confirm_battery
sequence:
- service: "{{ battery_start_service }}"
target:
entity_id: "{{ battery_entity }}"
- service: "notify.{{ notify_service }}"
data:
title: "πŸ”‹ Battery Charging Started"
message: "House batteries are now charging"
- conditions:
- condition: trigger
id: confirm_heating
sequence:
- service: climate.set_temperature
target:
entity_id: "{{ heating_entity }}"
data:
temperature: "{{ heating_boost }}"
- service: "notify.{{ notify_service }}"
data:
title: "πŸ”₯ Heating Boosted"
message: "Heating set to {{ heating_boost }}Β°C"
- conditions:
- condition: trigger
id: confirm_dehumidifier
sequence:
- service: switch.turn_on
target:
entity_id: "{{ dehumidifier_switches }}"
- service: "notify.{{ notify_service }}"
data:
title: "πŸ’§ Dehumidifiers Running"
message: "Dehumidifiers turned on"
- conditions:
- condition: trigger
id: end
sequence:
- if:
- condition: template
value_template: "{{ battery_stop_service != '' and battery_entity != '' }}"
then:
- service: "{{ battery_stop_service }}"
target:
entity_id: "{{ battery_entity }}"
- if:
- condition: template
value_template: "{{ heating_entity != '' }}"
then:
- service: climate.set_temperature
target:
entity_id: "{{ heating_entity }}"
data:
temperature: "{{ heating_normal }}"
- if:
- condition: template
value_template: "{{ dehumidifier_switches | length > 0 }}"
then:
- service: switch.turn_off
target:
entity_id: "{{ dehumidifier_switches }}"
- service: "notify.{{ notify_service }}"
data:
title: "⚑ Free Electricity Ended"
message: "Session finished. All devices returned to normal."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment