input_select.select_option으로 원하는 옵션을 선택하지만 선택옵션에 대한 자동화는 실행시키지 않는 방법으로 처음 실행시 항상 1번 전등부터 켜는 자동화.
자동화에 연결되지 않은 idle옵션을 만들어 항상 시작하기 원하는 옵션 전단계에 두는 방법을 많이 사용했는데 그건 input_select순환시 idle에서 순환 작업이 끊기는 문제 발생.
input_select에 연결된 자동화가 많지 않다면 해당 input_select를 사용하는 자동화를 off하고 선택옵션을 사용하는 자동화를 실행한 후 on하는 방법이 여러 경우에서 예외상황이 가장 적게 발생.
아래 자동화는 주방 레일조명의 개별 전구를 버튼을 누를 때마다 순환하며 켜는 자동화인데 마지막 끌 때는 항상 4번조명에 가져다 놓는 자동화며 순환은 벽스위치에서 input_select.select_next명령어 사용.
**레일조명 전체를 group 도메인 아래에서 그룹으로 묶으면 해당그룹을 선택한 후 개별 조명을 따로 제어가능하고 light 도메인 아래에서 그룹으로 묶으면 전체 조명이 하나의 light entity로 작동.
automations.yaml
- id: input_ki_bulb
alias: input_ki_bulb
mode: restart
trigger:
- platform: state
entity_id: input_select.ki_bulb
actions:
- action: homeassistant.turn_off
entity_id: group.kitchen
- action: light.turn_on
target:
entity_id: >
{% if trigger.to_state.state == 'light1' %}
light.kitchen_lamp1
{% elif trigger.to_state.state == 'light2' %}
light.kitchen_lamp2
{% elif trigger.to_state.state == 'light3' %}
light.kitchen_lamp3
{% elif trigger.to_state.state == 'light4' %}
light.kitchen_lamp4
{% endif %}
data:
color_temp_kevin: 3000
brightness: 250
- id: input-ki_bulb_reset
alias: input-ki_bulb_reset
trigger:
- platform: state
entity_id: group.kitchen
to: 'off'
for: '00:00:10'
condition:
- condition: not
conditions:
- condition: state
entity_id: input_select.ki_bulb
state: 'light4'
action:
- action: homeassistant.turn_off
entity_id: automation.input_ki_bulb
- action: input_select.select_option
target:
entity_id: input_select.ki_bulb
data:
option: light4
- delay: '00:00:01'
- action: homeassistant.turn_on
entity_id: automation.input_ki_bulb
input_select.yaml
ki_bulb:
name: Ki Bulb
initial: light4
options:
- light1
- light2
- light3
- light4