Automation Not Triggering Based On Brightness Level

Attempting to publish MQTT topics when light brightness slider is set below level 2.

The automation does not trigger when I move the light slider to 1%

Using the HA UI below is the YAML.

alias: MyDimmerAutomation
description: ""
trigger:
  - platform: state
    entity_id:
      - light.my_dimmer
    attribute: brightness
condition:
  - condition: numeric_state
    entity_id: light.my_dimmer
    below: 2
action:
  - service: mqtt.publish
    data:
      topic: oh3/dimmer/my_dimmer/state_bright
      payload: "0"
      retain: true
  - service: mqtt.publish
    data:
      topic: oh3/dimmer/my_dimmer/state
      payload: "OFF"
      retain: true
mode: single

You forgot to specify the brightness attribute there.

Still not working. What am I doing wrong?

alias: MyDimmerAutomation
description: ""
trigger:
  - platform: state
    entity_id:
      - light.my_dimmer
    attribute: brightness
condition:
  - condition: numeric_state
    entity_id: light.my_dimmer
    attribute: brightness
    below: 2
action:
  - service: mqtt.publish
    data:
      topic: oh3/dimmer/my_dimmer/state_bright
      payload: "0"
      retain: true
  - service: mqtt.publish
    data:
      topic: oh3/dimmer/my_dimmer/state
      payload: "OFF"
      retain: true
mode: single

Follow the trace, what does it show?

Your automation is only going to run the actions when the brightness is turned to one, on a scale of 0 (off) to 255.

That is exactly what I want to happen.

I move the slider to the far left which is 1 or 1% and I am expecting the automation to trigger, which it is not.

When triggered I am expecting oh3/dimmer/my_dimmer/state_bright to end up with 0 and oh3/dimmer/my_dimmer/state with OFF which is not happening because the automation is not triggering.

I wish that it was a scale of 0 to 255. The slider only goes to 1 not zero if it went to zero I would not be fiddling around with this.

Check the automation trace

There is nothing in the TRACE because the automation has not been triggered.

I manually ran the automation and the expected outcome took place. state_bright was set to 0 and state was set to off and the light turned off.

TRACED had limited information and did not include anything regarding the TRIGGER or CONDITION as they were not called when the automation was manually run.

If it never triggered then the attribute brightness for light.my_dimmer never changed after the automation was written.

Or the automation is disabled.

Oh, and if you turn the light off there’s no brightness attribute, so the automation won’t run.

The automation is not disabled.

Moving the slider for the dimmer raises and lowers the light level.

Moving the slider to the 1 value positions dimes the light to the lowest level. The light is NOT off. Should it not trigger the automation and publish my MQTT statements???

Is there a way to change the lowest value of the slider from 1 to 0?

Have you attempted to replicate?

No

Have have state triggers using an attribute that work, yes.

Have you checked your log file for errors or warnings?

There are no errors or warnings in home-assistant.log.

If you have time please create a MQTT Light and then create an automation that does what I am attempting to do. You may discover my error or an issue with the automation.

Maybe there is a different method to trigger the automation when the slider is moved to the 1 position.

The slider is irrelevant here.

Did you look in States at light.my_dimmer and check the value of the brightness attribute?

Thanks for your guidance. The brightness was the issue for me.

The MQTT Light UI and the underpinning takes a bit of getting accustom to.

The slider is 1 to 100 but the brightness is 0 to 255 yet the mqtt state_brightness is published as 1 and not 0.

The whole ON/OFF coloration seems odd. Might be nice if the slider was 0-100 and that setting to 0 would turn off the light.

It used to behave more like that, but unsurprisingly the sudden surprise at turning off the light was a problem.