Add brightness_scale to MQTT Template Light

I’m currently using the MQTT Template Light for my lights with dimmers, thanks to its support for brightness.

From what I can tell, this type of light uses a brightness range of 0 - 255 and cannot be changed. I tried via the ‘brightness_scale’ option below, but it gets ignored. I don’t think this option is supported by the MQTT Template Light.

  - platform: mqtt_template
    name: Light 1
    command_topic: "home/light1/set"
    state_topic: "home/light1"
    command_on_template: '{"state": "on" {%- if brightness is defined -%}, "brightness": {{ brightness }} {%- endif -%} }'
    command_off_template: '{ "state": "off" }'
    state_template: '{{ value_json.state }}'
    brightness_template: '{{ value_json.brightness }}'
    brightness_scale: 100    # this gets ignored!!!!

Can this support be added?

I second that. That would be perfect

1 Like

As I’m using RGBW LED stripes, I would be happy to make also use of this.

Another one for this (although I’d like to scale to 1024). Was just about to make a post myself.

I was looking for the same thing and that would be a great addition.

In the meantime, here is a workaround using Math in templates, here converting the 255 scale to 100 scale:

light:
  - platform: mqtt_template
    command_topic: "zigate/command"
    command_on_template: >
      {%- if brightness is defined -%}
      {"function": "action_move_level_onoff", "args": ["5c2f", 1, 1, {{ brightness / 255 * 100 }}]}
      {%- else -%}
      {"function": "action_onoff", "args": ["5c2f", 1, 1]}
      {%- endif -%}
    command_off_template: '{"function": "action_onoff", "args": ["5c2f", 1, 0]}'
1 Like