]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Review alarms
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 4 Feb 2020 20:53:59 +0000 (21:53 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Tue, 4 Feb 2020 20:53:59 +0000 (21:53 +0100)
automation/alarms.yaml [new file with mode: 0644]
automation/doors.yaml
device_tracker/ping.yaml [deleted file]
device_tracker/ping.yaml.disabled [new file with mode: 0644]
script/alarms.yaml

diff --git a/automation/alarms.yaml b/automation/alarms.yaml
new file mode 100644 (file)
index 0000000..fe3b623
--- /dev/null
@@ -0,0 +1,16 @@
+######################################################################\r
+# Alarm: Aknowledge Alarms\r
+#\r
+# Actions:\r
+# - script.stop_alarm\r
+######################################################################\r
+- alias: "Alarms: Riconoscimento Allarmi"\r
+  initial_state: 'on'\r
+\r
+  trigger:\r
+    platform: state\r
+    entity_id: input_boolean.alarms\r
+    to: 'off'\r
+\r
+  action:\r
+    - service: script.stop_alarm\r
index 11882a79df6d671c088b0e2e95bd44f19ba671cd..3b50bcb502fb7c075f7623718eb1c85bba3eb87b 100644 (file)
   initial_state: 'on'
 
   trigger:
-    platform: state
-    entity_id: binary_sensor.porta_casa_stato
-    to: 'on'
+    platform: state
+      entity_id: binary_sensor.porta_casa_stato
+      to: 'on'
 
   condition:
-  - condition: time
-    after: '23:00:00'
-    before: '06:00:00'
+     - condition: numeric_state
+       entity_id: sun.sun
+       value_template: "{{ state_attr('sun.sun', 'elevation') }}"
+       below: -10
 
   action:
+    - delay: 00:00:01
     - service: light.turn_on
       entity_id: light.luce_corridoio
     - delay: '00:05:00'
   initial_state: 'on'
 
   trigger:
-    platform: state
-    entity_id: binary_sensor.porta_casa_stato
-    to: 'on'
+    platform: state
+      entity_id: binary_sensor.porta_casa_stato
+      to: 'on'
     
   condition:
-    condition: state
-    entity_id: binary_sensor.guard_mode
-    state: 'on'
+    condition: state
+      entity_id: binary_sensor.guard_mode
+      state: 'on'
 
   action:
-    service: script.notify_all
-    data_template:
-      title: "Home Assistant - Presenza non autorizzata"
-      volume_level: '0.4'
-      language: 'it'
-      message: "È stata rilevata una presenza non autorizzata."
-      enable_persistent: 1
\ No newline at end of file
+    - service: script.start_alarm
+      data_template:
+        title: "Presenza non autorizzata"
+        message: "È stata rilevata una presenza non autorizzata."
+        level: 1
diff --git a/device_tracker/ping.yaml b/device_tracker/ping.yaml
deleted file mode 100644 (file)
index c034b40..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-######################################################################
-# Device Tracker: Ping
-######################################################################
-
-- platform: ping
-  hosts:
-    s9: s9.giorgioravera.it
-    a5: a5.giorgioravera.it
-    a3: a3.giorgioravera.it
-  count: 5
-
-  # Seconds between each scan for new devices
-  interval_seconds: 60
-  # Seconds to wait till marking someone as not home after not being seen
-  consider_home: 300
-  new_device_defaults:
-    track_new_devices: true
-    hide_if_away: false
diff --git a/device_tracker/ping.yaml.disabled b/device_tracker/ping.yaml.disabled
new file mode 100644 (file)
index 0000000..c034b40
--- /dev/null
@@ -0,0 +1,18 @@
+######################################################################
+# Device Tracker: Ping
+######################################################################
+
+- platform: ping
+  hosts:
+    s9: s9.giorgioravera.it
+    a5: a5.giorgioravera.it
+    a3: a3.giorgioravera.it
+  count: 5
+
+  # Seconds between each scan for new devices
+  interval_seconds: 60
+  # Seconds to wait till marking someone as not home after not being seen
+  consider_home: 300
+  new_device_defaults:
+    track_new_devices: true
+    hide_if_away: false
index 474748e3216f01f1cb99f4472d60e40d876d89d2..800b2dfc820580d7012f39db15397f972e2738eb 100644 (file)
@@ -1,25 +1,18 @@
 ######################################################################
-# Alarm: Start Alarm
+# Alarm: Start Alarm Sound
 #
 # Operations:
-# - script.notify_text
 # - media_player.volume_set
 # - media_player.play_media
 ######################################################################
 
-start_alarm:
-  alias: "Attiva Allarme"
+start_alarm_sound:
+  alias: "Allarmi: Avvia Suono"
   sequence:
-    - service: script.notify_text
-      data_template: 
-        title: "Allarme"
-        message: "Rilevato allarme"
-        enable_persistent: 1
-
     - service: media_player.volume_set
       data_template:
         entity_id: 'media_player.google_home'
-        volume_level: 0.5
+        volume_level: 0.4
 
     - service: media_player.play_media
       data_template:
@@ -28,15 +21,15 @@ start_alarm:
         media_content_id: 'https://home.giorgioravera.it/local/audio/alarm.mp3'
 
 ######################################################################
-# Alarm: Stop Alarm
+# Alarm: Stop Alarm Sound
 #
 # Operations:
 # - media_player.media_stop
 # - script.volume_manager
 ######################################################################
 
-stop_alarm:
-  alias: "Interrompi Allarme"
+stop_alarm_sound:
+  alias: "Allarmi: Interrompi Suono"
   sequence:
     - service: media_player.media_stop
       data_template:
@@ -45,3 +38,75 @@ stop_alarm:
     - service: script.volume_manager
       data_template:
         media_player: 'media_player.google_home'
+
+######################################################################
+# Alarm: Start Alarm Level 1
+# Inputs:
+# - title
+# - message
+#
+# Operations:
+# - script.notify_text
+######################################################################
+
+start_alarm_level_1:
+  alias: "Allarmi: Attiva Allarme 1"
+  sequence:
+    - service: script.notify_all
+      data_template:
+        volume_level: 0.4
+        language: 'it'
+        title: >-
+          {# Check Null Input #}
+          {% if title | length == 0 %}
+            {% set title = 'Allarme Generico' %}
+          {% endif %}
+          Home Assistant - {{ title }}
+        message: >-
+          {# Check Null Input #}
+          {% if message | length == 0 %}
+            {% set message = 'Allarme Generico' %}
+          {% endif %}
+          {{ message }}
+        enable_persistent: 1
+        notification_id: "alarm"
+#    - service: input_boolean.turn_on
+#      entity_id: input_boolean.{{ alarm_type }}
+
+######################################################################
+# Alarm: Start Alarm
+# Inputs:
+# - title
+# - message
+# - level
+#
+# Operations:
+# - input_boolean.turn_on
+# - script.start_alarm_level_1
+# - script.start_alarm_level_2
+######################################################################
+
+start_alarm:
+  alias: "Allarmi: Attiva Allarme"
+  sequence:
+    - service: input_boolean.turn_on
+      entity_id: input_boolean.alarms
+
+    - service: script.start_alarm_level_1
+      data_template:
+        title: "{{ title }}"
+        message:  "{{ message }}"
+
+######################################################################
+# Alarm: Stop Alarm
+#
+# Operations:
+# - persistent_notification.dismiss
+######################################################################
+
+stop_alarm:
+  alias: "Allarmi: Disattiva Allarme"
+  sequence:
+    - service: persistent_notification.dismiss
+      data_template:
+        notification_id: "alarm"