Browse Source

Add remiks renovasjon notify

Joachim M. Giæver 1 year ago
parent
commit
b8d7ea6357
1 changed files with 71 additions and 0 deletions
  1. 71 0
      General/remiks_renovasjon.yaml

+ 71 - 0
General/remiks_renovasjon.yaml

@@ -0,0 +1,71 @@
+remiks_renovasjon:
+  streets: ["kirkegardsvegen-14"]
+  following: ["Glass og metallemballasje"]
+  days_notice: 1
+
+binary_sensor:
+  - platform: remiks_renovasjon
+
+sensor:
+  - platform: remiks_renovasjon
+
+calendar:
+  - platform: entities_calendar
+    calendars:
+      - name: "Trash collection: Glass and metal"
+        entities:
+          - entity: sensor.remiks_glass_og_metallemballasje_kirkegardsvegen_14
+            name: "Glass and metal"
+            start_time:
+              timestamp_attribute: start_time
+            all_day: true
+
+automation:
+  - id: "trash_collection_glass_metal"
+    alias: "Trash collection: Glass and metal"
+    trigger:
+      platform: calendar
+      event: start
+      entity_id: calendar.trash_collection_glass_and_metal
+      offset: "-06:00:00"
+    action:
+      - service: system_log.write
+        data:
+          level: warning
+          message: "{{ trigger }}"
+      - variables:
+          notify_devices: >-
+            {{ state_attr('group.owners_notify_devices', 'entity_id')|list }}
+          entity_id: "{{ trigger.entity_id|default('calendar.trash_collection_glass_and_metal') }}"
+          date: >-
+            {{ state_attr(entity_id, 'start_time') }}
+      - repeat:
+          for_each: "{{ notify_devices }}"
+          sequence:
+            - service: script.turn_on
+              target:
+                entity_id: script.notify_device
+              data:
+                variables:
+                  notify_device: "{{ repeat.item }}"
+                  timeout:
+                    hours: 12
+                  data:
+                    title: "Trash collection day ♻"
+                    message: >-
+                      It's collection day for glass 🍾 and metal 🥫
+                      tomorrow {{ as_datetime(date).strftime('%A')}} the {{ as_datetime(date).day|string + {1: 'st', 2: 'nd', 3: 'rd'}.get(4 if 10 <= as_datetime(date).day|int % 100 < 20 else as_datetime(date).day|int % 10, 'th') }} of {{ as_datetime(date).strftime('%B') }}.
+                      \n\nHow about placing it next to the road tonight?
+                    data:
+                      persistent: true
+                      channel: "Trash"
+                      vibrationPattern: "100, 1000, 100000, 100, 1000, 100"
+                      notification_icon: "mdi:delete-restore"
+                      icon_url: /local/icons/notifications/glass_trash.png
+                      color: "#5bb59b"
+                      actions:
+                        - action: DONE_DISMISS_ALL
+                          title: "Done! ✔"
+                        - action: DISMISS
+                          title: "Dismiss ✖"
+