Skip to content

Instantly share code, notes, and snippets.

@lparry
Last active December 9, 2025 21:17
Show Gist options
  • Select an option

  • Save lparry/34d1f94710bd366628e5aa6c8b9a0152 to your computer and use it in GitHub Desktop.

Select an option

Save lparry/34d1f94710bd366628e5aa6c8b9a0152 to your computer and use it in GitHub Desktop.
Appliance Cycle Power Usage
blueprint:
name: Appliance Cycle Power Usage
description: >
Detects an appliance cycle start/end from power usage, calculates energy
and cost, and sends a notification.
domain: automation
input:
appliance_name:
name: Appliance name
description: Used in notification text (e.g. Dishwasher, Washing Machine)
default: Appliance
selector:
text:
power_sensor:
name: Power sensor
description: Sensor reporting instantaneous power (W)
selector:
entity:
domain: sensor
energy_sensor:
name: Energy sensor
description: Sensor reporting cumulative energy (kWh)
selector:
entity:
domain: sensor
energy_start_helper:
name: Energy start helper
description: input_number used to store starting energy reading
selector:
entity:
domain: input_number
start_threshold:
name: Start threshold (W)
description: Power above this means the cycle has started
default: 10
selector:
number:
min: 0
max: 2000
step: 1
idle_threshold:
name: Idle threshold (W)
description: Power below this (for a while) means the cycle is finished
default: 5
selector:
number:
min: 0
max: 200
step: 1
idle_time:
name: Idle duration
description: How long power must stay below idle threshold
default: "00:05:00"
selector:
duration:
energy_price:
name: Energy price ($/kWh)
description: Used to estimate cycle cost
default: 0.30
selector:
number:
min: 0
max: 2
step: 0.01
notify_target:
name: Notification target
description: Where to send the completion notification
selector:
target:
entity:
domain: notify
mode: single
variables:
appliance_name: !input appliance_name
power_sensor: !input power_sensor
energy_sensor: !input energy_sensor
energy_start_helper: !input energy_start_helper
start_threshold: !input start_threshold
idle_threshold: !input idle_threshold
idle_time: !input idle_time
energy_price: !input energy_price
trigger:
- id: cycle_start
platform: numeric_state
entity_id: !input power_sensor
above: !input start_threshold
- id: cycle_complete
platform: numeric_state
entity_id: !input power_sensor
below: !input idle_threshold
for: !input idle_time
action:
- choose:
# Store starting energy when cycle starts
- conditions:
- condition: trigger
id: cycle_start
sequence:
- service: input_number.set_value
target:
entity_id: !input energy_start_helper
data:
value: "{{ states(energy_sensor) | float(0) }}"
# Notify and compute usage when cycle finishes
- conditions:
- condition: trigger
id: cycle_complete
sequence:
- variables:
energy_start: "{{ states(energy_start_helper) | float(0) }}"
energy_now: "{{ states(energy_sensor) | float(0) }}"
energy_used: "{{ (energy_now - energy_start) | float(0) }}"
cost: "{{ (energy_used * energy_price) | float(0) }}"
- service: notify.notify
target: !input notify_target
data:
title: "{{ appliance_name }} cycle complete"
message: >
{{ appliance_name }} cycle finished.
Energy used: {{ energy_used | round(2) }} kWh.
Estimated cost: ${{ cost | round(2) }}.
- service: input_number.set_value
target:
entity_id: !input energy_start_helper
data:
value: "{{ energy_now }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment