I’ve tried the usual iterations, but keep hitting that same wall.
blueprint:
domain: script
name: Toggle switch_entity, with support for spinner
author: cvonk
homeassistant:
min_version: 2023.8.0
# source_url:
description: >
Toggles a switch. While waiting for the state change, it sets
the `pending_entity` to true. The latter can use to e.g.
control the visibility of a spinner element.
E.g.
switch_entity: switch.opnpool_aux2_circuit
pending_entity: input_boolean.opnpool_aux2_circuit_pending
input:
switch_entity:
name: Switch entity
description: >
The switch that you want to toggle
selector:
entity:
domain: switch
pending_entity:
name: Helper input_boolean
description: >
True when a state change is requested, but didn't happen yet.
You need to create this helper.
selector:
entity:
domain: input_boolean
variables:
switch_entity_var: !input switch_entity
pending_entity_var: !input pending_entity
sequence:
- action: input_boolean.turn_on
entity_id: !input pending_entity
- variables:
current_state: "{{ states(switch_entity_var) }}"
- action: switch.toggle
entity_id: !input switch_entity
- wait_template: "{{ states(switch_entity_var) != current_state }}"
timeout: 20 # Optional timeout in seconds
- action: input_boolean.turn_off
entity_id: !input pending_entity
icon: mdi:script
mode: queued
max: 10
Thanks for your time,
/c
