#What are you trying to do?
1 messages ยท Page 1 of 1 (latest)
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
This is a select list?
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)
Ok, I would switch to using an input_select, because you can just select the next one.
Share the YAML of your current automation.
Do you want the whole yaml for the entire switch, or just the choose block?
The whole thing for your automation. Otherwise it's like trying to see an a dark castle with just a candle in the library ๐
of course, sorry
No worries, thanks for asking instead of just assuming the choose block would be alright ๐
What's the prefered method for sharing large text blocks? Pastebin?
The element in question (Scene Toggling) references an input number helper for tracking option position
Ok, I see what is going on.
Well that's something, I was worried my terrible automation writing would render it impenetrable
I also see you're using device triggers, you might want to look into event triggers: https://www.home-assistant.io/integrations/event
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)
Yeah, similarly the template conditions could just be numeric state checks: https://www.home-assistant.io/docs/scripts/conditions/#numeric-state-condition
I'm just noodling on the best way to do this.
thank you
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.
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?
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.
Oh, that's a good point
(Just an example, you might not want seasonal lighting, but you might want something for school holidays or similar)
No, that's 100% a use case I'd have as I'm always doing seasonal stuff
Well, that was a good guess on my part then ๐
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!
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!)
Oh yes, I'm well aware of the doubled edged sword that is threads, I'm a mod on a fairly big server myself
Cool, I just wanted to make sure you knew as a lot of folks don't realise that ๐
Thank you, you've been so helpful
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.
Oh, I think it might and that's a really good idea, thank you!
You're welcome! You can tell it's a good problem because I'm still thinking ๐