From 9a85a3b424aef06d515bb5b9b38e51162b24906d Mon Sep 17 00:00:00 2001
From: Erik Appel <erik@appel.cloud>
Date: Mon, 24 Oct 2022 15:23:35 +0200
Subject: [PATCH] Added Alarm (Blaulicht + Sirene)

---
 .../templates/config/esphome_alarm.yaml       | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 warpsrvint/docker_esphome/templates/config/esphome_alarm.yaml

diff --git a/warpsrvint/docker_esphome/templates/config/esphome_alarm.yaml b/warpsrvint/docker_esphome/templates/config/esphome_alarm.yaml
new file mode 100644
index 00000000..150b4731
--- /dev/null
+++ b/warpsrvint/docker_esphome/templates/config/esphome_alarm.yaml
@@ -0,0 +1,47 @@
+{% set devicename = "esphome_strommesser"  %}
+
+{% include "/includes/ansible.inc.yaml" %}
+{% include "/includes/board.d1_mini.inc.yaml" %}
+{% include "/includes/common.inc.yaml" %}
+
+switch:
+- platform: gpio
+  pin: D2
+  id: sirene_pin
+- platform: gpio
+  pin: D1
+  id: blaulicht
+  name: Blaulicht
+- platform: template
+  name: Sirene
+  id: sirene
+  optimistic: true
+  turn_on_action:
+  - switch.turn_on: sirene_pin
+  - delay: 300ms 
+  - switch.turn_off: sirene_pin
+  - delay: 100ms
+  # turn self on again if still enabled
+  - if:
+      condition:
+        lambda: 'return id(sirene).state;'
+      then:
+      - switch.turn_on: sirene
+  turn_off_action:
+    - switch.turn_off: sirene_pin
+
+binary_sensor:
+- platform: gpio
+  pin: D6
+  name: "Alarm-Button"
+  id: "alarm_button"
+  filters:
+      - delayed_on_off: 300ms
+  on_release:
+    then:
+      - switch.turn_on: sirene
+      - switch.turn_on: blaulicht
+  on_press:
+    then:
+      - switch.turn_off: sirene
+      - switch.turn_off: blaulicht
-- 
GitLab