From ccee1593bdd939c194f716dedab5598c97b391fa Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sat, 16 May 2020 13:51:01 +0300 Subject: [PATCH] Refactor packages - define automations per device where possible --- .../devices/bedroom/bedside_switch.yaml | 27 ++++++++ .../climate => devices/bedroom}/purifier.yaml | 0 .../packages/devices/bedroom/wall_switch.yaml | 45 ++++++++++++++ .../living_room}/bulsatcom.yaml | 0 .../living_room/desk_switch.yaml} | 12 ++++ .../living_room}/hdmi_switch.yaml | 0 .../devices/{ => living_room}/magic_cube.yaml | 0 .../devices/{ => living_room}/titanium.yaml | 0 .../living_room/toshiba_ac.yaml} | 0 .../media => devices/living_room}/tv.yaml | 0 .../devices/{ => living_room}/wallmote.yaml | 0 .../lighting/by_rooms/master_bedroom.yaml | 62 ------------------- config/packages/modules/media/music.yaml | 23 ------- 13 files changed, 84 insertions(+), 85 deletions(-) create mode 100644 config/packages/devices/bedroom/bedside_switch.yaml rename config/packages/{modules/climate => devices/bedroom}/purifier.yaml (100%) create mode 100644 config/packages/devices/bedroom/wall_switch.yaml rename config/packages/{modules/media => devices/living_room}/bulsatcom.yaml (100%) rename config/packages/{modules/lighting/by_rooms/living_room.yaml => devices/living_room/desk_switch.yaml} (76%) rename config/packages/{modules/media => devices/living_room}/hdmi_switch.yaml (100%) rename config/packages/devices/{ => living_room}/magic_cube.yaml (100%) rename config/packages/devices/{ => living_room}/titanium.yaml (100%) rename config/packages/{modules/climate/hvac.yaml => devices/living_room/toshiba_ac.yaml} (100%) rename config/packages/{modules/media => devices/living_room}/tv.yaml (100%) rename config/packages/devices/{ => living_room}/wallmote.yaml (100%) diff --git a/config/packages/devices/bedroom/bedside_switch.yaml b/config/packages/devices/bedroom/bedside_switch.yaml new file mode 100644 index 0000000..c456619 --- /dev/null +++ b/config/packages/devices/bedroom/bedside_switch.yaml @@ -0,0 +1,27 @@ +automation: + - alias: Lighting · Master bedroom · Toggle lights on bedside switch single click + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret master_bedroom_bedside_switch_ieee + command: single + action: + - service: light.toggle + data_template: + entity_id: >- + + {% if is_state('input_select.house_mode', 'day') %} + light.master_bedroom_main + {% elif is_state('input_select.house_mode', 'bed') %} + light.bedside, light.bed_led + {% elif is_state('input_select.house_mode', 'night') %} + light.bed_led + {% endif %} + brightness_pct: >- + + {% if is_state('input_select.house_mode', 'night') %} + 40 + {% else %} + 100 + {% endif %} diff --git a/config/packages/modules/climate/purifier.yaml b/config/packages/devices/bedroom/purifier.yaml similarity index 100% rename from config/packages/modules/climate/purifier.yaml rename to config/packages/devices/bedroom/purifier.yaml diff --git a/config/packages/devices/bedroom/wall_switch.yaml b/config/packages/devices/bedroom/wall_switch.yaml new file mode 100644 index 0000000..8bf6059 --- /dev/null +++ b/config/packages/devices/bedroom/wall_switch.yaml @@ -0,0 +1,45 @@ +automation: + - alias: Lighting · Master bedroom · Toggle lights on switch single click + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret master_bedroom_switch_ieee + command: single + action: + - service: light.toggle + data_template: + entity_id: light.master_bedroom_main + brightness_pct: >- + + {% if is_state('input_select.house_mode', 'night') %} + 40 + {% else %} + 100 + {% endif %} + + - alias: Lighting · Master bedroom · Toggle ambient lights on switch double click + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret master_bedroom_switch_ieee + command: double + action: + - service: light.toggle + data_template: + entity_id: + - light.bedside + - light.bed_led + brightness_pct: 100 + + - alias: Music · Master bedroom · Play pause on switch hold + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret master_bedroom_switch_ieee + command: hold + action: + - service: media_player.media_play_pause + entity_id: media_player.master_bedroom diff --git a/config/packages/modules/media/bulsatcom.yaml b/config/packages/devices/living_room/bulsatcom.yaml similarity index 100% rename from config/packages/modules/media/bulsatcom.yaml rename to config/packages/devices/living_room/bulsatcom.yaml diff --git a/config/packages/modules/lighting/by_rooms/living_room.yaml b/config/packages/devices/living_room/desk_switch.yaml similarity index 76% rename from config/packages/modules/lighting/by_rooms/living_room.yaml rename to config/packages/devices/living_room/desk_switch.yaml index a436eb4..6c64cac 100644 --- a/config/packages/modules/lighting/by_rooms/living_room.yaml +++ b/config/packages/devices/living_room/desk_switch.yaml @@ -36,3 +36,15 @@ automation: {% else %} 100 {% endif %} + + - alias: Music · Living Room · Play pause on desk switch hold + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret desk_switch_ieee + command: hold + action: + - service: media_player.media_play_pause + entity_id: media_player.living_room + diff --git a/config/packages/modules/media/hdmi_switch.yaml b/config/packages/devices/living_room/hdmi_switch.yaml similarity index 100% rename from config/packages/modules/media/hdmi_switch.yaml rename to config/packages/devices/living_room/hdmi_switch.yaml diff --git a/config/packages/devices/magic_cube.yaml b/config/packages/devices/living_room/magic_cube.yaml similarity index 100% rename from config/packages/devices/magic_cube.yaml rename to config/packages/devices/living_room/magic_cube.yaml diff --git a/config/packages/devices/titanium.yaml b/config/packages/devices/living_room/titanium.yaml similarity index 100% rename from config/packages/devices/titanium.yaml rename to config/packages/devices/living_room/titanium.yaml diff --git a/config/packages/modules/climate/hvac.yaml b/config/packages/devices/living_room/toshiba_ac.yaml similarity index 100% rename from config/packages/modules/climate/hvac.yaml rename to config/packages/devices/living_room/toshiba_ac.yaml diff --git a/config/packages/modules/media/tv.yaml b/config/packages/devices/living_room/tv.yaml similarity index 100% rename from config/packages/modules/media/tv.yaml rename to config/packages/devices/living_room/tv.yaml diff --git a/config/packages/devices/wallmote.yaml b/config/packages/devices/living_room/wallmote.yaml similarity index 100% rename from config/packages/devices/wallmote.yaml rename to config/packages/devices/living_room/wallmote.yaml diff --git a/config/packages/modules/lighting/by_rooms/master_bedroom.yaml b/config/packages/modules/lighting/by_rooms/master_bedroom.yaml index fde75e4..92e924a 100644 --- a/config/packages/modules/lighting/by_rooms/master_bedroom.yaml +++ b/config/packages/modules/lighting/by_rooms/master_bedroom.yaml @@ -41,65 +41,3 @@ script: data: color_temp: 500 brightness_pct: 20 - -automation: - - alias: Lighting · Master bedroom · Toggle lights on bedside switch single click - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_bedside_switch_ieee - command: single - action: - - service: light.toggle - data_template: - entity_id: >- - - {% if is_state('input_select.house_mode', 'day') %} - light.master_bedroom_main - {% elif is_state('input_select.house_mode', 'bed') %} - light.bedside, light.bed_led - {% elif is_state('input_select.house_mode', 'night') %} - light.bed_led - {% endif %} - brightness_pct: >- - - {% if is_state('input_select.house_mode', 'night') %} - 40 - {% else %} - 100 - {% endif %} - - - alias: Lighting · Master bedroom · Toggle lights on switch single click - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_switch_ieee - command: single - action: - - service: light.toggle - data_template: - entity_id: light.master_bedroom_main - brightness_pct: >- - - {% if is_state('input_select.house_mode', 'night') %} - 40 - {% else %} - 100 - {% endif %} - - - alias: Lighting · Master bedroom · Toggle ambient lights on switch double click - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_switch_ieee - command: double - action: - - service: light.toggle - data_template: - entity_id: - - light.bedside - - light.bed_led - brightness_pct: 100 diff --git a/config/packages/modules/media/music.yaml b/config/packages/modules/media/music.yaml index 7832b55..a1df501 100644 --- a/config/packages/modules/media/music.yaml +++ b/config/packages/modules/media/music.yaml @@ -20,26 +20,3 @@ script: entity_id: media_player.master_bedroom data_template: source: "{{ playlist | default('Evening Chill') }}" - -automation: - - alias: Music · Living Room · Play pause on desk switch hold - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret desk_switch_ieee - command: hold - action: - - service: media_player.media_play_pause - entity_id: media_player.living_room - - - alias: Music · Master bedroom · Play pause on switch hold - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_switch_ieee - command: hold - action: - - service: media_player.media_play_pause - entity_id: media_player.master_bedroom