Skip to content

Instantly share code, notes, and snippets.

@kneath
Last active March 8, 2025 18:49
Show Gist options
  • Save kneath/c5cc1f92f082cc6624767f2d08d42e67 to your computer and use it in GitHub Desktop.
Save kneath/c5cc1f92f082cc6624767f2d08d42e67 to your computer and use it in GitHub Desktop.
Home Assistant scripts to replace Span Panel circuit prioritization logic.
alias: Energy Mode Reaction
description: ""
triggers:
- entity_id:
- input_select.energy_mode
trigger: state
conditions: []
actions:
- if:
- condition: state
entity_id: input_select.energy_mode
state: Full Power
then:
- action: script.turn_on_all_circuits
metadata: {}
data: {}
- if:
- condition: state
entity_id: input_select.energy_mode
state: Backup - Momentary
then:
- action: script.turn_off_non_essential_circuits
metadata: {}
data: {}
- if:
- condition: state
entity_id: input_select.energy_mode
state: Backup - Extended
then:
- action: script.turn_off_nice_to_have_circuits
metadata: {}
data: {}
mode: single
alias: Grid Failure (Long)
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.grid_state
from: "on"
to: "off"
for:
hours: 0
minutes: 30
seconds: 0
conditions: []
actions:
- action: input_select.select_option
metadata: {}
data:
option: Backup - Extended
target:
entity_id: input_select.energy_mode
- action: script.notify_all_ios_devices
data:
title: Power Outage
message: >-
Power has been out over 30 minutes, turning off nice to have circuits to
conserve power
mode: single
alias: Grid Failure (Short)
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.grid_state
from: "on"
to: "off"
for:
hours: 0
minutes: 2
seconds: 0
conditions: []
actions:
- action: input_select.select_option
metadata: {}
data:
option: Backup - Momentary
target:
entity_id: input_select.energy_mode
- action: script.notify_all_ios_devices
data:
title: Power Outage
message: There's been a power outage, non-essential circuits have been turned off
mode: single
alias: Grid Restored
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.grid_state
from: "off"
to: "on"
for:
hours: 0
minutes: 2
seconds: 0
conditions: []
actions:
- action: input_select.select_option
metadata: {}
data:
option: Full Power
target:
entity_id: input_select.energy_mode
- action: script.notify_all_ios_devices
data:
title: Power Restored
message: Power has been restored and all circuits have been turned back on
mode: single
{{ states('sensor.dsm_state') != 'DSM_ISLANDED' and states('sensor.dsm_state_3') != 'DSM_ISLANDED' }}
alias: Turn Off Nice to Have Circuits
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
label_id:
- power_nice_to_have
- power_non_essential
description: ""
icon: mdi:battery-charging-90
alias: Turn off Non-Essential Circuits
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
label_id: power_non_essential
description: ""
icon: mdi:battery-charging-90
alias: Turn On All Circuits
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
label_id:
- power_non_essential
- power_nice_to_have
description: ""
icon: mdi:battery-charging-90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment