Hi,
Need some help please:
since Ikea Tradfri lights don’t automatically show/send their state ‘unavailable’ (yet) to HA when power is cut off to the light, we need to force this by issuing a command to the light and have it reveal it is unavailable
.
this works fine for that:
- alias: "Dummy set Tradfri outside light to show unavailable"
id: "Dummy set Tradfri outside light to show unavailable"
#initial_state: 'on'
trigger:
platform: time
minutes: '/1'
seconds: 00
condition:
condition: template
value_template: >
{{ states('light.outside') != 'unavailable'}} # no need to check if the lights already show unavailable
action:
service: light.turn_on
data_template:
entity_id: light.outside
brightness: >
{{state_attr('light.outside','brightness') |int }} # set lights to last known brightness value
How can I do that in 1 automation for all my Tradfri lights? Need a for loop? Using the lights in the trigger part of the automation won’t work obviously, because they don’t send their unavailable
state, which is the issue at hand to begin with…
so the condition template and the action service need to be able to use a template to replace the above automation for all available tradfri lights (I a have a group so could use something like {{entity_id in state_attr('group.ikea_tradfri_lights','entity_id') }})
, or a dedicated set of indivually named lights.
as you can see it turns on the light at the last known brightness. That also means it does so when it was off. (turning it on with brightness 0) Which is kind of nice, since using a service_template for turning on /off isn’t accepted, unless you take out the brightness setting in the turn_off… making it much more complicated.
now: turn the above in an automation for all tradfri lights…
please have a look? for a bit more background see Test if Tradfri light is available/reachable?