-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathVibrationSensorApplianceFilter.yaml
More file actions
165 lines (146 loc) · 5.81 KB
/
VibrationSensorApplianceFilter.yaml
File metadata and controls
165 lines (146 loc) · 5.81 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
blueprint:
name: Vibration Sensor Filter
description: >
Filters a vibration sensor to detect when a vibrating appliance (like a washing machine or dryer) stops running.
Before configuring the blueprint, mount the vibration sensor on the appliance and run a few cycles to gather historic data to tune the filter.
For more detailed tuning instructions and visuals, see the blueprint's repository's [README file](https://github.com/axeldavid/VibrationSensorApplianceFilterBlueprint).
domain: automation
input:
vibration_sensor:
name: Vibration Sensor
description: The binary vibration sensor mounted on the appliance.
selector:
entity:
filter:
- domain: binary_sensor
device_class: vibration
multiple: false
stop_delay:
name: Started-to-Stopped transition threshold
description: >
The minimum duration of inactivity needed to consider the appliance **Stopped**. This sets the delay for end-of-cycle notifications.
Consequences of misconfiguration:
- **Too short**: Can lead to false positives, such as a single cycle being broken into multiple, or an unrelated vibration being mistaken for a new cycle.
- **Too long**: Excessive delay of cycle end detection.
selector:
duration:
default:
hours: 0
minutes: 5
seconds: 0
start_delay:
name: Stopped-to-Started transition threshold
description: >
For how long, a cycle's vibrations must continue without interruptions that exceed the **Started-to-Stopped** threshold.
This must be longer than the **Started-to-Stopped** threshold, plus the maximum duration of any brief, non-cycle related vibrations.
It must also be shorter than your shortest program cycle.
Consequences of misconfiguration:
- **Too short**: Can lead to false positives.
- **Too long**: A cycle might not be detected at all.
selector:
duration:
default:
hours: 0
minutes: 10
seconds: 0
running_state_helper:
name: Started/Stopped State Helper (input_boolean)
description: >
This is the main output of the blueprint. It is a toggle helper that stores the **Started**/**Stopped** state.
- The **Stopped** state will lag behind the actual end of the cycle by the **Started-to-Stopped** transition threshold duration.
- The **Started** state is not representative of the actual start time of the cycle and cannot reliably be used for automations that require precise timing.
selector:
entity:
filter:
- domain: input_boolean
multiple: false
started_timer_helper:
name: Started Timer Helper
description: A timer helper to determine the **Started** state of the appliance.
selector:
entity:
filter:
- domain: timer
multiple: false
stopped_timer_helper:
name: Stopped Timer Helper
description: A timer helper to determine the **Stopped** state of the appliance.
selector:
entity:
filter:
- domain: timer
multiple: false
variables:
started_timer_id: !input started_timer_helper
stopped_timer_id: !input stopped_timer_helper
mode: single
max_exceeded: silent
triggers:
- trigger: state
entity_id: !input vibration_sensor
to: ["on", "off"]
- trigger: event
event_type: timer.finished
event_data:
entity_id: !input started_timer_helper
- trigger: event
event_type: timer.finished
event_data:
entity_id: !input stopped_timer_helper
condition: []
actions:
- choose:
# Started timer finished: Switch the running state to Started
- conditions:
- condition: template
value_template: "{{ trigger.event is defined and trigger.event.data.entity_id == started_timer_id }}"
sequence:
- action: input_boolean.turn_on
target:
entity_id: !input running_state_helper
- stop: 'Appliance state set to Started, "started" timer finished.'
# Stopped timer finished: Cancel any running Started timer and switch the running state to Stopped
- conditions:
- condition: template
value_template: "{{ trigger.event is defined and trigger.event.data.entity_id == stopped_timer_id }}"
sequence:
- action: timer.cancel
target:
entity_id: !input started_timer_helper
- action: input_boolean.turn_off
target:
entity_id: !input running_state_helper
- stop: 'Appliance state set to OFF, "off" timer finished.'
# Vibration detected -> Cancel any running Stopped timer and start a Started timer
- conditions:
- condition: state
entity_id: !input vibration_sensor
state: "on"
sequence:
- action: timer.cancel
target:
entity_id: !input stopped_timer_helper
- if:
- condition: state
entity_id: !input started_timer_helper
state: "idle"
- condition: state
entity_id: !input running_state_helper
state: "off"
then:
- action: timer.start
target:
entity_id: !input started_timer_helper
data:
duration: !input start_delay
# Vibration sensor idle: Start a Stopped timer
- conditions:
- condition: state
entity_id: !input vibration_sensor
state: "off"
sequence:
- action: timer.start
target:
entity_id: !input stopped_timer_helper
data:
duration: !input stop_delay