TRÅDFRI Zigbee Light brightness not set correctly

Hello,

I have a set of Ikea TRADFRI bulb E27 WS globe 1055lm running firmware 3.0.22. The bulbs are connected to zigbee2mqtt and then integrated with HA using MQTT. I am trying to set the bulbs’ brightness to 50% when turning on at night (using automations and scripts). Despite a relatively simple requirement, the bulbs always turn on at full brightness first before adjusting itself to 50% brightness.

A sample script

action: light.turn_on
target:
 entity_id: light.activity_area_ceiling_light
data:
 brightness_pct: 50

I have been reading various topics but none has been able to resolve the issue. I did notice the following as well:

  1. When viewing log in zigbee2mqtt, there is a device_announce message before the bulbs turn on.
  2. I have some older Ikea bulbs running firmware 2.3.095 and they seem to work perfectly with brightness (always turn on at the right brightness).

I am a bit lost so any help is much appreciated.

Btw, I am running the latest version of HA and zigbee2mqtt.

Thanks.

You might get more targetted assitance chancing the title from MQTT Light to TRÅDFRI Zigbee Light as the end device uses Zigbee not MQTT.

The means of integrating Z2M into HASS is almost irrelevant.

The usual advice for IKEA Zigbee kit is to enable firmware updates as (certainly for remote controls) the newer firmware is a little more standards compliant.

Thanks @FloatingBoater . Updated as advised.

If I use HA UI to toggle the lights on/off, there is no flickering or problem.

Only when I use HA Actions/scripts, then there are issues. I noticed that the HA actions cause Z2M to publish a device_announce message which causes the lights to turn on at full brightness.

Back to the issue then…

I use ZHA rather than Z2M so can’t test this, however wonder what the different API calls are being made between the GUI and action. The light action has a lot of extra parameters which might are not set by default, but the GUI might be setting differently, e.g.:

# default ON, no parameters
action: light.turn_on
target:
  entity_id: light.test

# ON with a percentage dim
action: light.turn_on
data:
  brightness_pct: 100
target:
  entity_id: light.test

You’ve clearly tried looking at the logs, so is there a difference in Z2M logs between?:

  1. Action light.turn_on from Dev Tools with no options set
  2. Action light.turn_on from Dev Tools with Brightness = 100%
  3. GUI light ON

I’ve seen cheap Lidl Zigbee bulbs react differently to different calls, especially when the Zigbee “quirks file” was being altered to add colour support.

  1. GUI light on
z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Activity Area Ceiling Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":357,"color_temp_startup":65535,"linkquality":39,"power_on_behavior":"on","state":"ON","update":{"installed_version":50331682,"latest_version":50331682,"state":"idle"},"update_available":null}
  1. Light.turn_on from DEV tool with no option set
action: light.turn_on
target:
  entity_id: light.activity_area_ceiling_light
data: {}

----

z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Activity Area Ceiling Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":357,"color_temp_startup":65535,"linkquality":42,"power_on_behavior":"on","state":"ON","update":{"installed_version":50331682,"latest_version":50331682,"state":"idle"},"update_available":null}'
  1. Light.turn_on from DEV tool with brightness = 100%
action: light.turn_on
target:
  entity_id: light.activity_area_ceiling_light
data:
  brightness_pct: 100

---
2024-09-02 18:07:50z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/bridge/event', payload '{"data":{"friendly_name":"Activity Area Ceiling Light","ieee_address":"0x881a14fffed8868c"},"type":"device_announce"}'
info 2024-09-02 18:08:01z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/Activity Area Ceiling Light', payload '{"brightness":254,"color_mode":"color_temp","color_options":{"execute_if_off":false},"color_temp":357,"color_temp_startup":65535,"linkquality":105,"power_on_behavior":"on","state":"ON","update":{"installed_version":50331682,"latest_version":50331682,"state":"idle"},"update_available":null}'

The device_announce MQTT message is the one which causes the flickering imo.

I have another bulb of the same brand, model and firmware version and it works fine…sometimes. I wonder whether LQI has anything to do with this.