I have a problem that started a few months ago and I cannot get to the bottom of it.
I have an automation that checks the input from a button for controlling some switches which control a set of blinds.
This works in combination with an input_value.
The automation looks for the switch action (single press or double press). It looks at the input_value which can be Open, Closed or Raised.
When the button is double clicked and the Input_value is Raised, then the automation runs a script called “office_blinds_lower”
The script starts by turning off the “up” motor on the blinds, it then starts the down motor on the blinds, then waits 63 seconds, then stops the down motor on the blinds. This works perfectly when I just run the script.
The automation works fine. Checking the traces it follows the correct branch of a choose statement and runs the correct script.
The problem is that when the script “office_blinds_lower” is run from the automation, it somehow runs the command to stop the down motor after 2 seconds, not 63 seconds.
Here is the relevant bit of the automation:
- conditions:
- condition: template
value_template: "{{states.input_select.blinds_office.state == 'Closed' and trigger.from_state.state == 'Raised'}}"
sequence:
- service: script.office_blinds_lower
Here is the relevant script
office_blinds_lower:
alias: Lower Office Blinds
sequence:
- service: switch.turn_off
entity_id: switch.sonoff_1000xxxx_1
- delay: 00:00:01
- service: switch.turn_on
entity_id: switch.sonoff_1000xxxx_2
- delay:
seconds: 63
- service: switch.turn_off
entity_id: switch.sonoff_1000xxxx_2
Why is the script behaving this way when run from the automation, and how can I fix it please?