Reset brightness after reaching 100%

Hi, I have the next automation to increase lamp brightness but I need to modify it, when reaches 100% to start from 0% and again 10%, 20%…
All this with a single button press because I’m using long click for something else.

alias: Lamp
description: ""
trigger:
  - platform: event
    event_type: shelly.click
    event_data:
      device_id: 08f10a1fb131e8dc0aadf8dcef2ab7b6
      device: shellyswitch25-483FDA8212BE
      channel: 2
      click_type: single
      generation: 1
    id: channel2short
condition: []
action:
  - if:
      - condition: trigger
        id: channel2short
    then:
      - device_id: 8bf218864e36b293e79f31d2c1eb7c41
        domain: light
        entity_id: light.livingroom_lamp
        type: brightness_increase
    enabled: true
mode: single

Try something like this:

action:
  - choose:
      - conditions:
          - condition: trigger
            id: channel2short
          - condition: template
            value_template "{{ state_attr('light.livingroom_lamp','brightness' < 256 }}"
        sequence:
          - device_id: 8bf218864e36b293e79f31d2c1eb7c41
            domain: light
            entity_id: light.livingroom_lamp
            type: brightness_increase
      - conditions:
          - condition: trigger
            id: channel2short
          - condition: template
            value_template "{{ state_attr('light.livingroom_lamp','brightness' = 256 }}"
        sequence:
          - device_id: 8bf218864e36b293e79f31d2c1eb7c41
            domain: light
            entity_id: light.livingroom_lamp
            type: #3 command to set brightness to 0

I haven’t checked that I have the value_template correct, but hopefully it is enough for you to test. Note I a don’t know the command to set brightness to 0 so it is hashed out.

1 Like

Thanks for your idea, I ended up with following automation, it’s not the shortest but it works:

alias: Lamp
description: ""
trigger:
  - platform: event
    event_type: shelly.click
    event_data:
      device_id: 08f10a1fb131e8dc0aadf8dcef2ab7b6
      device: shellyswitch25-483FDA8212BE
      channel: 2
      click_type: single
      generation: 1
    id: click
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: click
          - condition: template
            value_template: "{{ states.light.livingroom_lamp.attributes.brightness < 254}}"
        sequence:
          - device_id: 8bf218864e36b293e79f31d2c1eb7c41
            domain: light
            entity_id: light.livingroom_lamp
            type: brightness_increase
      - conditions:
          - condition: trigger
            id: click
          - condition: template
            value_template: "{{ states.light.livingroom_lamp.attributes.brightness > 254}}"
        sequence:
          - service: light.turn_on
            data:
              brightness: 0
            target:
              entity_id: light.livingroom_lamp
      - conditions:
          - condition: trigger
            id: click
          - condition: device
            type: is_off
            device_id: 8bf218864e36b293e79f31d2c1eb7c41
            entity_id: light.livingroom_lamp
            domain: light
        sequence:
          - device_id: 8bf218864e36b293e79f31d2c1eb7c41
            domain: light
            entity_id: light.livingroom_lamp
            type: brightness_increase
mode: single