Cycle through "scenes" with a button press

Hi there!
I’m new to homeassistant, despite being in homelabbing for 3 years.
I want to be able to press one button and cycle through 4 predefined modes for 1 specific lamp and it should also remember at which mode it was before without influencing the other lamps. I have 10 lamps (per lamp: 4 brightness/color settings) and I want to control each lamp with a different button on my 4x Aqara 6-button remotes. I already have it working with 10 input selects (per lamp) and 40 individual scenes (10 lamps * 4 modes), but I think I must be missing a much simpler solution.

I’m using a blueprint to have the correct triggers for the remotes (link), which works fine.
Can someone explain me how to set it up better?

2 Likes

Ok I solved it, wow this took days. For anybody that wants to achieve the same way:
Action from the button press event on the aqara remote (can be any remote, I am using a blueprint):

      - service: input_select.select_option
        data:
          option: KI_LI1
        target:
          entity_id: input_select.lights
      - service: input_select.select_next
        target:
          entity_id: input_select.ki_li1
        data: {}

This will do the following: 1. It will pass on an input select drop down which light it wants to adress. 2. It will cycle through the scenes.
The input selects look like this:

  #To remember at which scene the lamp was at
  ki_li1:
    name: KI_LI1
    options:
      - "bright"
      - "medium"
      - "low"
      - "night"
  #All my lights are here
  lights:
    name: Lights
    options:
      - "KI_LI1"

Here are the scripts:

lights_bright:
  alias: Lights Bright
  sequence:
  - variables:
      light_entity: li{{ light }}
  - service: light.turn_on
    target:
      entity_id: '{{ light_entity }}'
    data:
      brightness_pct: 100
      color_temp: 335
  mode: single
lights_medium:
  alias: Lights Medium
  sequence:
  - variables:
      light_entity: li{{ light }}
  - service: light.turn_on
    target:
      entity_id: '{{ light_entity }}'
    data:
      brightness_pct: 70
      color_temp: 420
  mode: single
lights_low:
  alias: Lights Low
  sequence:
  - variables:
      light_entity: li{{ light }}
  - service: light.turn_on
    target:
      entity_id: '{{ light_entity }}'
    data:
      brightness_pct: 40
      color_temp: 465
  mode: single
lights_night:
  alias: Lights Night
  sequence:
  - variables:
      light_entity: li{{light}}
  - service: light.turn_on
    target:
      entity_id: '{{ light_entity }}'
    data:
      brightness_pct: 1
      color_temp: 500
  mode: single

Last not but least - an automation that gets triggered once the state of the inputs changes and it passes it on to the script

alias: ALL_Lights_Input_Change
description: ''
trigger:
  - platform: state
    entity_id: input_select.ki_li1
  - platform: state
    entity_id: input_select.ba_li1
  - platform: state
    entity_id: input_select.ba_li2
  - platform: state
    entity_id: input_select.be_li1
  - platform: state
    entity_id: input_select.be_li2
  - platform: state
    entity_id: input_select.ki_li1
  - platform: state
    entity_id: input_select.li_li1
  - platform: state
    entity_id: input_select.li_li2
  - platform: state
    entity_id: input_select.li_li3
condition: []
action:
  - service: script.lights_{{trigger.to_state.state}}
    data:
      light: ght.{{states('input_select.lights')}}
mode: single

I know it’s dirty, but it works really well! Only downside - pressing two buttons at the same time won’t work, but it’s dyanmic and lightweight

3 Likes