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