From cedea7d7dc9123dc72c016584d6c2e7f1990a30f Mon Sep 17 00:00:00 2001
From: Przemek Grondek <pgrondek@gmail.com>
Date: Mon, 14 Nov 2022 23:39:48 +0100
Subject: [PATCH] Use washing machine alerts to take out laundry

---
 configuration/alert.yaml                      |  9 ++++++++
 .../automations/bathroom-washing-machine.yaml | 21 +++++++++++++------
 configuration/configuration.yaml              |  4 ++++
 home-assistant.yml                            |  4 ++++
 4 files changed, 32 insertions(+), 6 deletions(-)
 create mode 100644 configuration/alert.yaml

diff --git a/configuration/alert.yaml b/configuration/alert.yaml
new file mode 100644
index 0000000..13c4a9a
--- /dev/null
+++ b/configuration/alert.yaml
@@ -0,0 +1,9 @@
+washing_machine:
+  name: Washing machine is done
+  done_message: Laundry taken out
+  entity_id: input_boolean.washing_machine_done
+  state: 'on'
+  repeat: 30
+  message: Washing machine is done, take out laundry
+  notifiers:
+    - mobile_app_iphone
\ No newline at end of file
diff --git a/configuration/automations/bathroom-washing-machine.yaml b/configuration/automations/bathroom-washing-machine.yaml
index a7e5feb..fe194fb 100644
--- a/configuration/automations/bathroom-washing-machine.yaml
+++ b/configuration/automations/bathroom-washing-machine.yaml
@@ -18,12 +18,9 @@
       entity_id: switch.washing_machine_on_off
       state: 'on'
   action:
-    - service: switch.turn_off
-      entity_id: switch.washing_machine_on_off
-    - service: notify.notify
-      data:
-        title: 'Washing Machine'
-        message: 'Washing has finished'
+    - service: input_boolean.turn_on
+      target:
+        entity_id: input_boolean.washing_machine_done
     - choose:
         - conditions:
             - condition: state
@@ -37,3 +34,15 @@
                 data:
                   duration: 30
                   color: black
+
+- id: washing-machine-taken
+  alias: '[Washing Machine] Laundry taken out'
+  mode: single
+  trigger:
+    - platform: state
+      entity_id:
+        - switch.washing_machine_on_off
+  action:
+    - service: input_boolean.turn_off
+      target:
+        entity_id: input_boolean.washing_machine_done
diff --git a/configuration/configuration.yaml b/configuration/configuration.yaml
index b05a95f..eba3bf7 100644
--- a/configuration/configuration.yaml
+++ b/configuration/configuration.yaml
@@ -1,4 +1,5 @@
 # Configure a default setup of Home Assistant (frontend, api, etc)
+alert: !include alert.yaml
 automation: !include automations.yaml
 #cloud:
 config:
@@ -61,6 +62,9 @@ input_boolean:
   vacuum_vacuumed_today:
     name: "Vacuumed today"
     icon: "mdi:robot-vacuum"
+  washing_machine_done:
+    name: "Washing machine done"
+    icon: "mdi:washing-machine"
 input_datetime:
   alarm:
     name: "Alarm time"
diff --git a/home-assistant.yml b/home-assistant.yml
index 7807580..f571caa 100644
--- a/home-assistant.yml
+++ b/home-assistant.yml
@@ -49,6 +49,10 @@
       copy:
         src: configuration/configuration.yaml
         dest: '{{ pwd_config }}/configuration.yaml'
+    - name: Copy alert
+      copy:
+        src: configuration/alert.yaml
+        dest: '{{ pwd_config }}/alert.yaml'
     - name: Copy customize
       copy:
         src: configuration/customize.yaml