Remove remaining blueprint from Garbage Collection
This commit is contained in:
@ -1,67 +0,0 @@
|
|||||||
blueprint:
|
|
||||||
name: Holiday in week
|
|
||||||
description: "This automation is triggered from the `garbage_collection` integration
|
|
||||||
by event `garbage_collection_loaded`, during the device state update. \nIt PROCESSES
|
|
||||||
DATA SENT WITH THE EVENT, and then FINISHES THE UPDATE. DO NOT CALL THIS SERVICE
|
|
||||||
MANUALLY, IT WON'T WORK (it won't have the data).\nAlso, make sure the INTEGRATION
|
|
||||||
IS CONFIGURED FOR `manual_update` (that will disable the state update by the integration
|
|
||||||
and pass it to this automation).\n\nIt loops through the calculated dates and
|
|
||||||
checks for a public holiday the week, before/on the calculated collection date.
|
|
||||||
If found, it will move the event to the next day.\n\nThe sensors are normally
|
|
||||||
updated once a day, or when Home Assistant starts. The update can be triggered
|
|
||||||
by updating the integration configuration (just hit configure and submit)."
|
|
||||||
domain: automation
|
|
||||||
source_url: https://github.com/bruxy70/Garbage-Collection/blob/master/blueprints/holiday_in_week.yaml
|
|
||||||
input:
|
|
||||||
garbage_collection_entity:
|
|
||||||
name: Garbage Collection Entity
|
|
||||||
description: Triggered by the event for this entity.
|
|
||||||
selector:
|
|
||||||
entity:
|
|
||||||
integration: garbage_collection
|
|
||||||
multiple: false
|
|
||||||
holiday_entity:
|
|
||||||
name: Holidays
|
|
||||||
description: Entity containing the holidays - an instance of Holidays custom
|
|
||||||
integration (available through HACS)
|
|
||||||
selector:
|
|
||||||
entity:
|
|
||||||
integration: holidays
|
|
||||||
multiple: false
|
|
||||||
mode: parallel
|
|
||||||
trigger:
|
|
||||||
- platform: event
|
|
||||||
event_type: garbage_collection_loaded
|
|
||||||
event_data:
|
|
||||||
entity_id: !input garbage_collection_entity
|
|
||||||
action:
|
|
||||||
- variables:
|
|
||||||
holiday_entity: !input holiday_entity
|
|
||||||
- alias: Iterate through the dates
|
|
||||||
repeat:
|
|
||||||
for_each: '{{ trigger.event.data.collection_dates }}'
|
|
||||||
sequence:
|
|
||||||
- alias: Is there a public holiday on the week?
|
|
||||||
condition: template
|
|
||||||
value_template: "{%- set collection_date = as_datetime(repeat.item) %} {%- set
|
|
||||||
ns = namespace(found=false) %} {%- for i in range(collection_date.weekday()+1)
|
|
||||||
%}\n {%- set d = ( collection_date + timedelta( days=-i) ) | as_timestamp
|
|
||||||
| timestamp_custom(\"%Y-%m-%d\") %}\n {%- if d in state_attr(holiday_entity,'holidays')
|
|
||||||
%}\n {%- set ns.found = true %}\n {%- endif %}\n{%- endfor %} {{ ns.found
|
|
||||||
}}"
|
|
||||||
- alias: Move the date
|
|
||||||
service: garbage_collection.offset_date
|
|
||||||
data:
|
|
||||||
entity_id: '{{ trigger.event.data.entity_id }}'
|
|
||||||
date: '{{ repeat.item }}'
|
|
||||||
offset: "{%- set collection_date = as_datetime(repeat.item) %} {%- set ns
|
|
||||||
= namespace(offset=1, found=false) %} {# Increase offset until we find a
|
|
||||||
date that is not public holiday #} {%- for _ in range(7) if not ns.found
|
|
||||||
%}\n {%- set d = ( collection_date + timedelta( days=ns.offset) ) | as_timestamp
|
|
||||||
| timestamp_custom(\"%Y-%m-%d\") %}\n {%- if d in state_attr(holiday_entity,'holidays')
|
|
||||||
%}\n {%- set ns.offset = ns.offset + 1 %}\n {% else %}\n {%- set
|
|
||||||
ns.found = true %}\n {%- endif %}\n{% endfor %} {{ ns.offset }}"
|
|
||||||
- alias: Update the garbage_collection entity
|
|
||||||
service: garbage_collection.update_state
|
|
||||||
data:
|
|
||||||
entity_id: '{{ trigger.event.data.entity_id }}'
|
|
Reference in New Issue
Block a user