I will include my current try at the bottom. I want to repeat some TTS and flashing lights if my phone is still charging. That means I trigger the “leave_shop” script and my phone is still sitting on the wireless charger. In the past, that means another trip to the shop. So I was trying to build into the “leave_shop” script, if the phone is on the charger then remind me till I pick it up. The repeat/while with the sequences work. Then I wanted to hold the repeat/while for a few seconds so it is not just flashing lights and google yelling at me the whole time. :-). That where it gets tricky. If I use the wait_trigger there has to be a transition and for my example, it would be from “wireless”. Then I have a 10-second timeout so google can flash and yell at me some more. That works. If I pick up the phone while that is going on, then it goes into the wait_trigger and the current state is “none” so it will never go from “wireless”, then I am waiting for 10 seconds that it should not have to. I wish there was a wait, that only waited if x condition, then it would exit if x condition is no more. Then I tried “wait_template” but that opposite of wait_trigger. This is where I am currently. It almost like I need a way of combining them. I sure I can get really creative but I wanted to see if there was an easier way that I am just missing.
leave_shop:
sequence:
- alias: "Repeat Paul phone if wireless charging"
repeat:
while:
- condition: state
entity_id: sensor.paul_mobile_charger_type
state: "wireless"
# Don't do it too many times
- condition: template
value_template: "{{ repeat.index <= 20 }}"
sequence:
- service: tts.cloud_say
entity_id: media_player.shop
data:
message: Paul you are forgetting your phone!
- service: light.turn_off
entity_id: light.shop_bays
- delay: 1
- service: light.turn_on
entity_id: light.shop_bays
- delay: 1
- service: light.turn_off
entity_id: light.shop_bays
- delay: 1
- service: light.turn_on
entity_id: light.shop_bays
- delay: 1
- wait_template: "{{ states('sensor.paul_mobile_charger_type') != 'wireless' }}"
# - wait_for_trigger:
# - platform: state
# entity_id: sensor.paul_mobile_charger_type
# from: "wireless"
# to:
# - "none"
# - "ac"
timeout: "00:00:10"
- service: light.turn_on
entity_id: light.back_porch
- delay: 15
- service: light.turn_off
entity_id: light.shop_bays
- service: light.turn_off
entity_id: light.shop_main_bench
- service: light.turn_off
entity_id: light.back_porch
- service: switch.turn_off
entity_id: switch.shop_heater