wasn’t sure how to build the topic to contain my idea, but here’s the explaination:
I use quite a few input_select components to keep “settings” of my hass.io - different people preferences about notifications, specific scenes for rooms, and planned sprinkler integration. I want to keep the selects as readable for every user as possible, so couple of them are not only 1-word or number, but like a small sentences [for example one of the options for notifications: “Get all important, but none at home” etc.]. is there a way to create numeric aliases for the options to use them in conditions or while setting them via scripts/automations? I’m starting to think that words are confusing my automations & want to make it easier at the yaml-side, but keep informative for humans.
in simple words: I’d love to have a possibility to check input_selects in conditions like “if input_selects.week_option > 3” but have that options visible to user as words, not numbers. that way I could also set input_select.week_option to, let’s say, 4, and that would mean that users will see “thursday” as selected setting*.
*disclaimer: week days are only as an example, I know I can number them with now() function that’s not the case
that definitely will work for attribute read and will make some of my conditions easier to grasp
I guess that the opposite - selecting an option via automation/script based on number (“select 1” which would on fact select the “Item B” selection) is not possible?
@pejotigrek any chance that you can paste an example of your automation? I’m trying to do the same with my solax inverter states and I’d love to have a way to decode/encode the human readable inverter state with the [0,1,2,3] operation code needed to set the state.
@luismsousa I guess my automation won’t help you as it was altered maaaaany times after this post but here’s what you can try in your automation, assuming, that it is triggeredy by input_select’s option change:
- service: <state change service>
target:
entity_id: <entity to change the state in>
data:
state: {{ state_attr(trigger.entity_id,'options').index(states(trigger.entity_id)) }}