I got the following automation with which I want to toggle my LED lights in the kitchen when I turn on my kitchen lights on the ceiling. It works well but when Home Assistant gets restarted because I updated it for example the LED lights will always toggle. So I thought a condition could help but it does not help.
trigger:
- platform: state
entity_id:
- light.kuche_deckenlichter
condition:
- condition: template
value_template: "{{ state_attr('trigger.entity_id', 'from_state.state') != 'unknown' }}"
action:
- type: toggle
device_id: f1f18ee3fd89b0521a04b334946c7d24
entity_id: light.kuche_led
domain: light
mode: single
If I have a look into the changed variables in the run that is causing the automation to run I see the following (from_state_state is unknown as you can see, so what is wrong):
this:
entity_id: automation.kuche_an_led_band_an
state: 'on'
attributes:
last_triggered: '2023-07-03T14:44:35.129135+00:00'
mode: single
current: 0
id: '1655848910187'
friendly_name: Küche an = LED Band an (und aus)
last_changed: '2023-07-03T14:45:58.871231+00:00'
last_updated: '2023-07-03T14:45:58.871231+00:00'
context:
id: 01H4E3FBYQCY122J619APPF1YN
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
alias: null
platform: state
entity_id: light.kuche_deckenlichter
from_state:
entity_id: light.kuche_deckenlichter
state: unknown
attributes:
effect_list:
- blink
- breathe
- candle
- channel_change
- finish_effect
- okay
- stop_effect
- stop_hue_effect
supported_color_modes:
- brightness
entity_id:
- light.hue_filament_fenster
- light.hue_filament_mitte
- light.hue_filament_tur
icon: mdi:lightbulb-group
friendly_name: Küche Deckenlichter
supported_features: 44
last_changed: '2023-07-03T14:49:30.154471+00:00'
last_updated: '2023-07-03T14:49:30.154471+00:00'
context:
id: 01H4E3NT9AY178NZ5HFACNBT43
parent_id: null
user_id: null
to_state:
entity_id: light.kuche_deckenlichter
state: 'off'
attributes:
effect_list:
- blink
- breathe
- candle
- channel_change
- finish_effect
- okay
- stop_effect
- stop_hue_effect
supported_color_modes:
- brightness
entity_id:
- light.hue_filament_fenster
- light.hue_filament_mitte
- light.hue_filament_tur
icon: mdi:lightbulb-group
friendly_name: Küche Deckenlichter
supported_features: 44
last_changed: '2023-07-03T14:50:03.195349+00:00'
last_updated: '2023-07-03T14:50:03.195349+00:00'
context:
id: 01H4E3PTHSR0T0WHGKJBN4E3JT
parent_id: null
user_id: null
for: null
attribute: null
description: state of light.kuche_deckenlichter