remiks_renovasjon.yaml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. automation:
  23. - id: "trash_collection_glass_metal"
  24. alias: "Trash collection: Glass and metal"
  25. trigger:
  26. platform: calendar
  27. event: start
  28. entity_id: calendar.trash_collection_glass_and_metal
  29. offset: "-06:00:00"
  30. action:
  31. - service: system_log.write
  32. data:
  33. level: warning
  34. message: "{{ trigger }}"
  35. - variables:
  36. notify_devices: >-
  37. {{ state_attr('group.owners_notify_devices', 'entity_id')|list }}
  38. entity_id: "{{ trigger.entity_id|default('calendar.trash_collection_glass_and_metal') }}"
  39. date: >-
  40. {{ state_attr(entity_id, 'start_time') }}
  41. - repeat:
  42. for_each: "{{ notify_devices }}"
  43. sequence:
  44. - service: script.turn_on
  45. target:
  46. entity_id: script.notify_device
  47. data:
  48. variables:
  49. notify_device: "{{ repeat.item }}"
  50. timeout:
  51. hours: 12
  52. data:
  53. title: "Trash collection day ♻"
  54. message: >-
  55. It's collection day for glass 🍾 and metal 🥫
  56. 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') }}.
  57. \n\nHow about placing it next to the road tonight?
  58. data:
  59. persistent: true
  60. channel: "Trash"
  61. vibrationPattern: "100, 1000, 100000, 100, 1000, 100"
  62. notification_icon: "mdi:delete-restore"
  63. icon_url: /local/icons/notifications/glass_trash.png
  64. color: "#5bb59b"
  65. actions:
  66. - action: DONE_DISMISS_ALL
  67. title: "Done! ✔"
  68. - action: DISMISS
  69. title: "Dismiss ✖"