kevin ревизій цього gist . До ревизії
1 file changed, 15 insertions, 19 deletions
WaterLeak.yaml
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | blueprint: | |
| 2 | - | name: Wasserleck-Alarm (IKEA BADRING) – mit Sperrzeit | |
| 3 | - | description: Benachrichtigt sofort beim Auslösen und verhindert weitere Meldungen während der Sperrzeit. | |
| 2 | + | name: Wasserleck-Alarm (IKEA BADRING) – mit Timer-Sperre | |
| 3 | + | description: Benachrichtigt beim Auslösen und verhindert Wiederholungen während einer Sperrzeit. | |
| 4 | 4 | domain: automation | |
| 5 | 5 | ||
| 6 | 6 | input: | |
| @@ -24,16 +24,17 @@ blueprint: | |||
| 24 | 24 | ||
| 25 | 25 | lockout_duration: | |
| 26 | 26 | name: Sperrzeit | |
| 27 | + | description: Während dieser Dauer werden keine neuen Meldungen gesendet. | |
| 27 | 28 | default: "00:30:00" | |
| 28 | 29 | selector: | |
| 29 | 30 | duration: | |
| 30 | 31 | ||
| 31 | - | last_alert: | |
| 32 | - | name: Interner Zeitstempel | |
| 33 | - | description: input_datetime für Sperrzeitverwaltung | |
| 32 | + | lockout_timer: | |
| 33 | + | name: Timer für Sperrzeit | |
| 34 | + | description: Ein Timer-Helper (input_boolean ist NICHT geeignet — Timer muss ein 'timer' sein!) | |
| 34 | 35 | selector: | |
| 35 | 36 | entity: | |
| 36 | - | domain: input_datetime | |
| 37 | + | domain: timer | |
| 37 | 38 | ||
| 38 | 39 | ||
| 39 | 40 | trigger: | |
| @@ -42,17 +43,9 @@ trigger: | |||
| 42 | 43 | to: "on" | |
| 43 | 44 | ||
| 44 | 45 | condition: | |
| 45 | - | - condition: template | |
| 46 | - | value_template: > | |
| 47 | - | {% set last = states(inputs.last_alert) %} | |
| 48 | - | {% if last in ["unknown", "unavailable", "none", ""] %} | |
| 49 | - | true | |
| 50 | - | {% else %} | |
| 51 | - | {% set last_dt = strptime(last, "%Y-%m-%d %H:%M:%S") %} | |
| 52 | - | {% set delta = (now() - last_dt).total_seconds() %} | |
| 53 | - | {% set cooldown = as_timedelta(inputs.lockout_duration).total_seconds() %} | |
| 54 | - | {{ delta > cooldown }} | |
| 55 | - | {% endif %} | |
| 46 | + | - condition: state | |
| 47 | + | entity_id: !input lockout_timer | |
| 48 | + | state: "idle" | |
| 56 | 49 | ||
| 57 | 50 | action: | |
| 58 | 51 | - service: !input notify_service | |
| @@ -60,7 +53,10 @@ action: | |||
| 60 | 53 | title: "Wasserleck" | |
| 61 | 54 | message: !input message_text | |
| 62 | 55 | ||
| 63 | - | - service: input_datetime.set_datetime | |
| 56 | + | - service: timer.start | |
| 64 | 57 | target: | |
| 65 | - | entity_id: !input last_alert | |
| 58 | + | entity_id: !input lockout_timer | |
| 66 | 59 | data: | |
| 60 | + | duration: !input lockout_duration | |
| 61 | + | ||
| 62 | + | mode: single | |
kevin ревизій цього gist . До ревизії
1 file changed, 5 insertions, 9 deletions
WaterLeak.yaml
| @@ -1,6 +1,6 @@ | |||
| 1 | 1 | blueprint: | |
| 2 | 2 | name: Wasserleck-Alarm (IKEA BADRING) – mit Sperrzeit | |
| 3 | - | description: Benachrichtigt sofort beim Auslösen und verhindert weitere Meldungen während einer Sperrzeit. | |
| 3 | + | description: Benachrichtigt sofort beim Auslösen und verhindert weitere Meldungen während der Sperrzeit. | |
| 4 | 4 | domain: automation | |
| 5 | 5 | ||
| 6 | 6 | input: | |
| @@ -35,6 +35,7 @@ blueprint: | |||
| 35 | 35 | entity: | |
| 36 | 36 | domain: input_datetime | |
| 37 | 37 | ||
| 38 | + | ||
| 38 | 39 | trigger: | |
| 39 | 40 | - platform: state | |
| 40 | 41 | entity_id: !input leak_sensor | |
| @@ -43,15 +44,13 @@ trigger: | |||
| 43 | 44 | condition: | |
| 44 | 45 | - condition: template | |
| 45 | 46 | value_template: > | |
| 46 | - | {% set entity = ( !input last_alert ) %} | |
| 47 | - | {% set last = states(entity) %} | |
| 47 | + | {% set last = states(inputs.last_alert) %} | |
| 48 | 48 | {% if last in ["unknown", "unavailable", "none", ""] %} | |
| 49 | 49 | true | |
| 50 | 50 | {% else %} | |
| 51 | 51 | {% set last_dt = strptime(last, "%Y-%m-%d %H:%M:%S") %} | |
| 52 | - | {% set now_dt = now() %} | |
| 53 | - | {% set delta = (now_dt - last_dt).total_seconds() %} | |
| 54 | - | {% set cooldown = as_timedelta(!input lockout_duration).total_seconds() %} | |
| 52 | + | {% set delta = (now() - last_dt).total_seconds() %} | |
| 53 | + | {% set cooldown = as_timedelta(inputs.lockout_duration).total_seconds() %} | |
| 55 | 54 | {{ delta > cooldown }} | |
| 56 | 55 | {% endif %} | |
| 57 | 56 | ||
| @@ -65,6 +64,3 @@ action: | |||
| 65 | 64 | target: | |
| 66 | 65 | entity_id: !input last_alert | |
| 67 | 66 | data: | |
| 68 | - | datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}" | |
| 69 | - | ||
| 70 | - | mode: single | |
kevin ревизій цього gist . До ревизії
1 file changed, 6 insertions, 8 deletions
WaterLeak.yaml
| @@ -35,26 +35,24 @@ blueprint: | |||
| 35 | 35 | entity: | |
| 36 | 36 | domain: input_datetime | |
| 37 | 37 | ||
| 38 | - | ||
| 39 | 38 | trigger: | |
| 40 | 39 | - platform: state | |
| 41 | 40 | entity_id: !input leak_sensor | |
| 42 | 41 | to: "on" | |
| 43 | 42 | ||
| 44 | - | variables: | |
| 45 | - | last_alert_entity: !input last_alert | |
| 46 | - | cooldown_seconds: "{{ as_timedelta(!input lockout_duration).total_seconds() }}" | |
| 47 | - | ||
| 48 | 43 | condition: | |
| 49 | 44 | - condition: template | |
| 50 | 45 | value_template: > | |
| 51 | - | {% set last = states(last_alert_entity) %} | |
| 46 | + | {% set entity = ( !input last_alert ) %} | |
| 47 | + | {% set last = states(entity) %} | |
| 52 | 48 | {% if last in ["unknown", "unavailable", "none", ""] %} | |
| 53 | 49 | true | |
| 54 | 50 | {% else %} | |
| 55 | 51 | {% set last_dt = strptime(last, "%Y-%m-%d %H:%M:%S") %} | |
| 56 | - | {% set delta = (now() - last_dt).total_seconds() %} | |
| 57 | - | {{ delta > cooldown_seconds }} | |
| 52 | + | {% set now_dt = now() %} | |
| 53 | + | {% set delta = (now_dt - last_dt).total_seconds() %} | |
| 54 | + | {% set cooldown = as_timedelta(!input lockout_duration).total_seconds() %} | |
| 55 | + | {{ delta > cooldown }} | |
| 58 | 56 | {% endif %} | |
| 59 | 57 | ||
| 60 | 58 | action: | |
kevin ревизій цього gist . До ревизії
1 file changed, 10 insertions, 9 deletions
WaterLeak.yaml
| @@ -1,12 +1,11 @@ | |||
| 1 | 1 | blueprint: | |
| 2 | 2 | name: Wasserleck-Alarm (IKEA BADRING) – mit Sperrzeit | |
| 3 | - | description: Benachrichtigt sofort beim Auslösen und blockiert danach für eine definierte Sperrzeit. | |
| 3 | + | description: Benachrichtigt sofort beim Auslösen und verhindert weitere Meldungen während einer Sperrzeit. | |
| 4 | 4 | domain: automation | |
| 5 | 5 | ||
| 6 | 6 | input: | |
| 7 | 7 | leak_sensor: | |
| 8 | 8 | name: Wassersensor | |
| 9 | - | description: BADRING Sensor auswählen. | |
| 10 | 9 | selector: | |
| 11 | 10 | entity: | |
| 12 | 11 | domain: binary_sensor | |
| @@ -20,40 +19,42 @@ blueprint: | |||
| 20 | 19 | ||
| 21 | 20 | notify_service: | |
| 22 | 21 | name: Benachrichtigungsdienst | |
| 23 | - | description: z.B. notify.all_mobile_devices | |
| 24 | 22 | selector: | |
| 25 | 23 | text: | |
| 26 | 24 | ||
| 27 | 25 | lockout_duration: | |
| 28 | 26 | name: Sperrzeit | |
| 29 | - | description: Zeitraum, in dem nach einer Meldung keine weiteren Nachrichten gesendet werden. | |
| 30 | 27 | default: "00:30:00" | |
| 31 | 28 | selector: | |
| 32 | 29 | duration: | |
| 33 | 30 | ||
| 34 | 31 | last_alert: | |
| 35 | 32 | name: Interner Zeitstempel | |
| 36 | - | description: Wird automatisch für die Sperrzeitverwaltung genutzt. | |
| 33 | + | description: input_datetime für Sperrzeitverwaltung | |
| 37 | 34 | selector: | |
| 38 | 35 | entity: | |
| 39 | 36 | domain: input_datetime | |
| 40 | 37 | ||
| 38 | + | ||
| 41 | 39 | trigger: | |
| 42 | 40 | - platform: state | |
| 43 | 41 | entity_id: !input leak_sensor | |
| 44 | 42 | to: "on" | |
| 45 | 43 | ||
| 44 | + | variables: | |
| 45 | + | last_alert_entity: !input last_alert | |
| 46 | + | cooldown_seconds: "{{ as_timedelta(!input lockout_duration).total_seconds() }}" | |
| 47 | + | ||
| 46 | 48 | condition: | |
| 47 | 49 | - condition: template | |
| 48 | 50 | value_template: > | |
| 49 | - | {% set last = states((!input last_alert)) %} | |
| 51 | + | {% set last = states(last_alert_entity) %} | |
| 50 | 52 | {% if last in ["unknown", "unavailable", "none", ""] %} | |
| 51 | 53 | true | |
| 52 | 54 | {% else %} | |
| 53 | 55 | {% set last_dt = strptime(last, "%Y-%m-%d %H:%M:%S") %} | |
| 54 | - | {% set now_dt = now() %} | |
| 55 | - | {% set delta = (now_dt - last_dt).total_seconds() %} | |
| 56 | - | {{ delta > (as_timedelta(!input lockout_duration).total_seconds()) }} | |
| 56 | + | {% set delta = (now() - last_dt).total_seconds() %} | |
| 57 | + | {{ delta > cooldown_seconds }} | |
| 57 | 58 | {% endif %} | |
| 58 | 59 | ||
| 59 | 60 | action: | |
kevin ревизій цього gist . До ревизії
1 file changed, 39 insertions, 6 deletions
WaterLeak.yaml
| @@ -1,11 +1,12 @@ | |||
| 1 | 1 | blueprint: | |
| 2 | - | name: Wasserleck-Alarm (IKEA BADRING) | |
| 3 | - | description: Löst eine Benachrichtigung aus, wenn ein gewählter IKEA BADRING Wassersensor Feuchtigkeit erkennt. | |
| 2 | + | name: Wasserleck-Alarm (IKEA BADRING) – mit Sperrzeit | |
| 3 | + | description: Benachrichtigt sofort beim Auslösen und blockiert danach für eine definierte Sperrzeit. | |
| 4 | 4 | domain: automation | |
| 5 | + | ||
| 5 | 6 | input: | |
| 6 | 7 | leak_sensor: | |
| 7 | 8 | name: Wassersensor | |
| 8 | - | description: Wähle den BADRING Sensor aus, der diese Automation auslösen soll. | |
| 9 | + | description: BADRING Sensor auswählen. | |
| 9 | 10 | selector: | |
| 10 | 11 | entity: | |
| 11 | 12 | domain: binary_sensor | |
| @@ -13,26 +14,58 @@ blueprint: | |||
| 13 | 14 | ||
| 14 | 15 | message_text: | |
| 15 | 16 | name: Nachrichtentext | |
| 16 | - | description: Nachricht, die an die Geräte gesendet werden soll. | |
| 17 | 17 | default: "Es wurde ein Wasserleck erkannt! Bitte prüfen." | |
| 18 | 18 | selector: | |
| 19 | 19 | text: | |
| 20 | 20 | ||
| 21 | 21 | notify_service: | |
| 22 | 22 | name: Benachrichtigungsdienst | |
| 23 | - | description: Wähle den Notify-Dienst für die Zustellung (z. B. notify.mobile_app_dein_gerät oder notify.all_mobile_devices). | |
| 23 | + | description: z.B. notify.all_mobile_devices | |
| 24 | 24 | selector: | |
| 25 | 25 | text: | |
| 26 | 26 | ||
| 27 | + | lockout_duration: | |
| 28 | + | name: Sperrzeit | |
| 29 | + | description: Zeitraum, in dem nach einer Meldung keine weiteren Nachrichten gesendet werden. | |
| 30 | + | default: "00:30:00" | |
| 31 | + | selector: | |
| 32 | + | duration: | |
| 33 | + | ||
| 34 | + | last_alert: | |
| 35 | + | name: Interner Zeitstempel | |
| 36 | + | description: Wird automatisch für die Sperrzeitverwaltung genutzt. | |
| 37 | + | selector: | |
| 38 | + | entity: | |
| 39 | + | domain: input_datetime | |
| 40 | + | ||
| 27 | 41 | trigger: | |
| 28 | 42 | - platform: state | |
| 29 | 43 | entity_id: !input leak_sensor | |
| 30 | 44 | to: "on" | |
| 31 | 45 | ||
| 46 | + | condition: | |
| 47 | + | - condition: template | |
| 48 | + | value_template: > | |
| 49 | + | {% set last = states((!input last_alert)) %} | |
| 50 | + | {% if last in ["unknown", "unavailable", "none", ""] %} | |
| 51 | + | true | |
| 52 | + | {% else %} | |
| 53 | + | {% set last_dt = strptime(last, "%Y-%m-%d %H:%M:%S") %} | |
| 54 | + | {% set now_dt = now() %} | |
| 55 | + | {% set delta = (now_dt - last_dt).total_seconds() %} | |
| 56 | + | {{ delta > (as_timedelta(!input lockout_duration).total_seconds()) }} | |
| 57 | + | {% endif %} | |
| 58 | + | ||
| 32 | 59 | action: | |
| 33 | 60 | - service: !input notify_service | |
| 34 | 61 | data: | |
| 35 | 62 | title: "Wasserleck" | |
| 36 | 63 | message: !input message_text | |
| 37 | 64 | ||
| 38 | - | mode: single | |
| 65 | + | - service: input_datetime.set_datetime | |
| 66 | + | target: | |
| 67 | + | entity_id: !input last_alert | |
| 68 | + | data: | |
| 69 | + | datetime: "{{ now().strftime('%Y-%m-%d %H:%M:%S') }}" | |
| 70 | + | ||
| 71 | + | mode: single | |
kevin ревизій цього gist . До ревизії
1 file changed, 38 insertions
WaterLeak.yaml(файл створено)
| @@ -0,0 +1,38 @@ | |||
| 1 | + | blueprint: | |
| 2 | + | name: Wasserleck-Alarm (IKEA BADRING) | |
| 3 | + | description: Löst eine Benachrichtigung aus, wenn ein gewählter IKEA BADRING Wassersensor Feuchtigkeit erkennt. | |
| 4 | + | domain: automation | |
| 5 | + | input: | |
| 6 | + | leak_sensor: | |
| 7 | + | name: Wassersensor | |
| 8 | + | description: Wähle den BADRING Sensor aus, der diese Automation auslösen soll. | |
| 9 | + | selector: | |
| 10 | + | entity: | |
| 11 | + | domain: binary_sensor | |
| 12 | + | device_class: moisture | |
| 13 | + | ||
| 14 | + | message_text: | |
| 15 | + | name: Nachrichtentext | |
| 16 | + | description: Nachricht, die an die Geräte gesendet werden soll. | |
| 17 | + | default: "Es wurde ein Wasserleck erkannt! Bitte prüfen." | |
| 18 | + | selector: | |
| 19 | + | text: | |
| 20 | + | ||
| 21 | + | notify_service: | |
| 22 | + | name: Benachrichtigungsdienst | |
| 23 | + | description: Wähle den Notify-Dienst für die Zustellung (z. B. notify.mobile_app_dein_gerät oder notify.all_mobile_devices). | |
| 24 | + | selector: | |
| 25 | + | text: | |
| 26 | + | ||
| 27 | + | trigger: | |
| 28 | + | - platform: state | |
| 29 | + | entity_id: !input leak_sensor | |
| 30 | + | to: "on" | |
| 31 | + | ||
| 32 | + | action: | |
| 33 | + | - service: !input notify_service | |
| 34 | + | data: | |
| 35 | + | title: "Wasserleck" | |
| 36 | + | message: !input message_text | |
| 37 | + | ||
| 38 | + | mode: single | |