Brightness adjustment of a light bulb

If a bulb is off, changing its brightness turns the bulb on. Is there a way to keep the bulb off while remembering the brightness setting? (maybe in z2m?)

Hi @Chris75,

This behavior doesn’t come from Gladys but from Zigbee itself. When you change the brightness, the command sent is « Move to Level (with On/Off) Â», which turns on the bulb by design. Most bulbs don’t know how to change their level while remaining off.

Two options on the Zigbee2MQTT side, if your bulb supports them. Go to Z2M, select the device, then check if there’s a level_config block in the exposes:

  • on_level: This is the level that will be applied the next time the bulb receives a turn-on command. This is exactly what you’re looking for, you remember the brightness without turning it on.
  • execute_if_off: Allows sending a brightness change without turning on the lamp. Support depends heavily on the firmware, some bulbs completely ignore it.

There’s also current_level_startup if your need is more about setting the level after a power outage.

After that, if the final goal is simply for the bulb to turn on at the correct brightness in a specific case, the simplest solution is to put the « change brightness Â» action directly in the scene that turns it on. No need to pre-memorize anything, the bulb will turn on at the requested level.

Actually, I found the following solution: I created a day/night (on/off) mode in a widget with a general brightness setting for night (MQTT virtual variable). Therefore, I don’t need to change the brightness in each affected scene, as the bulb will light up with the brightness level defined in the night mode.

However, there is indeed another possibility with the following exposes:

but I assume they are not included in Gladys and I need to use Node-RED?

Hi @Chris75,

Your night/day mode solution is great, it’s often even more readable than a setting hidden in the bulb: you can see at a glance what state you’re in, and it works the same for all your bulbs, regardless of the brand. If it suits you, keep it :slightly_smiling_face:

To answer your question: you’re right, these exposes are not taken up in Gladys. The Zigbee2MQTT service converts the exposes into Gladys features via an explicit mapping (state, brightness, color_temp, temperature, humidity, etc.), and anything outside this list is ignored. level_config is part of it: it’s a composite object of parameters, and today Gladys only manages composites for color.

On the other hand, no need for Node-RED. Two options:

1. The simplest: set it once in the Zigbee2MQTT interface. These values are stored in the bulb itself, not in z2m. You go to the Exposes tab of your bulb in the Z2M UI, you set your on_level (or you activate execute_if_off), and that’s it: Gladys doesn’t need to know, the behavior changes for everyone, including your existing scenes.

2. If you want to change it dynamically (typically: switch on_level according to your day/night mode), there is a dedicated scene action in Gladys: Zigbee2MQTT → Send an MQTT message. You put:

  • Topic: zigbee2mqtt/your_bulb_name/set
  • Message: {"level_config": {"on_level": 50}}

And it goes directly through Gladys’ MQTT connection, without any additional dependency. The message accepts Handlebars variables, so you can even inject a value from elsewhere in the scene.

Two warnings about these attributes: execute_if_off and on_level are optional in the Zigbee spec, not all bulbs implement them (and some accept them without applying them). The fact that z2m displays them in the exposes is a good sign but not a guarantee: test before building your entire logic on them.

After that, if several people have the need, we can definitely add support for level_config in the Zigbee2MQTT service. The real question is how to expose it on the Gladys side: it’s a device configuration parameter rather than a value to control on a daily basis, and it doesn’t naturally fit into the current feature categories.