-
Notifications
You must be signed in to change notification settings - Fork 14
/
laundry.yaml
131 lines (125 loc) · 3.63 KB
/
laundry.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
- alias: Notify
id: announce_dryer_when_complete
mode: parallel
trigger:
- platform: state
entity_id:
- binary_sensor.dryer_status
- binary_sensor.washer
to: 'off'
from: 'on'
variables:
valid: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
timeout: >
{%- if valid %}
{{ as_timestamp(trigger.to_state.last_changed, 0) - as_timestamp(trigger.from_state.last_changed, 0) }}
{% endif %}
continue: >
{{ timeout and timeout > 15 }}
name: >
{{ trigger.to_state.name.split(' ')[0] if valid else 'Unknown' }}
announce: >
{{ name.lower() if name != 'Unkonwn' else none }}
switch: >
switch.announce_{{ announce }}
condition:
- condition: template
value_template: "{{ continue and announce is not none }}"
action:
- service: switch.turn_on
target:
entity_id: "{{ switch }}"
- service: script.notify
data:
title: "{{ name }} is finished!"
message: "{{ name }} is finished!"
- alias: Booleans
id: washer_and_dryer_booleans
mode: parallel
trigger:
- platform: state
entity_id:
- sensor.dryer_power
- sensor.washer_power
variables:
config:
sensor.washer_power:
input_boolean: input_boolean.washer
threshold: 80
sensor.dryer_power:
input_boolean: input_boolean.dryer
threshold: 150
valid: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
current: >
{{ config.get(trigger.entity_id) }}
have_current: >
{{ current is not none }}
number: >
{{ trigger.to_state.state if valid and is_number(trigger.to_state.state) else none }}
have_number: >
{{ number is not none }}
disposition: >
{{ number > current.threshold if have_current and have_number else none }}
service_target: >
{{ current.input_boolean if have_current else none }}
service_call: >
homeassistant.turn_o{{ 'n' if disposition else 'ff' }}
continue: >
{{ valid and disposition is not none }}
condition:
- condition: template
value_template: "{{ continue }}"
action:
- service: "{{ service_call }}"
target:
entity_id: "{{ service_target }}"
- alias: Cycle Counter
id: washer_and_dryer_cycle_counter
mode: parallel
trigger:
- platform: state
entity_id:
- input_boolean.test_washer
- binary_sensor.washer_status
variables:
<<: &prefix
prefix: washer_dryer_
valid: >
{{ trigger | default(none) is not none and trigger.to_state is defined and trigger.from_state is defined }}
continue: >
{{ trigger.to_state.state != trigger.from_state.state if valid else False }}
source: >
{{ trigger.entity_id }}
next_phase: >
{{ trigger.to_state.state if valid else none }}
condition:
- condition: template
value_template: "{{ continue }}"
action:
- service: script.calculate_washer_cycle
data:
prefix: "{{ prefix }}"
source: "{{ source }}"
next_phase: "{{ next_phase }}"
- alias: MQTT Discovery
id: 3e5e2ffb-d811-4818-a6bd-1f1386c6dbae
trigger:
- platform: homeassistant
event: start
action:
- variables:
<<: *prefix
binary_sensors:
- test_washer
- washer
- repeat:
count: "{{ binary_sensors | length }}"
sequence:
- service: script.mqtt_automated_config
data:
domain: binary_sensor
unique_id: "{{ prefix }}{{ binary_sensors[repeat.index - 1] }}"
object_id: "{{ binary_sensors[repeat.index - 1] }}"
device_class: running