From 823cf4a6804e9f1469a9720b02083a42b3328932 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Sun, 21 Nov 2021 11:05:04 +0200 Subject: [PATCH] Add preferences support --- .../automation/light_on_set_temperature.yaml | 2 + .../advanced_dashboard/08_automations.yaml | 9 +++ .../home_dashboard/preferences_dashboard.yaml | 10 +++ .../guest_bedroom/guest_bedroom_switch.yaml | 8 +-- config/packages/modes/house_mode.yaml | 3 +- .../modules/lighting/areas/guest_bedroom.yaml | 4 +- .../modules/lighting/areas/hallway.yaml | 1 + .../modules/lighting/areas/kitchen.yaml | 6 +- .../preferences_guest_bedroom.yaml | 7 ++ .../preferences/preferences_milena.yaml | 69 +++++++++++++++++++ config/packages/modules/presence.yaml | 2 +- 11 files changed, 112 insertions(+), 9 deletions(-) create mode 100644 config/packages/modules/preferences/preferences_guest_bedroom.yaml create mode 100644 config/packages/modules/preferences/preferences_milena.yaml diff --git a/config/blueprints/automation/light_on_set_temperature.yaml b/config/blueprints/automation/light_on_set_temperature.yaml index 67efc39..48bba19 100644 --- a/config/blueprints/automation/light_on_set_temperature.yaml +++ b/config/blueprints/automation/light_on_set_temperature.yaml @@ -15,6 +15,8 @@ trigger: entity_id: !input light to: "on" +mode: queued + condition: condition: state entity_id: sensor.house_mode diff --git a/config/lovelace/advanced_dashboard/08_automations.yaml b/config/lovelace/advanced_dashboard/08_automations.yaml index 4c844d2..3747eb1 100644 --- a/config/lovelace/advanced_dashboard/08_automations.yaml +++ b/config/lovelace/advanced_dashboard/08_automations.yaml @@ -260,3 +260,12 @@ cards: entities: - automation.cover_living_room_open_at_morning - automation.cover_living_room_close_after_sunset + + - type: entities + title: Milena Preferences + icon: mdi:star-settings-outline + show_header_toggle: false + entities: + - automation.preferences_milena_enable + - automation.preferences_milena_disable + - automation.preferences_milena_kitchen_temperature_main_adjust_on_start diff --git a/config/lovelace/home_dashboard/preferences_dashboard.yaml b/config/lovelace/home_dashboard/preferences_dashboard.yaml index 80b9906..79476b2 100644 --- a/config/lovelace/home_dashboard/preferences_dashboard.yaml +++ b/config/lovelace/home_dashboard/preferences_dashboard.yaml @@ -149,3 +149,13 @@ - type: custom:button-card template: v3_button entity: binary_sensor.someone_home + + - type: custom:decluttering-card + template: v3_section_title + variables: + - title: Preferences Milena + - type: horizontal-stack + cards: + - type: custom:button-card + template: v3_button + entity: input_number.guest_bedroom_light_temp diff --git a/config/packages/devices/guest_bedroom/guest_bedroom_switch.yaml b/config/packages/devices/guest_bedroom/guest_bedroom_switch.yaml index a215967..37e2122 100644 --- a/config/packages/devices/guest_bedroom/guest_bedroom_switch.yaml +++ b/config/packages/devices/guest_bedroom/guest_bedroom_switch.yaml @@ -30,15 +30,15 @@ automation: sequence: - service: light.toggle entity_id: light.light_lohas_6 - data: + data_template: brightness_pct: 10 - color_temp: 154 + color_temp: "{{ states('input_number.guest_bedroom_light_temp') }}" default: - service: light.toggle entity_id: light.light_lohas_6 - data: + data_template: brightness_pct: 100 - color_temp: 154 + color_temp: "{{ states('input_number.guest_bedroom_light_temp') }}" double_click: - service: light.toggle diff --git a/config/packages/modes/house_mode.yaml b/config/packages/modes/house_mode.yaml index 79b51fb..c3c6b5d 100644 --- a/config/packages/modes/house_mode.yaml +++ b/config/packages/modes/house_mode.yaml @@ -52,7 +52,8 @@ sensor: day {% endif %} {% else %} - {% if is_state('input_select.bedroom_mode', 'night') and is_state('input_select.guest_bedroom_mode', 'night') %} + {% if (is_state('input_select.bedroom_mode', 'night') or is_state('input_select.bedroom_mode', 'bed')) + and is_state('input_select.guest_bedroom_mode', 'night') %} night {% else %} day diff --git a/config/packages/modules/lighting/areas/guest_bedroom.yaml b/config/packages/modules/lighting/areas/guest_bedroom.yaml index 6e80ec1..b21603d 100644 --- a/config/packages/modules/lighting/areas/guest_bedroom.yaml +++ b/config/packages/modules/lighting/areas/guest_bedroom.yaml @@ -13,8 +13,8 @@ script: - delay: 00:00:02 - service: light.turn_on entity_id: light.light_lohas_6 - data: - color_temp: 154 + data_template: + color_temp: "{{ states('input_number.guest_bedroom_light_temp') }}" - service: scene.turn_on entity_id: scene.guest_bedroom_before_confirm - delay: 00:00:01 diff --git a/config/packages/modules/lighting/areas/hallway.yaml b/config/packages/modules/lighting/areas/hallway.yaml index f021968..66be345 100644 --- a/config/packages/modules/lighting/areas/hallway.yaml +++ b/config/packages/modules/lighting/areas/hallway.yaml @@ -57,6 +57,7 @@ automation: entity_id: - light.hue_white_1 - light.hue_1 + - light.hallway - service: light.turn_on entity_id: light.browser_hallway data: diff --git a/config/packages/modules/lighting/areas/kitchen.yaml b/config/packages/modules/lighting/areas/kitchen.yaml index 42eea5f..1bce8c1 100644 --- a/config/packages/modules/lighting/areas/kitchen.yaml +++ b/config/packages/modules/lighting/areas/kitchen.yaml @@ -33,7 +33,9 @@ automation: entity_id: sensor.dark_sky_cloud_coverage above: 80 - service: light.turn_on - entity_id: light.kitchen + entity_id: + - light.kitchen_main + - light.kitchen_secondary data: brightness_pct: 100 # Turn on in Night Mode @@ -71,6 +73,8 @@ automation: entity_id: - light.ledvance_1 - light.hue_ambiance_1 + - light.kitchen_main + - light.kitchen_secondary - service: light.turn_on entity_id: light.browser_kitchen data: diff --git a/config/packages/modules/preferences/preferences_guest_bedroom.yaml b/config/packages/modules/preferences/preferences_guest_bedroom.yaml new file mode 100644 index 0000000..da8d11b --- /dev/null +++ b/config/packages/modules/preferences/preferences_guest_bedroom.yaml @@ -0,0 +1,7 @@ +input_number: + guest_bedroom_light_temp: + name: Guest bedroom light temp + min: 154 + max: 500 + step: 1 + icon: bha:table-lamp-variant diff --git a/config/packages/modules/preferences/preferences_milena.yaml b/config/packages/modules/preferences/preferences_milena.yaml new file mode 100644 index 0000000..e19d401 --- /dev/null +++ b/config/packages/modules/preferences/preferences_milena.yaml @@ -0,0 +1,69 @@ +binary_sensor: + - platform: template + sensors: + milena_preferences_enabled: + friendly_name: Milena Preferences + value_template: "{{ is_state('device_tracker.iphone_de_yovcheva', 'home') }}" + icon_template: > + {% if is_state('device_tracker.iphone_de_yovcheva', 'home') %} mdi:star-settings + {% else %} mdi:star-settings-outline + {% endif %} + + +automation: + - alias: Preferences · Milena · Enable + trigger: + - platform: state + entity_id: device_tracker.iphone_de_yovcheva + from: "not_home" + to: "home" + action: + - service: automation.turn_off + entity_id: + - automation.lighting_kitchen_temperature_main_adjust_on_start + - automation.lighting_kitchen_temperature_secondary_adjust_on_start + - automation.lighting_kitchen_temperature_main_sunset + - automation.lighting_kitchen_temperature_secondary_sunset + - automation.lighting_kitchen_temperature_main_night + - automation.lighting_kitchen_temperature_secondary_night + - service: automation.turn_on + entity_id: + - automation.preferences_milena_kitchen_temperature_main_adjust_on_start + - service: input_number.set_value + entity_id: input_number.guest_bedroom_light_temp + data: + value: 154 + + - alias: Preferences · Milena · Disable + trigger: + - platform: state + entity_id: device_tracker.iphone_de_yovcheva + from: "home " + to: "not_home" + action: + - service: automation.turn_on + entity_id: + - automation.lighting_kitchen_temperature_main_adjust_on_start + - automation.lighting_kitchen_temperature_secondary_adjust_on_start + - automation.lighting_kitchen_temperature_main_sunset + - automation.lighting_kitchen_temperature_secondary_sunset + - automation.lighting_kitchen_temperature_main_night + - automation.lighting_kitchen_temperature_secondary_night + - service: automation.turn_off + entity_id: + - automation.preferences_milena_kitchen_temperature_main_adjust_on_start + - service: input_number.set_value + entity_id: input_number.guest_bedroom_light_temp + data: + value: 500 + + - alias: Preferences · Milena · Kitchen · Temperature · Main · Adjust on start + use_blueprint: + path: light_on_set_temperature.yaml + input: + light: + - light.kitchen_main + - light.kitchen_secondary + day_temp: 153 + evening_temp: 153 + night_temp: 153 diff --git a/config/packages/modules/presence.yaml b/config/packages/modules/presence.yaml index 1849c98..ba7449b 100644 --- a/config/packages/modules/presence.yaml +++ b/config/packages/modules/presence.yaml @@ -62,7 +62,7 @@ binary_sensor: device_class: presence value_template: "{{ is_state('input_boolean.player_2_home', 'on') }}" icon_template: > - {% if is_state('input_boolean.georgi_home', 'on') %} mdi:account + {% if is_state('input_boolean.player_2_home', 'on') %} mdi:account {% else %} mdi:account-off-outline {% endif %}