#Can "Wait for Trigger" have multiple possible triggers to wait for?

1 messages · Page 1 of 1 (latest)

lean ether
#

Context
Since the AC in our bedroom isn’t too powerful, but very old and energy-hungry, it doesn’t matter if we run it all day or if we don’t, the next morning our bedroom ends up feeling the same in terms of temperature and stuffiness. No if nobody is going to be home for the rest of the day, I don't want tons of power wasted running it.

Goal
I want to create an actionable notification automation for when Home Assistant notices that my wife and I are out of the house. It will ask us both if we want to still allow the bedroom AC to run, and if both of us say no, any automations that turn it on for us won’t trigger for the rest of the day. But if either of us say yes, then home assistant will continue to automate the bedroom AC so it’s nice and cool when that person gets home later.

Setup (so far)
The automation will trigger if the AC is turned on but HA notices nobody's home. I have a switch helper called Allow Bedroom AC. This has to be on or else automations won't start the AC. I set up a number helper Vote. Yes will raise it and No does nothing, so if Vote is not 0 at the end, Allow Bedroom AC will turn back on.

Here's a human readable breakdown of the desired automation setup.

#Part 1
• Set Vote to 0.
• Turn off Allow Bedroom AC.
• Send Actionable notifications to Husband and Wife
Looks like Nobody's Home?
Should the AC still run?
Yes No

#Part 2 (THE PROBLEMATIC PART)
• Wait for Trigger (1st vote)
• Wait for Trigger (2nd vote)

#Part 3
• If Vote > -0, turn on Allow Bedroom AC
else, do nothing.
• Notify Husband and Wife of the results.

I need Wait for Trigger to be listening for either UPVOTE or DOWNVOTE, not just one or the other. I've tried a few ways of changing the data field on Wait for Trigger, but everything I tried seemed to just make it unresponsive.

arctic sparrow
#

Yes, it can

#

It will continue on any of the triggers listed

#

You can use trigger id's to determine the next action

#

You need to use templates though, using wait.trigger.id

lean ether
# arctic sparrow You need to use templates though, using `wait.trigger.id`

Would you please elaborate or provide an example of how that would be set up? I'm not sure what wait.trigger.id refers to. This gave me an idea for a solution, but I'm not sure if i'm thinking the way you're thinking. I'm not good at understanding yaml or figuring out how to write it most of the time.

Inspired solution: two more automations, one that listens for UPVOTE and one that listens for DOWNVOTE. I already have these just so that UPVOTE ticks the Vote count and DOWNVOTE essentially does nothing. Effectively a placeholder. At the end of both of them, I could trigger event SUBMITTEDVOTE and have my main automation listen for SUBMITTEDVOTE instead of UPVOTE or DOWNVOTE. I just thought it'd be nice if Wait for Trigger in the main automation didn't have to rely on the others. But since that's how votes are ticked, I guess nothing effectively changes.

Still, I would like an example of what you were talking about in case I have a use case where I'd rather keep everything in one automation.

arctic sparrow
#
actions: 
  - wait_for_trigger: 
      - trigger: event
        event_type: UPVOTE
        id: UPVOTE
      - trigger: event
        event_type: DOWNVOTE
        id: DOWNVOTE
  - choose: 
      - conditions: 
          - condition: template
            value_template: "{{ wait.trigger.id == "UPVOTE" }}"
        sequence:
          - do some stuff 
      - conditions: 
          - condition: template
            value_template: "{{ wait.trigger.id == "DOWNVOTE" }}"
        sequence:
          - do other stuff
lean ether
#

This is still so far over my head.

arctic sparrow
#

It waits for two different triggers, and then continues based on which trigger occurred

lean ether
#

I've gathered that much, but I don't have any experience with templates. From my point of view, condition: temple seems random. I'm not sure how it's interacting with anything. I'm also not sure where the sample yaml would go, or if it's an entirely manual/custom action that can't be parsed to be shown in the visual editor. I do almost everything in the visual editor.

high rune
#

the yaml is just a way to transfer automations for example on the forum. That would be the same if it would not contain a template. So this is just dipping your toe into the world of yaml and a tiny bit of templates.

Just open a new automation, go to yaml mode, paste this yaml, en switch back to UI mode. Now you can look at what UI items it created whcih you can just use in the automation you're working on. The only bit that will be a bit "code-ish" will be the template itself.

lean ether
high rune
#

This is the action bit of an automation (or could be in a script as well). But just have a look at the yaml of an empty automation and just replace the actions there with this. And if you would look at the yaml of you other automation you will see the trend 😄