remiks_renovasjon.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. # Require: https://github.com/remimikalsen/hacs_remiks_renovasjon
  2. remiks_renovasjon:
  3. streets: ["kirkegardsvegen-14"]
  4. following: ["Glass og metallemballasje"]
  5. days_notice: 1
  6. binary_sensor:
  7. - platform: remiks_renovasjon
  8. sensor:
  9. - platform: remiks_renovasjon
  10. # Require: https://github.com/gadgetchnnel/entities_calendar
  11. calendar:
  12. - platform: entities_calendar
  13. calendars:
  14. - name: "Trash collection: Glass and metal"
  15. entities:
  16. - entity: sensor.remiks_glass_og_metallemballasje_kirkegardsvegen_14
  17. name: "Glass and metal"
  18. start_time:
  19. timestamp_attribute: start_time
  20. all_day: true
  21. # Require: https://github.com/jmgiaever/home-assistant-public-config/blob/master/General/notify_device.yaml
  22. # Uses: https://github.com/tybritten/ical-sensor-homeassistant
  23. automation:
  24. - id: "trash_collection_glass_metal"
  25. alias: "Trash collection: Glass and metal"
  26. trigger:
  27. platform: calendar
  28. event: start
  29. entity_id: calendar.trash_collection_glass_and_metal
  30. offset: "-06:00:00"
  31. action:
  32. - service: system_log.write
  33. data:
  34. level: warning
  35. message: "{{ trigger }}"
  36. - variables:
  37. notify_devices: >-
  38. {{ state_attr('group.owners_notify_devices', 'entity_id')|list }}
  39. entity_id: "{{ trigger.entity_id|default('calendar.trash_collection_glass_and_metal') }}"
  40. date: >-
  41. {{ state_attr(entity_id, 'start_time') }}
  42. - repeat:
  43. for_each: "{{ notify_devices }}"
  44. sequence:
  45. - service: script.turn_on
  46. target:
  47. entity_id: script.notify_device
  48. data:
  49. variables:
  50. notify_device: "{{ repeat.item }}"
  51. timeout:
  52. hours: 12
  53. data:
  54. title: "Trash collection day ♻"
  55. message: >-
  56. It's collection day for glass 🍾 and metal 🥫
  57. 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') }}.
  58. \n\nHow about placing it next to the road tonight?
  59. data:
  60. persistent: true
  61. channel: "Trash"
  62. vibrationPattern: "100, 1000, 100000, 100, 1000, 100"
  63. notification_icon: "mdi:delete-restore"
  64. icon_url: /local/icons/notifications/glass_trash.png
  65. color: "#5bb59b"
  66. actions:
  67. - action: DONE_DISMISS_ALL
  68. title: "Done! ✔"
  69. - action: DISMISS
  70. title: "Dismiss ✖"