Wait_for_trigger not working

Hello,

I am rewriting my automations waiting for notification actiions into one automation using the UI editor. I cannot seem to get these new wait_for_trigger working. Here is my complete automationcode copied from the automations.yaml:

- id: '1590159926337'
  alias: Castor stofzuigen
  description: ''
  trigger:
  - at: '15:00:00'
    platform: time
  condition:
  - condition: state
    entity_id: alarm_control_panel.comfort_alarm
    state: disarmed
  action:
  - condition: state
    entity_id: device_tracker.life360
    state: home
  - data:
      data:
        timeout: 1800
        actions:
        - action: castor_start_clean
          title: Start nu
      message: Castor wil een rondje stofzuigen!
      title: Stofzuigers
    service: notify.mobile_app_telefoon_frans
  - wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: castor_start_clean
    timeout: 01:00:00
    continue_on_timeout: false
  - service: vacuum.start
    data: {}
    entity_id: vacuum.castor
  mode: restart

Hopefully someone can point me to the solution


I don’t think it’s getting as far as the wait template.

Are you getting the message?

The indentation for the notify service does not look right.

Never mind, just looked it up, it is ok.

I’d verify that your event is formatted properly. Go to the event page and listen to ‘mobile_app_notification_action’. Make sure you trigger the event. Then paste the results here and we can see if your event_data is formatted properly.

I triggered the event and this is the result:

{
    "event_type": "mobile_app_notification_action",
    "data": {
        "timeout": "1800",
        "title": "Stofzuigers",
        "message": "Castor wil een rondje stofzuigen!",
        "action_1_title": "Start nu",
        "action_1_key": "castor_start_clean",
        "action": "castor_start_clean",
        "device_id": "58570b10322894fa"
    },
    "origin": "REMOTE",
    "time_fired": "2020-09-24T15:20:34.778618+00:00",
    "context": {
        "id": "7e115948fe7911ea9903f327fafe39aa",
        "parent_id": null,
        "user_id": "6a522423623642f9b403cb447e56a395"
    }
}

based on your code it should be working. I would wager that you’re looking in the wrong spot then. Verify that your conditions are being met properly.

Or explain what’s not working with the wait_trigger.

I don’t understand; I want to start the vacuum when i click the notification on my phone. According to the new “wait_for_trigger” this should listen to the mobile_app_notification_action event for an hour. If it receives the castor_start_clean event it should go forward and start vacuuming, otherwise after an hour the automation should end.

Yes, that’s how it should work. But you must be looking in the wrong spot. I just created your automation with your event and it works as expected:

- id: '1600961838990'
  alias: wait for trigger test
  description: ''
  trigger:
  - platform: state
    entity_id: input_boolean.wait_for_trigger
    to: 'on'
  condition: []
  action:
  - service: persistent_notification.create
    data_template:
      message: Triggered at {{ as_timestamp(now()) | timestamp_custom("%I:%M %p")
        }}
  - wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: castor_start_clean
    timeout: 01:00:00
    continue_on_timeout: false
  - service: persistent_notification.create
    data_template:
      message: Wait for trigger at {{ as_timestamp(now()) | timestamp_custom("%I:%M
        %p") }}
  mode: single

image

image

petro,

The persistent notification is a great way to test things out, tnx, ddn’t know:-)

I found it. in my first post i had removed my girlfrients notification. What i want to do is send a notification to my girlfriend and myself IF we are at home. So like this:

  action:
  - condition: state
    entity_id: device_tracker.life360_frans_rampen
    state: home
  - data:
      data:
        timeout: 1800
        actions:
        - action: castor_start_clean
          title: Start nu
      message: Castor wil een rondje stofzuigen!
      title: Stofzuigers
    service: notify.mobile_app_telefoon_frans
  - condition: state
    entity_id: device_tracker.life360_laura_de_koning
    state: home
  - data:
      data:
        timeout: 1800
        actions:
        - action: castor_start_clean
          title: Start nu
      message: Castor wil een rondje stofzuigen!
      title: Stofzuigers
    service: notify.mobile_app_telefoon_laura
  - wait_for_trigger:
    - platform: event
      event_type: mobile_app_notification_action
      event_data:
        action: castor_start_clean
    timeout: 01:00:00
    continue_on_timeout: false
  - service: persistent_notification.create
    data_template:
      message: Wait for trigger at {{ as_timestamp(now()) | timestamp_custom("%I:%M
        %p") }}

But it seems like if my girlfriend is not at home; the notification isn’t send, but the rest of the automation is also stopped! So how can i make sure only action right after the condition is skipped, moving on with the next action?

You’ll have to separate the condition and action into a separate script. Then call that script in this automation.

Conditions in an action by default stop all other actions. So if you separate said condition into it’s own script with the actions you want to cancel, the script won’t cancel actions because it just fires the script.

Thx for your excellent help petro. I managed to have it working exactly as desired now.

1 Like

Hello,

I also need a bit of help with this Wait for trigger feature.
What I wanna do:
With my smart plug:
When supplied power goes above 10W, automation launched.
Wait for power decreasing below 10W for a given period.
When done, send me a notification.

Quite simple, but I don’t manage to make it work.
Here’s my automation :

- id: '1600503576338'
  alias: Notification de fin de cycle Lave-linge
  description: Le Lave-linge envoie une notification lorsque son cycle de lavage est
    terminé.
  trigger:
  - type: value
    platform: device
    device_id: 4e2e3c1a2933443eb8ec5dde2cf8e6a3
    entity_id: sensor.prise_lave_linge_power
    domain: sensor
    above: 10
    for:
      hours: 0
      minutes: 0
      seconds: 2
  condition: []
  action:
  - wait_for_trigger:
    - type: value
      platform: device
      device_id: 4e2e3c1a2933443eb8ec5dde2cf8e6a3
      entity_id: sensor.prise_lave_linge_power
      domain: sensor
      below: 10
      for:
        hours: 0
        minutes: 0
        seconds: 30
    timeout: ''
  - service: notify.mobile_app_telephone_jeje
    data:
      title: Lave-linge
      message: J'ai terminé !
  mode: single

Hello,

I happen to be trying something very similar to what you want. I can’t make it work either. It appears that the trigger does not read the entity’s power information.
Have you managed to solve it?

Hey !
I solved my issue, but using a workaround, not with Wait for trigger.
I created an Input (a Boolean, indeed) called “washing machine activated” from the Configuration menu.

Then I subdivided my single automation into 2:

  • The first one starts when Power is above 10W for a certain time, and then toggles the Input to “On”.

  • The second one Starts when power is below 10W, and as a Condition, checks if the Input state is “On”.
    If it’s the case, then send the notification to my phone “Wash cycle ended.”

Hoping it will help you ! And sorry for my perfectible English
I’m French.
I hope it will remain understandable ;).

Thank you for your help.
I will think of some other way to perform this.
What makes me curious is why it doesn’t work with the trigger, if the option is there and the logic too.

This is my automation:

alias: Shower Time
description: ‘’
trigger:

  • platform: tag
    tag_id: 4b54f3fc-f06f-xxxx-xxxx-cf1036d425f9
    condition: []
    action:
  • type: turn_on
    device_id: 6306960c47451c30c2621444a01dea62
    entity_id: switch.107xxxxxxxxxx67ee
    domain: switch
  • service: counter.increment
    target:
    entity_id: counter.contador_de_banhos
  • wait_for_trigger:
    • platform: numeric_state
      entity_id: sensor.potencia_atual
      attribute: unit_of_measurement
      below: ‘10’
      for:
      hours: 0
      minutes: 0
      seconds: 30
      milliseconds: 0
      id: 6306960c47451c30c2621444a01dea62
      continue_on_timeout: false
  • type: turn_off
    device_id: 6306960c47451c30c2621444a01dea62
    entity_id: switch.10xxxxxxxxxxxxxee
    domain: switch
    mode: single

I’m Brazilian and I don’t speak English very well either. :grin:
Thanks again for your help.