Trigger on Dishwasher finished

Hi all,

I’m sorry for this very easy question, but I’m finding it very hard to research this topic and finding my way into the world of HA’s automation/YAML syntax :frowning:

I want to check if my dishwasher is running and increment a counter. If it hits 10/50/x, I want to get a message on my phone via notify.

I found this small code snippet (Discord):

template:
  - binary_sensor:
    - name: spulmaschine_is_running
      id: "spulmaschine"
#      delay_off:
#          minutes: 5
      state: "{{ states('sensor.tasmota1_energy_power')|float > 3 }}"

Now, I don’t understand how to create an automation around that trigger. When I go to automations and add “when template triggers”, I have to insert some YAML code which I couldn’t find examples for on the internet :frowning:
Also, I have no clue what this code means and did not find any syntax explanation …

      state: "{{ states('sensor.tasmota1_energy_power')|float > 3 }}"

Any hint to a blog/web site that explains what this does and how it works is very appreciated!

Thanks in advance for your help!

<edit>
I had found and read this post, but it’s outdated:

<edit2>
I think I might need an automation via yaml and came up with this while studying the internet:

- id: 'spulmaschine_id'
  alias: spulmaschine-automation
  trigger:
    - platform: template
      value_template: "{{ states('binary_sensor.spulmaschine_is_running')}}"
  action: 
  - service: notify.notify
    data:
      message: Hallo
      title: Welt
  mode: single

I have no clue thogh how to test this as I cannot click a button on the GUI to see if that works :frowning: I’m really lost here

What you find on the internet is usually not relevant for you.
But the template returns true or false, if the tasmota energy sensor is above 3 (probably watt).

Post what you have instead and we can help you with your problem.

Thanks for your immediate reply!

Now that I (probably) know when the Tasmota sensor is above 3 something, how do I setup a simple notification/automation? From there on, I might be able to find the rest of the way myself, but I don’t know how to get this started :-/

So I added this to automation.yaml:

- id: 'spulmaschine_id'
  alias: spulmaschine-automation
  trigger:
    - platform: template
      value_template: "{{ states('binary_sensor.spulmaschine_is_running')}}"
  action: 
  - service: notify.notify
    data:
      message: Hello
      title: World
  mode: single

I copied the action from a different automation that I’ve already set up and which works. For the rest, I’m clueless what it does :-/

Was working on similar but wanted a bit more and this I tuned a bit yst.
It sort-off has a flow based on from>to state and tweaking needs to be done depending on the plug and machine but it works now (qed this week)
Make your washing machine smarter with Home Assistant | Emanuele Papa

One way of doing this is creating a counter for you dishwasher runs:

  1. Go to Settings > Devices & Services, select the tab Helpers
  2. Click on Create a helper
  3. Click on Counter
  4. Make sure the option to restore the last know value when Home Assistant starts:
  5. Click “Create”

Then you need an automation to increment your counter every time the dishwasher starts:

  1. Go to Settings > Automation & Scenes and create a new automation.
  2. Select the yaml mode (3-dots menu in the top right) and paste the following code:
description: ""
mode: single
trigger:
  - platform: state
    entity_id:
      - binary_sensor.spulmaschine_is_running
    from: "off"
    to: "on"
    for:
      seconds: 15
condition: []
action:
  - service: counter.increment
    data: {}
    target:
      entity_id: counter.spulmaschine_counter
  1. Save your automation (you will have to give it a name)

Then you can have another automation based on the counter reaching certain value.
Something like this:


alias: spulmaschine-automation
trigger:
  - platform: numeric_state
    entity_id: counter.spulmaschine_counter
    above: 10
  - platform: numeric_state
    entity_id: counter.spulmaschine_counter
    above: 50
action:
  - service: notify.notify
    data:
      message: The dishwasher ran {{ states('counter.spulmaschine_counter') }} times.
mode: single

You can have one trigger per each interval you want or if you have a pattern you can create a template to calculate that.
And you can also add something to reset your counter…
Maybe if you explain what is the point of that message it would be easier to find a better automation.

Wow, thanks for the detailed explanation!

Now it seems that the binary_sensor is not found. I create the yaml-automation like you said and HA shows When something changes from off to on for 15 seconds.

I reloaded all yaml config several times and will reboot HA/the Pi now, but I think something is wrong there :frowning:

What do you mean?

Are you creating the sensor based on that code on your original post?

What if you go Developer Tools, select the tab State and then search for binary_sensor. spulmaschine_is_running?
If the sensor is not existing, try to go to Developer Tools, select the tab Yaml and then reload Templates (or restart Home Assistant).
If the sensor is still not there, could you please take a look on your logs (Settings > System > Logs)?

Ok, so my configuration.yaml is this:


# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

# Text to speech
tts:
  - platform: google_translate

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template: !include templates.yaml

template "spulmaschine":
  - binary_sensor:
    - name: spulmaschine_is_running
      id: "spulmaschine"
#      delay_off:
#          minutes: 5
      state: "{{ states('sensor.tasmota1_energy_power')|float > 3 }}"

I reload configs and everything is ok.

I go to dev tools → status, search for entity “spul” and do not see the binary sensor there:

(sorry its german. I recently set the language to english but the change is not showing …)

In settings/system/logs, I dont see anything in HA Core. I purged the log, then reloaded all configs. Nothing in the logs :frowning:

You can’t make up your own lines like this.
Make that:

template:

I thougt that I had read in the documentation of HA’s YAML that that’s exactly what you have to do after defining template: !somefile.yaml?

Anyway, I changed it to template:
and now I receive the error message YAML file /config/configuration.yaml contains duplicate key "template". Check lines 15 and 17

So I commented the line template: !include templates.yaml as #template: !include templates.yaml

Now I get the error message Invalid config for [template]: [id] is an invalid option for [template]. Check: template->binary_sensor->0->id. (See /config/configuration.yaml, line 18)., so I omitted that id line in the code.

That leaves it at this:

template:
  - binary_sensor:
    - name: spulmaschine_is_running
#      delay_off:
#          minutes: 5
      state: "{{ states('sensor.tasmota1_energy_power')|float > 3 }}"

The state now correctly appears is the dev tools. The automation also correctly displays the new status.

Let’s see if it works properly when the dish washer will run today :smiley:

If you have something set into your templates.yaml file you will miss those sensors
You can instead add your new binary sensor inside the templates.yaml.

By the way, id is an invalid key, but unique_id is valid and using that will enable additional functionalities to your new entity.

1 Like

change applied! :smiley:

1 Like

Uhhhh, it really workers and the sensor is working as well as the automation.

I’m so happy! Thank you so much for your help!! :heart::heart:

2 Likes