This one is pretty simple. It triggers a set of user defined actions when some appliance like a dishwasher or washing machine has finished after running. It uses a power sensor to detect finishing. First we check that the thing has been started, i.e. crossing a certain power threshold for a given time. This is necessary so the action is not triggered at startup or after reloading automations. Then we detect that the appliance has finished by waiting until it crosses below a certain power level for some time. The actions to perform e.g. push notification or TTS announcement via Google Home can be freely chosen.
Blueprint Code
Click the badge to import this Blueprint: (needs Home Assistant Core 2021.3 or higher)
Or import this Blueprint by using the forum topic / Gist URL:
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.
domain: automation
input:
power_sensor:
name: Power Sensor
description: Power sensor entity (e.g. from a smart plug device).
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:
name: Actions
description: Actions (e.g. pushing a notification, TTS announcement, ...)
selector:
action: {}
pre_actions:
name: Actions
description: Actions when starting threshhold is crossed
selector:
action: {}
source_url: https://gist.github.com/sbyx/6d8344d3575c9865657ac51915684696
trigger:
- platform: numeric_state
entity_id: !input 'power_sensor'
for:
minutes: !input 'starting_hysteresis'
above: !input 'starting_threshold'
condition: []
action:
- choose: []
default: !input 'pre_actions'
- wait_for_trigger:
- platform: numeric_state
entity_id: !input 'power_sensor'
below: !input 'finishing_threshold'
for:
minutes: !input 'finishing_hysteresis'
- choose: []
default: !input 'actions'
mode: single
max_exceeded: silent
Changelog
2022-03-04: Add additional action block at startup
2020-12-30: Increase hysteresis resolution to 1/4 minutes
2020-12-27: Relax selector since HA has very inconsistent device_classes.
Can you explain why the action uses choose that offers only one condition and that condition always evaluates to true. Seems like a lot of code for nothing.
however that way wait_for_trigger wasnât executed and the notification was fired instantly. I tried several other varaints but they all resulted in some sort of syntax error. So next best thing that came to my mind was a choose with an always-true condition and that somehow worked. If anyone has a proper solution I would appreciate it.
With the notify is there a way to only send the notification to people who are actually at home? Like if the washing is finished and I am at work I donât want the notification.
Sure, I am not predefining any actual notification here you can freely define that in the actions section if you want to notify via the app based on the device being in the WiFi for example or if you have person tracking in HA you can do something like this (taken from one of my automations):
Thanks for the blueprint, works great! The hysteresis in minutes is a bit coarse, but it works. Easily changeable to seconds (or both a minutes and seconds slider) if I really wanted.
For the conditions you could also add a condition action before your notification. I have an input_boolean for âquiet modeâ which I use to turn off announcements when it is on (condition is state, input_boolean.quiet_mode âoffâ)
Iâve also adapted a version of this to an acceleration/vibration sensor using a SmartThings multipurpose sensor (class: moving) rather than power sensor for my dryer and dishwasher which canât use a power sensor (dryer is 240V, dishwasher is hard wired).
blueprint:
name: Appliance has finished shaking
description: Do something when an appliance (like a washing machine or dishwasher)
has finished as detected by a vibration sensor.
domain: automation
input:
vibration_sensor:
name: Vibration Sensor
description: 'Vibration sensor entity (e.g. from a multipurpose sensor). Needs to have device_class:
moving'
selector:
entity:
domain: binary_sensor
device_class: moving
starting_hysteresis:
name: Starting hysteresis
description: Time duration the sensor has to stay on.
default: 5
selector:
number:
min: 1.0
max: 60.0
unit_of_measurement: min
mode: slider
step: 1.0
finishing_hysteresis:
name: Finishing hysteresis
description: Time duration the sensor has to stay off.
default: 5
selector:
number:
min: 1.0
max: 60.0
unit_of_measurement: min
mode: slider
step: 1.0
actions:
name: Actions
description: Actions (e.g. pushing a notification, TTS announcement, ...)
selector:
action: {}
trigger:
- platform: state
entity_id: !input 'vibration_sensor'
to: 'on'
for:
minutes: !input 'starting_hysteresis'
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: !input 'vibration_sensor'
to: 'off'
for:
minutes: !input 'finishing_hysteresis'
- choose: []
default: !input 'actions'
mode: single
max_exceeded: silent
I have an entity pulled in from my Fibaro HC2 which I am trying to customise to include the device class of power. No matter what I do, I canât seem to get this blueprint to use the entity I need.
Iâve added customize.yaml to configuration. customize.yaml shows this for the deviceâŚ
switch.garage_tumble_dryer_29:
device_class: power
Usually the switch itself will not give the power measurement but only has a state âonâ or âoffâ related to if it switched off or on. However there should be a separate sensor entity (maybe with a similar name) that provides it. I donât own any Z-Wave gear so not particularly sure how it works with those in practice.
If I use the entity in an automation it shows me some of the other attributes like the power measurements. I wonder if itâs because Iâm pulling it in via Fibaro.
The device is a switch, the power is an attribute of the switch (current_power_w).
You will need to make a template sensor to use this with the blueprint as-is, or change the blueprint to use the current_power_w attribute of this switch entity.
To add the attribute as a power sensor and keep the blueprint the same, add this to configuration.yaml:
Also note that this doesnât make it a power sensor, so you will need to manually type the entity âsensor.garage_tumble_dryer_29_wattsâ into the sensor entity.
I havnât checked on whether you can specify an attribute in blueprints, so donât have code for that. This does work though - my power sensor (TP-Link Kasa) is an attribute using this code.
Instead of creating a template sensor in the above post, you could instead modify the blueprint to use the current_power_w attribute of your switch.
To do this, change the following:
Change:
name: Power Sensor
description: "Power sensor entity (e.g. from a smart plug). Needs to have device_class: power"
selector:
entity:
domain: sensor
device_class: power
to
name: Power Sensor
description: "Power sensor entity (e.g. from a smart plug). Needs to be a switch with a current_power_w attribute"
selector:
entity:
domain: switch
# device_class: power
Thanks for this automation but is there a way to get the amount of time that the dish washer/washing machine has been above the threshold so that the energy usage can be worked out?