One button cycle through different automations

Hello,

I have a lightbox where i’ve added an rgb ledstrip with inidividual controlable leds. I created 3 partitions in the ledstrip:

  - platform: partition
    name: "box3"
    id: part1
    segments:
      - id: strip
        from: 0
        to: 20
  - platform: partition
    name: "box2"
    id: part2
    segments:
      - id: strip
        from: 21
        to: 38
  - platform: partition
    name: "box1"
    id: part3
    segments:
      - id: strip
        from: 41
        to: 60          

I can’t use scenes to switch the lightbox colors, because it only triggers the first partition to change color, but the second and third don’t change (other people have this issue, so it’s a bug i guess)
now, i’ve found a solution, If I create an automation that changes the colors, it works for eacht segment.

now I want to cycle through 5 different automations when I push a button on my hue dimmer.

TL;DR is it possible to cycle through 5 different automations with 1 push on a button?

thanks

You could combine all these automations into a single automation and in between the actions use the wait until action type for the button to be pressed again. Please see the sample yaml below.

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: switch.ab_home
    to: 'on'
condition: []
action:
  - service: switch.turn_on
    target:
      entity_id: switch.daemon
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - wait_for_trigger:
      - platform: state
        entity_id: switch.ab_home
        to: 'on'
    continue_on_timeout: false
  - service: switch.turn_on
    target:
      entity_id: switch.daemon
  - delay:
      hours: 0
      minutes: 0
      seconds: 2
      milliseconds: 0
  - wait_for_trigger:
      - platform: state
        entity_id: switch.ab_home
        to: 'on'
    continue_on_timeout: false

This is how it works, when you push the buttom, the switch turns on. Assuming that its a momentary switch type button, it should go off as soon as you release it. With the button being on the automation is triggered and the action of your first automation is done.

After the first automation actions you will need to give a 2 second relay to ensure that the button goes back to off state. Then we use the wait until node for the button to turn on again and do the second automation actions.

This cycle continues till the 5th and then the automation is started again. For this to work make sure that you set the automation mode single.

If you have any questions, please do ask.

oh wauw, this is exactly what I was looking for!! thanks Seminasalam !!!

1 Like