Repeating laundry notification with time in laundry machine updates

Hi all,

I was looking for a repeating notification with time updates for my laundry because I don’t want it to be in the machine for too long or it will smell. Couldn’t find what I was looking for so I made it myself for anyone who is looking for something like this. If you have any improvements, please share.

  • When laundry is done and you are home, it sends: Laundry done.
  • When laundry is done and you are not home, it waits till someone is home and sends a notification: Laundry done at (time), in the laundry machine for (time in laundry machine).

Both will repeat as long as someone is home and include updates with time in laundry machine. The notifications will stop when no one is home since you can’t do anything about it when you’re not at home.

You have to have some sensor obviously to let HA know your laundry is done. Use that sensor as your trigger in the first automation.

I have a doorsensor on my laundry machine that turns of the automation but you can manually turn it off if you don’t have such a sensor.

Here’s everything you need:

configuration.yaml:

input_datetime:
  laundry_done:
  name: Laundry done
  has_date: true
  has_time: true

input_boolean:
  laundry_done:
  friendly_name: Laundry done
  initial: off

laundry_notification_timer:
  name: Laundry notification timer
  duration: 900

sensor:
- platform: template
  sensors:

    laundry_done_time:
      friendly_name: Laundry done time
      value_template: >
    {% set hours = (now().timestamp() - states.input_datetime.laundry_done.attributes.timestamp)|timestamp_custom('%H',false)|int %}
    {% set minutes = (now().timestamp() - states.input_datetime.laundry_done.attributes.timestamp)|timestamp_custom('%M',false)|int %}

    {% if hours > 0 %}{{hours}} hour{% endif %}{% if hours > 0 and minutes > 0 %} and{% endif %}{% if minutes == 1 %} {{minutes}} minute{% elif minutes > 1 %} {{minutes}} minutes{% endif %}
      entity_id: sensor.time

automations.yaml:

- alias: Laundry done
  initial_state: off
  trigger:
  - platform: trigger
    entity_id: sensor.laundry_machine
    to: 'done'
  action:
  - service: input_boolean.turn_on
    entity_id: input_boolean.laundry_done
  - service: input_datetime.set_datetime
    entity_id: input_datetime.was_klaar
    data_template:
      date: "{{now().timestamp()|timestamp_custom('%Y-%m-%d')}}"
      time: "{{now().timestamp()|timestamp_custom('%H:%M')}}"
  - condition: state
    entity_id: group.all_devices
    state: 'home'
  - service: notify.notify
    data_template:
      title: "Laundry machine"
      message: "Laundry is done."
  - service: timer.start
    data:
      entity_id: timer.laundry_notification_timer


- alias: Notification when coming home
  trigger:
  - platform: state
    entity_id: group.all_devices
    to: 'home'
  condition:
  - condition: state
    entity_id: input_boolean.laundry_done
    state: 'on'
  action:
  - service: notify.notify
    data_template:
      title: "Laundry machine"
      message: "Laundry was done at {{states.input_datetime.laundry_done.attributes.timestamp | timestamp_custom('%H:%M')}} and has been in the machine for {{states.sensor.laundry_done_time.state}}."
  - service: timer.start
    data:
      entity_id: timer.laundry_notification_timer

- alias: No notification when not home
  trigger:
  - platform: state
    entity_id: group.all_devices
    to: 'not_home'
  condition:
  - condition: state
    entity_id: input_boolean.laundry_done
    state: 'on'
  action:
  - service: timer.cancel
    data:
      entity_id: timer.laundry_notification_timer


- alias: Repeat laundry notification
  trigger: 
  - platform: event
    event_type: timer.finished
    event_data: 
      entity_id: timer.laundry_notification_timer
  action:
  - service: notify.notify
    data:
      title: "Laundry machine"
      message: 
            "Don't forget to take out the laundry. It has been in the machine for {{states.sensor.laundry_done_time.state}}."
  - service: timer.start
    data:
      entity_id: timer.laundry_notification_timer

- alias: Laundry out of machine
  trigger:
  - platform: state
    entity_id: binary_sensor.laundry_machine_door_sensor
    to: 'on'
  action:
  - service: input_boolean.turn_off
    entity_id: input_boolean.laundry_done
  - service: timer.cancel
    data:
      entity_id: timer.laundry_notification_timer
1 Like

Is there any reason you didn’t use the alert component?

I haven’t actually used it yet so am not sure if you can enable/disable it based (in your case) on someone being home.

My main problem with that component is I have different messages for different scenario’s. Probably could be done with templates but I liked this way better.

2 Likes

This is exactly what I wanted :slightly_smiling_face:

I still tweaked the sensor a bit for a nicer output (hour/hours):

- platform: template
  sensors:
    laundry_done_time:
      friendly_name: Laundry done time
      value_template: >-
        {% set hours = (now().timestamp() - states.input_datetime.laundry_done_time.attributes.timestamp)|timestamp_custom('%H',false)|int %}
        {% set minutes = (now().timestamp() - states.input_datetime.laundry_done_time.attributes.timestamp)|timestamp_custom('%M',false)|int %}
        {% if hours == 1 %}{{hours}} hour{% elif hours > 1 %}{{hours}} hours{% endif %}{% if hours > 0 and minutes > 0 %} and {% endif %}{% if minutes == 1 %}{{minutes}} minute{% elif minutes > 1 %}{{minutes}} minutes{% endif %}

And as I consider that my laundry is done if my washing machine is in standby (i.e. < 30 W) since 15 minutes, I changed the first automation as follows:

- alias: Laundry done
  trigger:
  - platform: state
    entity_id:
    - sensor.washing_machine_state
    from: Washing
    to: Standby
    for:
      hours: 0
      minutes: 15
      seconds: 0
  condition: []
  action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.laundry_done
  - service: input_datetime.set_datetime
    data_template:
      date: '{{now().timestamp()|timestamp_custom(''%Y-%m-%d'')}}'
      time: '{{(now() | as_timestamp - (15*60)) | timestamp_custom(''%H:%M'', true)}}'
    target:
      entity_id: input_datetime.laundry_done_time
  - condition: state
    entity_id: group.somebody_home
    state: home
  - service: notify.alexa_media
    data:
      message: The laundry is done since {{states.sensor.laundry_done_time.state}}.
      target:
      - media_player.living_room
      data:
        type: tts
  - service: timer.start
    data: {}
    target:
      entity_id: timer.laundry_notification_timer