Select Button | input_boolean(s) ? #1108
Replies: 4 comments
-
Like - i have an input_select from alarmo which.. when I use it.. gives me a nice drop down of the states I can choose between and when I tap one it is selected. I'd like the same but with a few input_booleans I have for vacation mode... If I create a sub-button I can select the input_boolean but I still need to select an entity but there is none.. so to speak. |
Beta Was this translation helpful? Give feedback.
-
I think this should be solved with an automation. |
Beta Was this translation helpful? Give feedback.
-
can you give an example of this? maybe I am not explaining it properly but i want a button which is named "home state" |
Beta Was this translation helpful? Give feedback.
-
Yes I recently learned this can also go through a template select helper. So what you need to do:
State template {% set activeElements = states.input_boolean
| selectattr('state','equalto','on')
| selectattr('entity_id', 'in', label_entities('TestBooleans'))
| sort(reverse=true, attribute='last_changed')
| map(attribute='name')
| list
%}
{% if activeElements | length == 0 %}
Off
{% else %}
{{activeElements|first}}
{% endif %} Available options {{(states.input_boolean
| selectattr('entity_id', 'in', label_entities('TestBooleans'))
| map(attribute='name')
| list
| sort) + ['Off']
}} Actions on select: sequence:
- if:
- condition: template
value_template: "{{ option != 'Off' }}"
then:
- action: homeassistant.turn_on
target:
entity_id: |
{{
states.input_boolean
| selectattr('name', 'eq', option)
| map(attribute='entity_id')
| first
}}
- action: homeassistant.turn_off
metadata: {}
data: {}
target:
entity_id: >-
{{(states.input_boolean | selectattr('entity_id', 'in',
label_entities('TestBooleans')) | rejectattr('name','match', option) |
map(attribute='entity_id') | list) }}
|
Beta Was this translation helpful? Give feedback.
-
hi
is it possible to create a select button but with input_booleans..
it looks like I can only use input_select and similar.. but not helpers.
am i missing some clever way of doing this?
Beta Was this translation helpful? Give feedback.
All reactions