Hi, I’m really struggling to stop a script once started. I’ve read many posts and tried many options but cannot seem to get a script to stop once started
I’ve read:
and
and
This is where I’ve got to so far:
I’ve set up an automation with 4 triggers. Each “cancel” 3 scrips using script.turn_off
then continue to do what I require. I’ve tried canceling from the automation, the script and both but whatever I do when an new option is chosen in the middle of one currently running it won’t work.
Automation: Triggers
- Maiden: Off
- Maiden: 1h
- Maiden: 2h
- Maiden: 3h
Script:
A: Cancel what is not being used
B: Turn on switch
C: Wait x hours
D: Turn off switch
E: Send finished notification
One of my 4 scripts
alias: Maiden 1 Hour
sequence:
- service: script.turn_off
data: {}
target:
entity_id: script.maiden_off
- service: script.turn_off
data: {}
target:
entity_id: script.maiden_2_hours
- service: script.turn_off
data: {}
target:
entity_id: script.maiden_3_hours
- type: turn_on
device_id: 1d88db3bac3d1745d486c
entity_id: switch.kitchen_maiden
domain: switch
- delay:
hours: 1
minutes: 0
seconds: 0
milliseconds: 0
- type: turn_off
device_id: 1d88db3bac3d1745d486c
entity_id: switch.kitchen_maiden
domain: switch
- device_id: dfdb79ffda1445eb93f45
domain: mobile_app
type: notify
message: 1h script ran
mode: single
My automation trigger:
alias: Maid Trigger
description: ""
trigger:
- platform: state
entity_id:
- input_select.maiden
id: "Off"
to: "Off"
- platform: state
entity_id:
- input_select.maiden
id: 1 Hour
to: 1 Hour
- platform: state
entity_id:
- input_select.maiden
id: 2 Hours
to: 2 Hours
- platform: state
entity_id:
- input_select.maiden
id: 3 Hours
to: 3 Hours
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: 1 Hour
sequence:
- service: script.turn_off
entity_id: script.maiden_off
- service: script.turn_off
entity_id: script.maiden_1hour
enabled: false
- service: script.turn_off
entity_id: script.maiden_2_hours
- service: script.turn_off
entity_id: script.maiden_3_hours
- device_id: f7c09145a6e3fda1445eb93f45
domain: mobile_app
type: notify
title: Maiden
message: 1 hour started
- device_id: 999c8931f9f5e06498ac20d6
domain: mobile_app
type: notify
title: Maiden
message: 1 hour started
enabled: false
- service: script.maiden_1hour
data: {}
- conditions:
- condition: trigger
id: 2 Hours
sequence:
- service: script.turn_off
entity_id: script.maiden_off
- service: script.turn_off
entity_id: script.maiden_1hour
enabled: true
- service: script.turn_off
entity_id: script.maiden_2_hours
enabled: false
- service: script.turn_off
entity_id: script.maiden_3_hours
- device_id: 7c09145a6e3fda1445eb93f45
domain: mobile_app
type: notify
title: Maiden
message: 2 hours started
- device_id: de999c8931f9f5e06498ac20d6
domain: mobile_app
type: notify
title: Maiden
message: 2 hours started
enabled: false
- service: script.maiden_2_hours
data: {}
- conditions:
- condition: trigger
id: 3 Hours
sequence:
- service: script.turn_off
entity_id: script.maiden_off
- service: script.turn_off
entity_id: script.maiden_1hour
enabled: true
- service: script.turn_off
entity_id: script.maiden_2_hours
- service: script.turn_off
entity_id: script.maiden_3_hours
enabled: false
- device_id: f7c09145a6e3fda1445eb93f45
domain: mobile_app
type: notify
title: Maiden
message: 3 hours started
- device_id: de999c8931f9f5e06498ac20d6
domain: mobile_app
type: notify
title: Maiden
message: 3 hours started
enabled: false
- service: script.maiden_3_hours
data: {}
- conditions:
- condition: trigger
id: "Off"
sequence:
- service: script.turn_off
entity_id: script.maiden_off
enabled: false
- service: script.maiden_1hour
data: {}
- service: script.turn_off
entity_id: script.maiden_2_hours
- service: script.turn_off
entity_id: script.maiden_3_hours
- device_id: f7c09145a6e3fda1445eb93f45
domain: mobile_app
type: notify
title: Maiden
message: "Off"
- device_id: de999c8931f9f5e06498ac20d6
domain: mobile_app
type: notify
title: Maiden
message: "Off"
enabled: false
- service: script.maiden_off
data: {}
mode: single
Am I doing something stupid? If so I apologies, I’ve only been using HA for a few weeks.
Any guidance would be appreciated, many thanks.