Closed pjasinsk closed 2 years ago
You want to have two garbage_collection integrations, right? And if the first one falls on a date of the second one, you want to move it, correct? That's not that easy. The blueprint is not an issue, that's easy. But it will be hard to get the list of dates from the collection 2, as the garbage_collection does not have an attribute with the list of the collection dates, only the next collection.
Not sure what type of schedule it is, but I guess the easiest would be to calculate the "second" schedule in the blueprint. Or read it from somewhere else
"You want to have two garbage_collection integrations, right? And if the first one falls on a date of the second one, you want to move it, correct?" Yes, this is what I need to do. Collection 1: monthly --> on THU 2'nd week of month Collection 2: every 2nd week on THU
Right, that won't be too hard. So what I'd do is to create the collection 1. And then have a blueprint and testing each date if it falls on the second week (either checking the week number - that's easiest, but this resets at the end of the year as weeks restart from 1, or calculating a difference between the date and start date and checking whether it divides by 14). And if yes, then just call the offset with -7.
Can you help me with creating such blueprint? I'm a HA beginner and I gave up trying to do it by myself...
You need to iterate through the dates (you can take the repeat loop from the move on holidays blueprint). And for each iteration have a condition, calculating the difference between the date and your first date, and check whether it is divisible by 14. Again, similar to move on holiday, except that instead of checking whether it is a public holiday, you make a different condition. To calculate the difference between the dates, convert them to the timestamps and just calculate the difference - it will be in seconds, so just convert that to days (divide by the number of seconds per day...) And after the condition, call the service garbage_collection.offset_date with offset -7.
If you'd like to give it a go, you can post it here for a review :)
It doesent work and I have no idea how to solve this problem... Can you help me?
blueprint:
name: Move before if same collection day
description: >-
This automation is triggered from the garbage_collection
integration by event garbage_collection_loaded
,
during the device state update.
It 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).
Also, make sure the INTEGRATION IS CONFIGURED FOR `manual_update`
(that will disable the state update by the integration and pass it to this automation).
It loops through the calculated dates and checks if it is the same date as other collection date.
If found, it will move the event one week before.
The 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/move_on_holiday.yaml input: garbage_collection_entity: name: Garbage Collection Entity To Move description: Triggered by the event for this entity. selector: entity: integration: garbage_collection garbage_collection_entity_main: name: Garbage Collection Entity Main description: Main entity. selector: entity: integration: garbage_collection mode: parallel trigger:
Can you please send the file through gist, or at least format it as yaml. It is quite hard to understand the above. I am not sure why you have two garbage collection entities. The scenario I was describing, you'd only need one entity to iterate through, and have the first date (a fixed date). And then calculate the difference between each date and the first date. I do not see that. You are checking whether the date is in the attribute 'zmieszane' of the main entity. The garbage collection integration does not have such attribute. Also, in the offset, you do not have to have the template. So offset: -7 should be enough if I understand correctly.
Before you submit a new bug report, please check that
Write your question here
I need to create the automatition or modify a blueprint to Move the collection 1 to the PREVIOUS week, if the collection falls on the day with collection 2. Can you help me with that?