]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Added telegram notifications
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Wed, 27 Jan 2021 15:11:15 +0000 (16:11 +0100)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Wed, 27 Jan 2021 15:11:15 +0000 (16:11 +0100)
.secrets_travis.yaml
components/telegram.yaml [new file with mode: 0644]
configuration.yaml
notify/telegram.yaml [new file with mode: 0644]
scripts/notify.yaml
templates/speech_message.yaml

index 158a5ff630ad3eeeb7b88c2e651f1e9f4f64bb70..b2686bc1996c5c05b2959382300e986c433139d9 100644 (file)
@@ -52,3 +52,9 @@ mb_vin: vin
 
 netatmo_client_id: client_id
 netatmo_client_secret: password
+
+telegram_bot_name: "name_bot"
+telegram_bot_username: "telegram_bot"
+telegram_bot_access_token: token
+telegram_bot_chat_id_group: 0
+telegram_bot_chat_id_giorgio: 0
diff --git a/components/telegram.yaml b/components/telegram.yaml
new file mode 100644 (file)
index 0000000..ba2be65
--- /dev/null
@@ -0,0 +1,9 @@
+######################################################################
+# Component: Telegram
+######################################################################
+
+- platform: polling
+  api_key: !secret telegram_bot_access_token
+  allowed_chat_ids:
+    - !secret telegram_bot_chat_id_group
+    - !secret telegram_bot_chat_id_giorgio
index 397041d110dd66816ece261d99a1314a2c9a51ce..e5277a119503fe814c2f8e194252b2feae97724c 100644 (file)
@@ -184,6 +184,9 @@ netatmo: !include components/netatmo.yaml
 # Speed Test
 speedtestdotnet: !include components/speedtest.yaml
 
+# Telegram
+telegram_bot: !include components/telegram.yaml
+
 ###########################################################
 # Custom Components
 ###########################################################
diff --git a/notify/telegram.yaml b/notify/telegram.yaml
new file mode 100644 (file)
index 0000000..2c0fe84
--- /dev/null
@@ -0,0 +1,7 @@
+######################################################################
+# Telegram Notifications
+######################################################################
+
+- platform: telegram
+  name: telegram
+  chat_id: !secret telegram_bot_chat_id_group
index 8a59ba6c5d4d0fc4d9a530f4dfca3b26fbc65727..6d92162a7ea80ebb3b0fcff6e0fcb80545f915df 100644 (file)
@@ -4,10 +4,12 @@
 # - title
 # - message
 # - notification_id
+# - disable_telegram
 # - enable_persistent
 #
 # Operations:
 # - notify.mail
+# - notify.telegram
 # - notify.push
 # - persistent_notification.create (if enable_persistent)
 ######################################################################
@@ -32,6 +34,26 @@ notify_text:
         title: "{{ title }}"
         message: "{{ message }}"
 
+    - choose:
+      - conditions:
+          - condition: template
+            value_template: >
+              {% if disable_telegram is defined %}
+                {% if disable_telegram | int == 1 %}
+                  false
+                {% else %}
+                  true
+                {% endif %}
+              {% else %}
+                true
+              {% endif %}
+
+        sequence:
+          - service: notify.telegram
+            data_template:
+              title: "{{ title }}"
+              message: "{{ message }}"
+    
     - service: notify.push
       data_template:
         title: "{{ title }}"
index 771ffc3b42ef67c376c900cab29040719d7046f9..3a71023b43af03120cd53c381dc2564da778a940 100644 (file)
     {% set hour = now().strftime('%H') %}\r
     {% set min = now().strftime('%M') %}\r
     {% set day = now().strftime('%d') %}\r
-    {% set mounth = now().strftime('%B') %}\r
+    {% set mounth = now().strftime('%B')|replace('January', 'Gennaio')\r
+                                        |replace('February', 'Febbraio')\r
+                                        |replace('March', 'Marzo')\r
+                                        |replace('April', 'Aprile')\r
+                                        |replace('May', 'Maggio')\r
+                                        |replace('June', 'Giugno')\r
+                                        |replace('July', 'Luglio')\r
+                                        |replace('August', 'Agosto')\r
+                                        |replace('September', 'Settembre')\r
+                                        |replace('October', 'Ottobre')\r
+                                        |replace('November', 'Novembre')\r
+                                        |replace('December', 'Dicembre') %}\r
     {% set year = now().strftime('%Y') %}\r
     Sono le {{ hour }} e {{ min }} del {{ day }} {{ mounth }} {{ year }}\r
   {%- endmacro -%}\r
       {% if is_state(entity_id, 'not_home') %}\r
         {% set source = state_attr(entity_id, 'source') %}\r
         {% set position = state_attr(source, 'address')|replace('Province of', 'Provincia di') %}\r
-      {% else %}\r
+      {% elif is_state(entity_id, 'home') %}\r
+        {% set position = "casa" %}\r
+      {% else %}      \r
         {% set position = states(entity_id) %}\r
       {% endif %}\r
       \r
   \r
   {# Car Status #}\r
   {%- macro status_car() -%}\r
-    {% if is_state('device_tracker.wdd1760081v167576', state_attr('zone.home', 'friendly_name')) %}\r
+    {% if is_state('device_tracker.ff590mr_device_tracker', 'home') %}\r
       {% set car_position = "in garage" %}\r
     {% else %}\r
       {% set car_position = "fuori" %}\r