1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- template:
- - trigger:
- platform: state
- attribute: start_time
- entity_id: binary_sensor.kirkegardsvegen_14_glass_metallemballasje
- sensor:
- - name: "{{ state_attr(trigger.entity_id, 'friendly_name') }}"
- unique_id: "kirkegardsvegen_14_glass_metallemballasje"
- state: >- # Set state (datetime) 6 hours ahead of midnigth (start_time)
- {{
- strptime(
- state_attr(trigger.entity_id, 'start_time'),
- '%Y-%m-%dT%H:%M:%S',
- default=now()
- ) - timedelta(hours=6)
- }}
- attributes:
- source_sensor: "{{ trigger.entity_id }}"
- start_time: "{{ state_attr(trigger.entity_id, 'start_time') }}"
- automation:
- - id: "trash_collection_glass_metal"
- alias: "Trash collection: Glass and metal"
- trigger_variables:
- entity_id: "sensor.kirkegardsvegen_14_glass_metallemballasje"
- trigger:
- platform: time
- at: sensor.kirkegardsvegen_14_glass_metallemballasje
- action:
- - variables:
- notify_devices: >-
- {{ state_attr('group.notify_user_devices', 'entity_id')|default([])|list }}
- # Set the default, so we can trigger it manually....
- binary_sensor: "{{ state_attr(entity_id, 'source_sensor') }}"
- date: >-
- {{ states(entity_id) }}
- - service: system_log.write
- data:
- level: warning
- message: >-
- Trigger:{{ trigger }}\n
- Entity_id: {{ entity_id }}, state: {{ states(entity_id)}}
- - repeat:
- for_each: "{{ notify_devices }}"
- sequence:
- - service: script.turn_on
- target:
- entity_id: script.notify_device # https://github.com/jmgiaever/home-assistant-public-config/blob/master/General/notify_device.yaml
- 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: "{{ state_attr(binary_sensor, 'icon_url')|default('/local/icons/notifications/glass_trash.png') }}"
- color: "#5bb59b"
- actions:
- - action: DONE_DISMISS_ALL
- title: "Done! ✔"
- - action: DISMISS
- title: "Dismiss ✖"
|