구글홈, 리시버, TV, PC등 장치가 playing중 또는 사용중일 때 해당장치만 볼륨 업다운.
PC에 TV를 모니터로 쓰고 있어 PC와 TV가 동시에 켜졌을 때는 PC볼륨만 업다운하고 TV만 켜졌을 때는 TV볼륨 업다운.
automations:
- id: 버튼-쉼포니스크
alias: 버튼-쉼포니스크
trigger:
- entity_id: sensor.li_volume_remote_action
platform: state
to:
- "rotate_right"
- "rotate_left"
- "rotate_stop"
- "play_pause"
- "skip_forward"
- "skip_backward"
action:
- choose:
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == ''rotate_right'' }}'
sequence: #볼륨 업
- entity_id: #구글홈,허브 볼륨업
- input_number.speaker_volume
- input_number.speaker_cast_volume
- input_number.speaker_hub_volume
service_template: "{{ is_state('media_player.all', 'playing') |
iif('input_number.increment', 'script.nop') }}"
- entity_id: input_number.speaker_rv_volume #리시버 볼륨업
service_template: "{{ is_state('media_player.rv', 'playing') |
iif('input_number.increment', 'script.nop') }}"
- entity_id: input_number.speaker_tv_volume #TV 볼륨업
service_template: "{{ (is_state('media_player.tv', 'on')
and is_state('switch.pc', 'off')) |
iif('input_number.increment', 'script.nop') }}"
- entity_id: input_number.speaker_pc_volume #PC 볼륨업
service_template: "{{ (is_state('media_player.tv', 'on')
and is_state('switch.pc', 'on')) |
iif('input_number.increment', 'script.nop') }}"
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == ''rotate_left'' }}'
sequence: #볼륨 다운
- entity_id:
- input_number.speaker_volume
service_template: "{{ is_state('media_player.all', 'playing') |
iif('input_number.decrement', 'script.nop') }}"
- entity_id: input_number.speaker_rv_volume
service_template: "{{ is_state('media_player.rv', 'playing') |
iif('input_number.decrement', 'script.nop') }}"
- entity_id: input_number.speaker_tv_volume
service_template: "{{ (is_state('media_player.tv', 'on')
and is_state('switch.pc', 'off')) |
iif('input_number.decrement', 'script.nop') }}"
- entity_id: input_number.speaker_pc_volume
service_template: "{{ (is_state('media_player.tv', 'on')
and is_state('switch.pc', 'on')) |
iif('input_number.decrement', 'script.nop') }}"
- conditions:
- condition: template
value_template: '{{ trigger.to_state.state == ''play_pause'' }}'
sequence: #음악 ON/OFF
- entity_id: switch.classic_music
service: switch.toggle
mode: single
- id: 미디어-볼륨_변경
alias: 미디어-볼륨 변경
initial_state: 'on'
trigger:
- platform: state
entity_id:
- input_number.speaker_volume
id: "1"
- platform: state
entity_id:
- input_number.speaker_rv_volume
id: "2"
- platform: state
entity_id:
- input_number.speaker_tv_volume
id: "3"
- platform: state
entity_id:
- input_number.speaker_pc_volume
id: "4"
action:
- choose:
- conditions:
- condition: trigger
id: "1"
sequence:
- service: script.speaker_cast_volume
- service: script.speaker_hub_volume
- conditions:
- condition: trigger
id: "2"
sequence:
- service: script.speaker_rv_volume
- conditions:
- condition: trigger
id: "3"
sequence:
- service: script.speaker_tv_volume
- conditions:
- condition: trigger
id: "4"
sequence:
- service: script.speaker_pc_volume
mode: queued
script:
speaker_volume:
sequence:
- service: media_player.volume_set
entity_id:
- media_player.homelivingroom
- media_player.homemoving
- media_player.castaudio
- media_player.hubbedroom
- media_player.hubkitchen
- media_player.hubatelier
data_template:
volume_level: '{{ states.input_number.speaker_volume.state }}'
speaker_rv_volume:
sequence:
- service: media_player.volume_set
entity_id: media_player.rv
data_template:
volume_level: '{{ states.input_number.speaker_rv_volume.state }}'
speaker_tv_volume:
sequence:
- service: media_player.volume_set
entity_id: media_player.tv
data_template:
volume_level: '{{ states.input_number.speaker_tv_volume.state }}'
speaker_pc_volume:
sequence:
- service_template: >
{% if states.input_number.speaker_pc_volume.state | int == 100.0 %}
shell_command.pc_volume_100
{% elif states.input_number.speaker_pc_volume.state | int == 90.0 %}
shell_command.pc_volume_90
{% elif states.input_number.speaker_pc_volume.state | int == 80.0 %}
shell_command.pc_volume_80
{% elif states.input_number.speaker_pc_volume.state | int == 70.0 %}
shell_command.pc_volume_70
{% elif states.input_number.speaker_pc_volume.state | int == 60.0 %}
shell_command.pc_volume_60
{% elif states.input_number.speaker_pc_volume.state | int == 50.0 %}
shell_command.pc_volume_50
{% elif states.input_number.speaker_pc_volume.state | int == 40.0 %}
shell_command.pc_volume_40
{% elif states.input_number.speaker_pc_volume.state | int == 30.0 %}
shell_command.pc_volume_30
{% elif states.input_number.speaker_pc_volume.state | int == 20.0 %}
shell_command.pc_volume_20
{% elif states.input_number.speaker_pc_volume.state | int == 10.0 %}
shell_command.pc_volume_10
{% elif states.input_number.speaker_pc_volume.state | int == 0.0 %}
shell_command.pc_volume_0
{% else %}
{% endif %}
input_number:
speaker_volume:
name: 통합볼륨
icon: mdi:volume-medium
initial: 0.4
min: 0.0
max: 1.0
step: 0.05
speaker_cast_volume:
name: 캐스트볼륨
icon: mdi:volume-medium
initial: 0.5
min: 0.0
max: 1.0
step: 0.05
speaker_hub_volume:
name: 허브볼륨
icon: mdi:volume-medium
initial: 0.6
min: 0.0
max: 1.0
step: 0.05
speaker_tv_volume:
name: TV볼륨
icon: mdi:volume-medium
initial: 0.5
min: 0.0
max: 1.0
step: 0.05
speaker_rv_volume:
name: RV볼륨
icon: mdi:volume-medium
initial: 0.5
min: 0.0
max: 1.0
step: 0.05
speaker_pc_volume:
name: PC볼륨
icon: mdi:volume-medium
initial: 50
min: 0
max: 100
step: 25
** PC볼륨조절을 위해 Windows에 설치한 유틸은 Airytec Switch Off와 Soundvolumeview
** (2023/11/14) 최근 PC볼륨은 PC용 리모컨 리시버를 이용해 RM4 mini에 볼륨 up/down을 학습시켜 컨트롤. Airytec Switch off를 사용하면 최초 반응할 때 시간차가 제법있어 불편해 변경.
** 학습시킨 리모컨 신호를 리시버와 PC에 동시에 쏘면 하나의 신호만 가니 장치에 우선순위를 둬 조건에 따라 하나의 장치에만 보내야만 됨.