Washing Machine Automation

Have a automation that has been working fine

Just wanted to get it to repeat the tts action if I don’t open the door
that way it reminds me until I open the garage door to move clothes into the dryer.

The condition is what I added and the tts message works but it does not
repeat after 1 minute.

Tried it many ways and just can’t get it to repeat and then stop
when I open the door.

Any help would be great.

- id: nineteen
  alias: "Washing Machine OFF state"
  trigger:
    - platform: numeric_state
      entity_id: sensor.washer_watts
      below: '2'
  condition:
    - condition: state
      entity_id: binary_sensor.visonic_mct340_e_0b3e19fb_1_1280
      state: 'off'
      for:
        minutes: 1
   action:
    - service: tts.google_say
       entity_id: media_player.ccaudio_media
      data_template:
        message: >
          Washing Machine is now done and turned off.
    - service: notify.HA_NOTIFIER
      data:
          title: 'Washing Machine Done'
          message: 'Washing Machine Off'

Your condition basically means your binary_sensor.visonic_mct340_e_0b3e19fb_1_1280 needs to be off for at least 1 min for the condition to be true, it does not mean it’ll keep running the automation.
In addition, your automation will only trigger if your sensor.washer_watts changes, the chances are when your washing machine is done it won’t use much power and will probably return the same power usage.
Best would be to have an automation to run every minute, then you can add conditions to check that:

  1. there was a washing program that took place in the last xxx hours
  2. your power consumption is less than 2 watts for more than xx sec
    3 the door has not been opened the washing cycle completed.

All in all it’s going to be a little bit complex, but not impossible. This is how I would approach it:

  1. Have an automation that triggers on sensor.washer_watts and sets an input_boolean (e.g. washing_in_progress ) to on with conditions power consumption is over 2 Watts AND the input_boolean is off:
  2. Have an automation that triggers on sensor.washer_watts and sets an input_boolean (e.g. washing_in_progress ) to off with conditions power consumption is below 2 Watts AND the input_boolean is on:
    Now you know whether there is a washing cycle in progress.
    Create a 3rd automation that runs every min with conditions A.time since door open last updated is older than time since your input boolean was last updated and B. input_boolean is off
    action: your tts messages as above.

You first condition above will look like:

    - condition: template
      value_template: '{{ (as_timestamp(states.binary_sensor.visonic_mct340_e_0b3e19fb_1_1280.attributes.last_changed | default(0)) | int) < (as_timestamp(states.input_boolean.washing_in_progress.attributes.last_changed | default(0)) | int )}}'

Doesn’t https://www.home-assistant.io/components/alert/ do exactly what @wakeskate wants to achieve?

Well yes because it would take care of the “every min” bit, but there is still a need to sort the sensor for alert to react on.
And you can’t have a template sensor that works on time since last changed, template sensors only get updated on an entity’s state change,

You could also turn the automtion around:

Trigger it when the visonic is ‘on’, under the condition that the wattage is below a certain threshold for some time.

If you want to use alert (to nag you) you could create a template binary sensor to test against 2 states and create notifications while true.

Thanks for the suggestions.
The Alert component is almost what I need but I don’t see any way
to send the tts message but it will do the notify.
But it looks like it would only work on if the door is opened for a
period of time but not only when the washer has completed.

The automation above works perfect for me I am just trying to find a
simple way to repeat the action until the door is opened.

These are the small things in HA that seam easy to me, but then in
action I get stuck understanding the logic.

Mertbril
could you give me a code example of what you are suggesting.

Thanks…

I have exactly this here

Go to packages/appliances all the washing machine / dryer automations are in that package

off topic - killer repo dude! it got a star from me :slight_smile: (fellow aussie too)

1 Like

jimpower,

Your repo is awesome I will learn alot by looking at the code.

With you obvious high level of customization for HA
do you see a simple way to edit my trigger or condition to do what
I am looking for to repeat the action until I open the door.

Thanks in advance for any ideas.

If you look at my appliance package there is an action to do Just this. It annoys the crap out of my wife until she opens the door.

## Washing Machine Alerts
  - alias: Send alert when washing machine is finished
    trigger:
      - platform: state
        entity_id: sensor.washing_machine_status
        to: Clean
        for:
          minutes: 1
      - platform: state
        entity_id: device_tracker.admin_samsung
        to: 'home'
        for:
          minutes: 2
      - platform: state
        entity_id: device_tracker.admin_iphone
        to: 'home'
        for:
          minutes: 2
      - platform: time
        at: '20:45:00'
    condition:
      condition: and
      conditions:
        - condition: time
          before: '21:00:00'
          after: '08:30:00'
        - condition: state
          entity_id: group.family
          state: 'home'
        - condition: state
          entity_id: input_select.washing_machine_status
          state: Clean
        - condition: state
          entity_id: input_boolean.disable_washing_machine_notification
          state: 'off'
        - condition: template
          value_template: >
            {% if states.automation.send_alert_when_washing_machine_is_finished.last_triggered is not none %}
              {% if as_timestamp(now()) | int   -  as_timestamp(states.automation.send_alert_when_washing_machine_is_finished.attributes.last_triggered) | int > 1800 %} true {% else %} false
              {% endif %}
            {% else %}
            false
            {% endif %}
    action:
      - service: tts.google_say
        data:
          entity_id: media_player.tts_kodi
          message: 'The washing machine has finished and is ready to be emptied'
      - service: notify.pushbullet
        data:
          message: 'The washing machine has finished and is ready to be emptied'

Which part of the code creates the loop is it the
condition: template?

Do you have a way of knowing if the washing machine has been emptied? I use a xiaomi door sensor and once the washing power plug load goes below 6 for more then 1 minute it is safe for me to assume my washing machine has finished its cycle and it not in between cycles you may need to adjust for your particular machine.

Once this state has been triggered it set an input_boolean to on, you could then use this state in your condition template check to see it if washer has been emptied and loop from there. Once door sensor is triggered to on it would then turn off the input_boolean closing the loop.

In my code above I added some things to try and get it to loop.

This is the actual code I use and it works perfect.
All of my cycles drop to 4 so if it drops below 2 its done.

Just can’t figure how to make the action loop until I open the door.
To clarify when I say door its not the door on the washer, its the
garage door that has a MCT340E sensor on it.

So what happens now is it will announce its done and I will be doing
something and forget to move clothes to the dryer.

I just want it to repeat every 5 minutes until I open the garage door
and put the clothes in the dryer.

- id: nineteen
  alias: "Washing Machine OFF state"
  trigger:
    - platform: numeric_state
      entity_id: sensor.washer_watts
      below: '2'
  action:
    - service: tts.google_say
      entity_id: media_player.ccaudio_media
      data_template:
        message: >
          Washing Machine is now done and turned off.
    - service: notify.HA_NOTIFIER
      data:
          title: 'Washing Machine Done'
          message: 'Washing Machine Off'

If you use the inout_boolean as condition you could call an automation like this

  - alias: Washing Maching Notifications
    trigger:
      - platform: time
        minutes: '/5'
    condition:
    - condition: state
      entity_id: "input_boolean.washing_machine_notify"
      state: 'on'    
    action:
	- service: tts.google_say
      data:
        entity_id: media_player.ccaudio_media
        message: "Washing Machine is now done and turned off."
    - service: notify.HA_NOTIFIER
      data:
        title: 'Washing Machine Done'
        message: 'Washing Machine Off'

Another option could be to call a notify script that is triggered by the input_boolean state rather then trying to run an automation every 5 mins to see if it meets a condition.

That is what always seams wrong to me in most of the suggestions
is everything seams to suggest ways that require you to constantly
check for a status every 5 min, that just seams like a wast of cycles to me.

My automation already does mostly what I want and only triggers
when the washer is done.

This is where I always seam to get stuck with HA because what I
want to do is a while until loop for the action until I open the door
instead of it having to constantly check constantly.

Thanks for all of your suggestions.