How to detect rising or falling edge with template?

I’m writing a script to map my house with my Xiaomi vacuum by sending app_go_target commands.

I have to wait the vacuum status go to idle before sending the next app_go_target command with a wait_template instruction.
But I notice the wait condition is immediately true as it seems the vacuum take time to change is state. Currently I add a delay instruction as workaround but I search a cleaner way to do that.

Do you know if there is any way to detect in a template a rising or falling edge on status or attributes ?

Example with the delay:

- service: vacuum.send_command
  data:
    entity_id: vacuum.xiaomi_vacuum_cleaner
    command: app_goto_target
    params: [27500,25500]
- delay: '00:00:10'
- wait_template: "{{ is_state('vacuum.xiaomi_vacuum_cleaner', 'idle') }}"

maybe that’s what your looking for? :

Old message :wink:
Your link is a trigger that can’t be directly used in my case. when asking in 2019.
But recently we have a new instruction wait_for_trigger which associated by the trigger you have referenced will allow to cover the initial need.

Oh I see, thanks for the reply. That was my first interaction with the community :slight_smile:

Welcome to the community!

TIP:

If a forum post is dated like this:

May 19

it means it was written on May 19th in the current year

In contrast, if a forum post is dated like this:

May '19

it means it was written in May of 2019.

1 Like

And it was a good one. Trying to help someone with no answer is always aprreciated.

Welcome in the community.

1 Like