@armedad after a long debug session and some modification for your code i think we have a winner, documenting here what i noticed for anyone who might see this thread and have similar issues.
TLDR - probably due to usage of Change device type of a switch
from switch to light.
All the switches above are configured VIA HACS LocalTuya integration which works flawlessly for me up until this automation flow, no delay or glitches. however while running the code above my light entities (switch converted to light by helper) == 4&7 become unavailable \ unknown which caused the various time delays, and due to the mode single configuration of the automation any new change would not trigger the automation.
I resolved it by removing the helpers and static the switch entities instead.
FYI:
- Your description is correct.
- The delay was in the light switch LED status but also caused the next automation not to run which was my bigger issue.
- knowledge is power, i am a big advocate in having all the information as well - THANK YOU!!!
Adding the current code only running 1Ā± day, so too soon to state the stability:
alias: Sync Switch To Light Group
description: ""
trigger:
- platform: state
entity_id:
- light.all_kitchen_lights
- switch.all_kitchen_lights
from:
- "on"
- "off"
to:
- "on"
- "off"
condition:
- condition: template
value_template: >-
{{ states.light.all_kitchen_lights.state !=
states.switch.all_kitchen_lights.state }}
enabled: true
action:
- variables:
trigger_entity: |-
{%- if trigger.from_state.entity_id == 'light.all_kitchen_lights' %}
switch.all_kitchen_lights
{% elif trigger.from_state.entity_id == 'switch.all_kitchen_lights' %}
light.all_kitchen_lights
{% endif %}
- service: homeassistant.turn_{{ trigger.to_state.state }}
target:
entity_id: "{{ trigger_entity }}"
enabled: true
mode: single