From dac8d3d00dbf2a54ae998aa523c1f5b962bc5ea9 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Thu, 23 Apr 2020 21:19:28 +0300 Subject: [PATCH] Add bed_led light --- config/floorplan-lovelace.yaml | 14 +++++++----- config/home-lovelace.yaml | 22 ++++++++++++------- .../picture_elements/light_switches.yaml | 7 ++++++ .../picture_elements/sensors.yaml | 18 +++++++++++++++ config/lovelace/home_dashboard/00_home.yaml | 18 ++++++++++----- .../home_dashboard/02_master_bedroom.yaml | 1 + config/lovelace/home_dashboard/09_system.yaml | 3 +-- config/packages/modes/domestina.yaml | 3 +-- config/packages/modes/house_mode.yaml | 20 ++++------------- config/packages/modules/lighting/groups.yaml | 1 + config/packages/modules/lighting/state.yaml | 13 +++++++++-- config/packages/modules/lighting/zha.yaml | 5 +++++ config/packages/routines/bedtime.yaml | 4 ++++ config/packages/routines/good_night.yaml | 8 +++++++ 14 files changed, 96 insertions(+), 41 deletions(-) create mode 100644 config/packages/modules/lighting/zha.yaml diff --git a/config/floorplan-lovelace.yaml b/config/floorplan-lovelace.yaml index 631d14b..fe15a59 100644 --- a/config/floorplan-lovelace.yaml +++ b/config/floorplan-lovelace.yaml @@ -11,8 +11,12 @@ views: panel: true icon: mdi:floor-plan cards: - - type: picture-elements - image: /local/images/floorplan/floorplan_night_transparent.png - style: | - height: 100% - elements: !include_dir_merge_list lovelace/floorplan-dashboard/picture_elements + - type: 'custom:config-template-card' + entities: + - light.bed_led + card: + type: picture-elements + image: /local/images/floorplan/floorplan_night_transparent.png + style: | + height: 100% + elements: !include_dir_merge_list lovelace/floorplan-dashboard/picture_elements diff --git a/config/home-lovelace.yaml b/config/home-lovelace.yaml index 6eaee4a..06d03c6 100644 --- a/config/home-lovelace.yaml +++ b/config/home-lovelace.yaml @@ -44,14 +44,24 @@ views: template: small entity: light.living_room_main_lights name: Living room - - type: custom:button-card - template: small - entity: light.master_bedroom_main_lights - name: M. Bedroom - type: custom:button-card template: small entity: light.tuya_hallway_main_lights name: Hallway + - type: horizontal-stack + cards: + - type: custom:button-card + template: small + entity: light.master_bedroom_main_lights + name: "M. Bedroom" + - type: custom:button-card + template: small + entity: light.bedside_light + name: Bedside + - type: custom:button-card + template: small + entity: light.bed_led + name: Bed - type: horizontal-stack cards: - type: custom:button-card @@ -61,10 +71,6 @@ views: - type: custom:button-card template: small entity: light.pc - - type: custom:button-card - template: small - entity: light.bedside_light - name: Bedside - type: custom:button-card template: small entity: light.tuya_hallway_entrance_lights diff --git a/config/lovelace/floorplan-dashboard/picture_elements/light_switches.yaml b/config/lovelace/floorplan-dashboard/picture_elements/light_switches.yaml index 306d971..c082ed5 100644 --- a/config/lovelace/floorplan-dashboard/picture_elements/light_switches.yaml +++ b/config/lovelace/floorplan-dashboard/picture_elements/light_switches.yaml @@ -26,6 +26,13 @@ - top: 11.7% - left: 61.6% +- type: custom:decluttering-card + template: floorplan_state_icon + variables: + - entity: light.bed_led + - top: 11% + - left: 67.5% + - type: custom:decluttering-card template: floorplan_state_icon variables: diff --git a/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml b/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml index 7de7e07..4c2a373 100644 --- a/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml +++ b/config/lovelace/floorplan-dashboard/picture_elements/sensors.yaml @@ -167,3 +167,21 @@ background-color: rgba(255,0,0,0.5) color: transparent transform: perspective(2000px) rotateX(185.6deg) rotateY(73.1deg) + +# Master bedroom LED Strip +- type: conditional + conditions: + - entity: light.bed_led + state: "on" + elements: + - type: state-label + entity: light.bed_led + style: + width: 9.9% + height: 0 + top: 7.6% + left: 67.6% + background-color: '${ states[''light.bed_led''].attributes.rgb_color ? "rgb(" + states[''light.bed_led''].attributes.rgb_color[0] + "," + states[''light.bed_led''].attributes.rgb_color[1] + "," + states[''light.bed_led''].attributes.rgb_color[2] + ")" : "rgba(0, 0, 0, 0)" }' + + color: transparent + box-shadow: '${ states[''light.bed_led''].attributes.rgb_color ? "0 0 10px 5px rgba(" + states[''light.bed_led''].attributes.rgb_color[0] + "," + states[''light.bed_led''].attributes.rgb_color[1] + "," + states[''light.bed_led''].attributes.rgb_color[2] + ",0.7)" : "none" }' diff --git a/config/lovelace/home_dashboard/00_home.yaml b/config/lovelace/home_dashboard/00_home.yaml index 51ce535..04329a6 100644 --- a/config/lovelace/home_dashboard/00_home.yaml +++ b/config/lovelace/home_dashboard/00_home.yaml @@ -35,14 +35,24 @@ cards: template: small entity: light.living_room_main_lights name: Living room + - type: custom:button-card + template: small + entity: light.tuya_hallway_main_lights + name: Hallway + - type: horizontal-stack + cards: - type: custom:button-card template: small entity: light.master_bedroom_main_lights name: "M. Bedroom" - type: custom:button-card template: small - entity: light.tuya_hallway_main_lights - name: Hallway + entity: light.bedside_light + name: Bedside + - type: custom:button-card + template: small + entity: light.bed_led + name: Bed - type: horizontal-stack cards: - type: custom:button-card @@ -52,10 +62,6 @@ cards: - type: custom:button-card template: small entity: light.pc - - type: custom:button-card - template: small - entity: light.bedside_light - name: Bedside - type: custom:button-card template: small entity: light.tuya_hallway_entrance_lights diff --git a/config/lovelace/home_dashboard/02_master_bedroom.yaml b/config/lovelace/home_dashboard/02_master_bedroom.yaml index 761859f..cf5ca6d 100644 --- a/config/lovelace/home_dashboard/02_master_bedroom.yaml +++ b/config/lovelace/home_dashboard/02_master_bedroom.yaml @@ -72,6 +72,7 @@ cards: - fade: switch.light_le_4_fade - wifi: sensor.light_le_4_wifi - light.bedside_light + - light.bed_led - type: custom:decluttering-card template: sonos_media_player diff --git a/config/lovelace/home_dashboard/09_system.yaml b/config/lovelace/home_dashboard/09_system.yaml index fddfeb1..bb5d06e 100644 --- a/config/lovelace/home_dashboard/09_system.yaml +++ b/config/lovelace/home_dashboard/09_system.yaml @@ -117,8 +117,7 @@ cards: - automation.house_mode_set_to_day - automation.house_mode_set_to_bed - automation.house_mode_set_to_night - - automation.house_mode_set_to_night_on_bedside_switch_double_click - - automation.house_mode_set_to_bed_on_bedside_switch_hold + - automation.house_mode_toggle_on_bedside_switch_double_click - automation.alarm_wake_up - automation.alarm_set_time diff --git a/config/packages/modes/domestina.yaml b/config/packages/modes/domestina.yaml index 924e766..035110e 100644 --- a/config/packages/modes/domestina.yaml +++ b/config/packages/modes/domestina.yaml @@ -12,8 +12,7 @@ group: - automation.house_mode_set_to_night - automation.house_mode_set_to_bed - automation.house_mode_set_to_day - - automation.house_mode_set_to_night_on_bedside_switch_double_click - - automation.house_mode_set_to_bed_on_bedside_switch_hold + - automation.house_mode_toggle_on_bedside_switch_double_click - automation.alarm_wake_up - automation.music_play_pause_on_magic_cube_knock - automation.music_volume_down_on_magic_cube_rotate_left diff --git a/config/packages/modes/house_mode.yaml b/config/packages/modes/house_mode.yaml index 2b10503..c46e833 100644 --- a/config/packages/modes/house_mode.yaml +++ b/config/packages/modes/house_mode.yaml @@ -63,7 +63,7 @@ automation: action: - service: script.routine_good_night - - alias: House mode · Set to night on bedside switch double click + - alias: House mode · Toggle on bedside switch double click trigger: - platform: event event_type: zha_event @@ -76,26 +76,14 @@ automation: data_template: option: > - {% if now().strftime('%H')|int > 20 or now().strftime('%H')|int < 6 %} + {% if is_state('input_select.house_mode', 'day') %} + bed + {% elif is_state('input_select.house_mode', 'bed') %} night {% else %} day {% endif %} - - alias: House mode · Set to bed on bedside switch hold - trigger: - - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_bedside_switch_ieee - command: hold - action: - - service: input_select.select_option - entity_id: input_select.house_mode - data: - option: bed - - - alias: Alarm · Wake up trigger: platform: template diff --git a/config/packages/modules/lighting/groups.yaml b/config/packages/modules/lighting/groups.yaml index 37fb972..f99ccec 100644 --- a/config/packages/modules/lighting/groups.yaml +++ b/config/packages/modules/lighting/groups.yaml @@ -26,6 +26,7 @@ light: entities: - light.master_bedroom_main_lights - light.bedside_light + - light.bed_led - platform: group name: Kitchen main lights diff --git a/config/packages/modules/lighting/state.yaml b/config/packages/modules/lighting/state.yaml index 87eb204..2c670ed 100644 --- a/config/packages/modules/lighting/state.yaml +++ b/config/packages/modules/lighting/state.yaml @@ -35,8 +35,17 @@ automation: {% if is_state('input_select.house_mode', 'day') %} light.master_bedroom_main_lights + {% elif is_state('input_select.house_mode', 'bed') %} + light.bedside_light, 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 %} - light.bedside_light + 100 {% endif %} - alias: Lighting · Living room · Turn all lights on on Magic Cube flip 90 @@ -103,7 +112,7 @@ automation: - light.light_le_6 - light.light_le_8 data: - brightness_pct: 13 + brightness_pct: 13 # this is the lowest it'll go ¯\_(ツ)_/¯ - delay: 00:10:00 # reset brightness and turn off - service: light.turn_on diff --git a/config/packages/modules/lighting/zha.yaml b/config/packages/modules/lighting/zha.yaml new file mode 100644 index 0000000..cc6c089 --- /dev/null +++ b/config/packages/modules/lighting/zha.yaml @@ -0,0 +1,5 @@ +homeassistant: + customize: + light.bed_led: + friendly_name: Bed LED + icon: mdi:led-strip diff --git a/config/packages/routines/bedtime.yaml b/config/packages/routines/bedtime.yaml index 646e9d6..86c4cc9 100644 --- a/config/packages/routines/bedtime.yaml +++ b/config/packages/routines/bedtime.yaml @@ -5,6 +5,10 @@ script: # Set master bedroom state - service: light.turn_on entity_id: light.bedside_light + - service: light.turn_on + entity_id: light.bed_led + data: + brightness_pct: 100 - service: fan.turn_on entity_id: fan.philips_airpurifier - service: light.turn_off diff --git a/config/packages/routines/good_night.yaml b/config/packages/routines/good_night.yaml index c08742c..00b1db1 100644 --- a/config/packages/routines/good_night.yaml +++ b/config/packages/routines/good_night.yaml @@ -2,6 +2,11 @@ script: routine_good_night: alias: Routine · Going to sleep sequence: + - service: light.turn_on + entity_id: light.bed_led + data: + brightness_pct: 40 + color_temp: 500 - service: fan.turn_on entity_id: fan.philips_airpurifier - service: media_player.media_stop @@ -16,3 +21,6 @@ script: - service: script.say_discretely data: message: "Entering night mode. Good night!" + + - service: light.turn_off + entity_id: light.bed_led