I’ve had a rather pesky light (A tradfri LED1949C5) above my bed for a while, which would sometimes turn on without being instructed to do so. I finally managed to find the what would cause the random turn on, it being a turn_off
with a transition, while the light is already off. This only appears to happen once, and calling turn_off
again whilst the light is in the spooky on
state turns it off.
Anyhow, I made a blueprint that (seems to) fix this behaviour. It listens to calls to the light.turn_off
action, and checks if the entity is in either of the targets presents, checks for a transition, and ensures the light is already meant to be off (to ensure actual turn off calls are not intercepted). It then waits a small bit, and calls turn_off
again on the light. Poof, no more random turning on. See the gist below for the code. It can be imported via its link:
Member 123 also saw some questions I was asking while trying to figure out a solution, and it turns out they have the same tradfri light. They are running on Zigbee2MQTT, I am running on ZHA, so our conclusion was that the bug is somewhere in the light’s firmware. It may be possible to fix it with, for example, a custom quirk (or the Z2M equivalent), but for now this works. If you happen to have any other spooky lights with different hardware, let me know. It may be useful to keep a list in the blueprint, or here, to keep track of misbehaving lights and allow others having the issue to find it more easily.
blueprint:
name: Tradfri LED1949C5 Patcher
description: |
The IKEA tradfri LED1949C5 bulbs seem to have a bug in the firmware where instructing them to turn off with a transition when they are already off, causes them to turn on.
The light still reports being off to Home Assistant, however. From testing, this only seemed to happen if the previous command turned the light off from being on.
Calling turn off again when it is in this spooky state (credits to 123 for that term) turns it off and seems to prevent it from happening again.
This blueprint aims to fix the light turning on in the spooky state by catching turn off commands if it is already off.
It listens to all calls to the ``light.turn_off`` service, then checks for the conditions that:
- The light is currently off
- The turn off is called with a transition
- Checks if the light is present in any of the targets, either as entity_id, within a device that is being turned off, or in the area that is instructed to turn off
- Checks if the service call did not originate from the automation (to prevent infinite loops)
Considering IKEA seems to have been phasing out these lights (and likely are done by now), I suspect a firmware update to fix this is unlikely.
This blueprint was written for ``TRADFRIbulbE14WScandleopal470lm`` on firmware `` 0x01010020``.
domain: automation
input:
spooky_light:
name: Light Entity
description: The spooky light
selector:
entity:
filter:
domain: light
variables:
light_entity: !input spooky_light
trigger:
- platform: event
event_type: call_service
event_data:
domain: light
service: turn_off
condition:
- condition: template
value_template: "{{ this.context.id != trigger.event.context.id }}"
enabled: true
- condition: state
entity_id: !input spooky_light
state: "off"
enabled: true
- condition: template
value_template: "{{ 'transition' in trigger.event.data.service_data }}"
enabled: true
- condition: or
conditions:
- condition: template
value_template: |
{% set service_data = trigger.event.data.service_data %}
{% if "entity_id" in service_data %}
{{ light_entity in service_data.entity_id }}
{% else %}
false
{% endif %}
- condition: template
value_template: |
{% set service_data = trigger.event.data.service_data %}
{% if "device_id" in service_data %}
{{ device_id(light_entity) in service_data.device_id }}
{% else %}
false
{% endif %}
- condition: template
value_template: |
{% set service_data = trigger.event.data.service_data %}
{% if "area_id" in service_data %}
{{ area_id(light_entity) in service_data.area_id }}
{% else %}
false
{% endif %}
alias: >-
Test if the light to be fixed is in any of the targets (either its area,
device or the entity itself)
action:
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 500
- metadata: {}
data: {}
target:
entity_id: !input spooky_light
action: light.turn_off
enabled: true