# Select next/previous of a sequence of flows

**URL:** <https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132>\
**Category:** Questions & Help\
**Created:** [October 14, 2021, 11:24am UTC](https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132 "2021-10-14T11:24:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joost\_Schevers](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/joost_schevers/32/16498_2.png) [@Joost\_Schevers](https://community.homey.app/u/Joost_Schevers)\
**Post date:** [October 14, 2021, 11:24am UTC](https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132/1 "2021-10-14T11:24:42Z")

</div>

Hi all.

I’ve tried searching for this a couple of times on different occasions but haven’t found an easier way to do this. I’m wondering if there is.

Here’s the concept (simplified):

I’ve got a certain number of lighting scenes.  
Let’s say the following:

1. blue
2. red
3. orange
4. yellow
5. green

I want to control my lights with two buttons:

A) next lighting scene  
B) previous lighting scene

(both with wraparound behavior)

Currently I store a number in a variable.  
A increases the variable  
B decreases the variable

I’ve got severals flows set up triggering on that variable changing:

- If variable below minimum (1) set variable to maximum (5) (= wraparound)
- If variable above maximum (5) set variable to minimum (1) (= wraparound)
- If variable set to # set lighting scene #

So all in all I have 4 + # lighting scene = 9 flows configured in order to get the behavior I want.

Kinda cumbersome to set up and also to modify.

It would be nice to be able to configure a sequence or enum or array where for each value you could configure a corresponding flow to be executed and some “Sequence flow cards” with “Next sequence step” and “Previous sequence step”.

This way, adding a new lighting scene would be a matter of creating a flow to set that scene and configuring the sequence with the additional value and that corresponding flow.

I know that this can be done with HomeyScript and given time at some point will try do use HomeyScript to reduce the number of flows I need.

For an experienced person it shouldn’t even be that hard to create a Homey app for this.

I’m just surprised this doesn’t seem to exist yet nor find anyone asking for this kind of feature.

Was I simply unlucky with my searches and is anybody aware of a Homey app that supports this?  
(Or willing to create one, but that’s a stretch I realize)

Or does anyone know a simpler way of realizing this behavior?

I’m eager to hear thoughts from fellow community members!

Kind regards,

Joost

---

<div class="post-metadata">

**Author:** ![Adrian\_Rockall](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/adrian_rockall/32/13209_2.png) [@Adrian\_Rockall](https://community.homey.app/u/Adrian_Rockall)\
**Post date:** [October 14, 2021, 12:18pm UTC](https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132/2 "2021-10-14T12:18:40Z")

</div>

You could look at [Flow Event Bus App for Homey | Homey](https://homey.app/en-gb/app/name.klep.flow-event-bus/Flow-Event-Bus/)  
I used it for a similar scenario a few years back.

Or there is the newer [Homey Community Store](https://store.homey.community/app/nl.qluster-it.HOOP) that might be able to do it.

---

<div class="post-metadata">

**Author:** ![Joost\_Schevers](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/joost_schevers/32/16498_2.png) [@Joost\_Schevers](https://community.homey.app/u/Joost_Schevers)\
**Post date:** [October 14, 2021, 1:37pm UTC](https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132/3 "2021-10-14T13:37:53Z")

</div>

I actually use Flow Event Bus.  
I don’t see yet though how I could use it to simplify/optimize the suggested functionality.

Could you elaborate on how you would implenent this using the Flow Event Bus?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [October 14, 2021, 3:17pm UTC](https://community.homey.app/t/select-next-previous-of-a-sequence-of-flows/53132/4 "2021-10-14T15:17:10Z")

</div>

Like Adrian suggested, the [H.O.O.P. flow programmer](https://community.homey.app/t/h-o-o-p-hope-homey-object-oriented-programming/43709) can do this in one flow (okay, I needed 2), but idk if things get more clear/organized.  
Here’s an example, to dim a light to low, middle, high and off, by pushing the same knob, in a sequence loop. That’s like switching to the next scene in your situation.  
Maybe this is what you’re looking for.

While the text on some cards runs out of space, here’s a screenshot of the ‘and’ section of flow1:

 ![Screenshot_20211014-172637_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/d/cd47f5394c4ec6eef57c08ac0b98488ec7f9698c.jpeg)
