Notify or do something when an appliance like a dishwasher or washing machine finishes

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.

1 Like

Yeah that solution with choose is not very elegant. The underlying problem I had was I tried first with this:

action:
  - wait_for_trigger:
      - platform: numeric_state
        entity_id: !input power_sensor
        below: !input finishing_threshold
        for:
          minutes: !input finishing_hysteresis
action: !input actions

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.

1 Like

I think the question was , why do you have such condition, as it should work without it anyway… Even it is not a condition, its just a declaration :slight_smile:

RIght, okay was probably just too lazy to test if it works without the condition :wink:

If nothing else, it would be a good submission to a code-obfuscation contest.

4 Likes

I changed it now to:

  - choose: []
    default: !input actions

If you prefer using Github Gist over the forum posts I will now track this Blueprint here: https://gist.github.com/sbyx/6d8344d3575c9865657ac51915684696

Link has been added to the original post as well.

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):

You would need one such choose-block for every person.

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
11 Likes

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

What am I doing wrong?

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.

Screenshot 2020-12-21 at 15.30.07

Also shows here that the device class is power?

Screenshot 2020-12-21 at 15.33.40

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:

  - platform: template
    sensors:
      garage_tumble_dryer_29_watts:
        friendly_name_template: "{{ states.garage_tumble_dryer_29.name}} power"
        value_template: '{{ states.switch.garage_tumble_dryer_29.attributes["current_power_w"] |float }}'
        unit_of_measurement: 'W'

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.

1 Like

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

and

trigger:
- platform: numeric_state
  entity_id: !input 'power_sensor'
  for:
    minutes: !input 'starting_hysteresis'
  above: !input 'starting_threshold'
condition: []
action:
- wait_for_trigger:
  - platform: numeric_state
    entity_id: !input 'power_sensor'
    below: !input 'finishing_threshold'
    for:
      minutes: !input 'finishing_hysteresis'
- choose: []
  default: !input 'actions'

to

trigger:
- platform: numeric_state
  entity_id: !input 'power_sensor'
  attribute: current_power_w
  for:
    minutes: !input 'starting_hysteresis'
  above: !input 'starting_threshold'
condition: []
action:
- wait_for_trigger:
  - platform: numeric_state
    entity_id: !input 'power_sensor'
    attribute: current_power_w
    below: !input 'finishing_threshold'
    for:
      minutes: !input 'finishing_hysteresis'
- choose: []
  default: !input 'actions'
4 Likes

Absolute magic :slight_smile:

Went with the second option as I have a few of these devices so it seemed to be the simplest way to cater for all of them.

Thank you for your help.

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?

In principle yes by modifying the blueprint and taking timestamps as first and last actions. However you wouldn’t really get useful values from that alone for the consumption since the power draw on most of these devices heavily fluctuates over time, e.g. when water is heated or not. There are esp. on ZigBee smartplugs available that actually do have a consumption sensor that gives you a kWh value. If you have one of these you can more or less figure it out by taking that value at the start and end a calculate the difference.

Works like a charm! Thank you very much @Sbyx

1 Like