i have been wanting to set up some automations to help me with reminders and wish to have then trigger at different times on different days, i currently have automations running at set times- using the condition to specify the day, but i was wondering if i could set one automation to trigger on different times and days instead of having each one set to a specific day/set of days?
basically just this but having several as triggers instead of several automations with this as a condition
There are multiple ways to do what you want in a single automation.
One approach would be to use multiple triggers for the different times then use a Choose action to run the desired actions based on the trigger that fired and the day of the week.
It would be much easier to give you a specific answer if you share the configuration of your automations, as specified in the Questions Guidelines.
i would like in theory for it to be something along the lines of
–trigger–
friday at 3pm
or
Tuesday at 8pm
or
Wednesday at 10am
–action–
-send a message through Alexa device
-wait 5 minutes (to prevent spam)
loop top two actions until nfc tag scanned- then stop loop and trigger again when any of the above triggers are met
Most efficient way to start would be to use a Schedule helper set up via the UI to represent the day / times that you want; and a state trigger that fires when the schedule entity goes to on.
If all the triggers execute the same action sequence, you don’t need a Choose as proffered in my previuos post. You just need to use conditions appropriately. Here is one example of triggering on Time and using conditional logic:
Automation Example
trigger:
- platform: time
id: Tuesday
at:
- "20:00:00"
- platform: time
id: Wednesday
at:
- "10:00:00"
- platform: time
id: Friday
at:
- "15:00:00"
condition:
- alias: Check if the Trigger ID matches the current weekday
condition: template
value_template: "{{ trigger.id == now().strftime('%A') }}"
action:
- #YOUR ACTION SEQUENCE
Note: now().strftime('%A') will return the weekday in whatever language your system uses, so make sure the trigger IDs are set to match those.
It is also possible to create a functionally equivalent automation without a Template condition, the condition block is just more verbose.
Verbose Condition Block
trigger:
- platform: time
id: Tuesday
at:
- "20:00:00"
- platform: time
id: Wednesday
at:
- "10:00:00"
- platform: time
id: Friday
at:
- "15:00:00"
condition:
- alias: Check if the Trigger ID matches the current weekday
condition: or
conditions:
- and:
- condition: trigger
id: Tuesday
- condition: time
weekday:
- tue
- and:
- condition: trigger
id: Wednesday
- condition: time
weekday:
- wed
- and:
- condition: trigger
id: Friday
- condition: time
weekday:
- fri
action:
- #YOUR ACTION SEQUENCE
(ah i was using the choose i will try your other suhgestions now)
(edit 2: i do quite like the choose option as it does give the possobility to customise the actions if needed to have slightly altered ones between days but these are both perfect for what i need one for a single action set and the other to let me have diffrent actions thanks so much!)
Perhaps use a different automation to set an input boolean helper “flag” (which you’ll need to create) when the tag is scanned (or however it works) and use the state of that helper in your until loop, resetting the flag helper on exit?
I would set up a trigger-based Template sensor to save a timestamp of the last time the tag was scanned. This can serve two functions in your automation. First, you can use it as a general condition so you aren’t alerting if the cage clean tag has already been scanned for the day. Whether this automation is for you or someone else in your household, there are few things more annoying in a “smart” home than being pestered to do something you’ve already done. Second, it can act as the condition that closes out your loop.
template:
- trigger:
- platform: tag
tag_id: 4d9c*******
sensor:
- name: Chin Cage Tag Last Scan
device_class: timestamp
state: "{{ now() }}"
In your automation you have used the Time condition alone instead of a Time condition and a Trigger condition suggested in my previous post. That will not have the behavior you want . For example, in your first Option, the condition will allow the notifications to be executed at 10:00, 13:00, and 17:00 on Mon,Tue, Sat, and Sun. You need to make the Option exclusive to the correct trigger.
ok i think i should have it all done except the tag sensor since i realised it didnt run today and it had the “tag scanned” condition in place
i assume its this but I’m not sure what to do with it? i dont do templates or anything usually since I’m still not round to understanding them yet haha
template:
- trigger:
- platform: tag
tag_id: 4d9c*******
sensor:
- name: Chin Cage Tag Last Scan
device_class: timestamp
state: "{{ now() }}"
edit: i do know last night i was fiddling with scanning the tag and seeing if the condition for “tag is scanned” passed so it might have just been that i was doing that after midnight and didn’t realise so it thought that i had already done it today perhaps? (last scanned seems to say it was before midnight yesterday so i suppose not)
If you want you can change the cutoff time by adding a time to the today_at() in the condition.
Double check the value of the sensor you created. Keep in mind that it should be in UTC not your local time zone; it may look way off if you don’t take that into account.
Use the developer tools to check the template (or more specifically, the individual things you compare in the template). I’m not sure, but you use as_local for the sensor, but not for today_at. My first guess would be you should use it at both sides, or neither side.
i dont know if i have mentioned but i have never used templates before because they are quite beyond me i can deal with everything else but i am yet to wrap my head around them so I’m not really sure what i am looking for hahah