Automation for light dimming - 2 questions

Hi.
I’m trying to create an automation for dimming of lights, but I encountered 2 problems I cannot find answers to:

  1. When dimming down, I would like for the automation to stop at 5% brightness, and not turn the light off as it does by default.
  2. How to set the speed for each repeat? Transition time doesn’t seem to do anything.

This is what I have created so far:

alias: Kontor - Lys m/Dimming
description: ""
trigger:
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: on_press
    id: kontor_lysbryter_on_press
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: on_hold
    id: kontor_lysbryter_on_hold
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: off_press
    id: kontor_lysbryter_off_press
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: off_hold
    id: kontor_lysbryter_off_hold
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: up_hold
    id: kontor_lysbryter_up_hold
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: down_hold
    id: kontor_lysbryter_down_hold
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: up_press_release
    id: kontor_lysbryter_up_release
  - platform: device
    domain: mqtt
    device_id: cda80baae48ac45754dbbfde1e575929
    type: action
    subtype: down_press_release
    id: kontor_lysbryter_down_release
condition: []
action:
  - alias: Increase brightness when HOLD UP
    if:
      - condition: trigger
        id:
          - kontor_lysbryter_up_hold
    then:
      - service: light.turn_on
        metadata: {}
        data:
          brightness_step_pct: 15
        target:
          device_id: cd8b8eb00c811c9314167cbbde29e6ad
      - repeat:
          sequence: []
          until:
            - condition: trigger
              id:
                - kontor_lysbryter_up_release
  - alias: Decrease brightness when HOLD DOWN
    if:
      - condition: trigger
        id:
          - kontor_lysbryter_down_hold
    then:
      - service: light.turn_on
        metadata: {}
        data:
          brightness_step_pct: -15
        target:
          device_id: cd8b8eb00c811c9314167cbbde29e6ad
      - repeat:
          sequence: []
          until:
            - condition: trigger
              id:
                - kontor_lysbryter_down_release
mode: restart

Thanks

i believe the transition time instructs the light bulb to take a certain amount of time to transtiion to the target brightness if the light supports ramping. however the call does not wait for it… so you need to add a wait yourself… so a 1 second wait would be something like:

  - delay:
      seconds: 1

i’d put it right after your call to light.turn_on

aside from that… does your code actually work? if so i’m a little confused as to how… the repeats don’t look to me like they are doing anything other than spinning in a tight loop until the button down is released. is it supposed to be calling to increase or decrease the brightness?

you said it currently goes until the light turns off so somehow it’s working… :person_shrugging: maybe while it’s being held down the device is actually repeatedly triggering events? if so, you could get rid of the “repeats” and it’d still work…

as for your first question… i think the way to do that is to check to see if the current value is < 20. and if so, just set it to 5%.

The code works. And seem simple enough; It increase brightness when a button is long pressed, and stops when that button is released.
But as mentioned, I don’t want the automation to be able to turn the lights completely off.
I don’t see a solution here.

I think something like this might work in your repeat for the down button press. I didn’t test it, but it should keep repeating as long as the brightness is above 15%. Once it gets below 15%, it should stop.

  sequence: []
  until:
    - condition: or
      conditions:
        - condition: state
          entity_id: sensor.office_button_remote_action
          state: down
        - condition: numeric_state
          entity_id: light.office_light_1
          attribute: brightness
          above: 15
1 Like