#What are you trying to do?

1 messages ยท Page 1 of 1 (latest)

iron oasis
#

I have a list of options that a button cycles through on each press

#

Currently it's handled by having an input number that determins which option is actioned and then increments on actioning it, meaning the next option triggers on the next press. This input number is reset after 3 seconds without a button press

#

This means if I re-order the options or add a new one, I have to manually edit each numerical position reference

steady wave
#

This is a select list?

dusk dirgeBOT
iron oasis
#

No, it's a choose building block within the automation that references an input number. I tried using a select list originally but that was before you could easily re-order them, so I moved over to input number

#

I now have a dozen of these style automations (they're used for scene management on my light switches)

steady wave
#

Ok, I would switch to using an input_select, because you can just select the next one.

#

Share the YAML of your current automation.

iron oasis
#

Do you want the whole yaml for the entire switch, or just the choose block?

steady wave
#

The whole thing for your automation. Otherwise it's like trying to see an a dark castle with just a candle in the library ๐Ÿ˜„

iron oasis
#

of course, sorry

steady wave
#

No worries, thanks for asking instead of just assuming the choose block would be alright ๐Ÿ™‚

iron oasis
#

What's the prefered method for sharing large text blocks? Pastebin?

steady wave
#

Pastebin does weird things to YAML

iron oasis
#

The element in question (Scene Toggling) references an input number helper for tracking option position

steady wave
#

Ok, I see what is going on.

iron oasis
#

Well that's something, I was worried my terrible automation writing would render it impenetrable

steady wave
iron oasis
#

Sure thing (I've been using this framework since day one of my home assistant build, so it's not the most ellegant and could do with an overhaul)

steady wave
#

I'm just noodling on the best way to do this.

iron oasis
#

thank you

steady wave
#

I think realistically, the best thing to do is to create selectsโ€”because then you can use regular state conditions to check if it's "Rainbow", or "Banana" or "Unicorn" and the order doesn't matter.

iron oasis
#

That'll mean though the order will be dictated by the input select, right? And if I want to add a new option to the button, I'll need to also add it to the input select?

steady wave
#

And what you do is you set the entities (recommended over devices so you can swap them more easily), and then call input_select.select_next, and whatever order you've set your options to in the input select will handle that for you

#

Yes, you'd need to add it in both places, but if you temporarily disable one, e.g. "Halloween", then you only need to remove it from the input select, the code in the automation can remain present.

#

And then next September/October you can add it back, at whatever position you like.

iron oasis
#

Oh, that's a good point

steady wave
#

(Just an example, you might not want seasonal lighting, but you might want something for school holidays or similar)

iron oasis
#

No, that's 100% a use case I'd have as I'm always doing seasonal stuff

steady wave
#

Well, that was a good guess on my part then ๐Ÿ˜‚

iron oasis
#

Okay, yeah, given input selects have been updated a fair bit since I last set up this structure, that'll be the best bet

#

Thank you for your help!

steady wave
#

I think it will be for now!

#

Glad to have helped ๐Ÿ˜„
If you do need any more help later on, I'd recommend posting to #automations-archived and linking this thread, as unless other folks saw the start of the thread they likely won't see a reply.

#

(Silly Discord UI, threads are great, at times!)

iron oasis
#

Oh yes, I'm well aware of the doubled edged sword that is threads, I'm a mod on a fairly big server myself

steady wave
#

Cool, I just wanted to make sure you knew as a lot of folks don't realise that ๐Ÿ˜„

iron oasis
#

Thank you, you've been so helpful

steady wave
#

Not a problem, it's a pleasure ๐Ÿ˜„

#

@iron oasis random idea: you could use a double press to go back one with input_select.select_previous, assuming your button supports it. Just thinking if someone overshoots, being able to "step back" is a nice bonus.

iron oasis
#

Oh, I think it might and that's a really good idea, thank you!

steady wave
#

You're welcome! You can tell it's a good problem because I'm still thinking ๐Ÿ˜‚