From 4af2953a6cbfdd4024f01950091a636c5f5d32e6 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Mon, 18 May 2020 22:17:01 +0300 Subject: [PATCH] Add meeting automations. Improve and combine AC automations --- .../advanced_dashboard/08_automations.yaml | 6 +- .../devices/living_room/toshiba_ac.yaml | 65 ++++++------------- config/packages/modules/speech.yaml | 20 ++++++ config/packages/sensors/meeting.yaml | 11 ++++ 4 files changed, 53 insertions(+), 49 deletions(-) create mode 100644 config/packages/sensors/meeting.yaml diff --git a/config/lovelace/advanced_dashboard/08_automations.yaml b/config/lovelace/advanced_dashboard/08_automations.yaml index c885c6a..ffe8982 100644 --- a/config/lovelace/advanced_dashboard/08_automations.yaml +++ b/config/lovelace/advanced_dashboard/08_automations.yaml @@ -25,6 +25,8 @@ cards: entities: - automation.titanium_turn_off_when_idle - automation.github_download + - automation.speech_enable_when_meeting_is_over + - automation.speech_disable_when_meeting_starts - type: entities title: Presence @@ -147,9 +149,7 @@ cards: icon: mdi:air-purifier entities: - automation.climate_ac_turn_on_if_hot - - automation.climate_ac_turn_off_if_window_opened - - automation.climate_ac_turn_off_if_cold - - automation.climate_ac_turn_off_if_working_at_night + - automation.climate_ac_turn_off - type: divider - automation.purifier_on_start_sync_and_update_state - automation.purifier_change_speed diff --git a/config/packages/devices/living_room/toshiba_ac.yaml b/config/packages/devices/living_room/toshiba_ac.yaml index 0b1c52c..b0583ab 100644 --- a/config/packages/devices/living_room/toshiba_ac.yaml +++ b/config/packages/devices/living_room/toshiba_ac.yaml @@ -33,7 +33,9 @@ automation: entity_id: sensor.trisensor_temperature above: 24 - platform: state - entity_id: binary_sensor.living_room_right_window_on_off_wrapper + entity_id: + - binary_sensor.living_room_right_window_on_off_wrapper + - binary_sensor.bedroom_right_window_on_off_wrapper from: "on" to: "off" condition: @@ -80,59 +82,30 @@ automation: message: "AC · Switching on · Above 24 degrees, windows closed" domain: climate - - alias: Climate · AC · Turn off if window opened + - alias: Climate · AC · Turn off trigger: - platform: state - entity_id: binary_sensor.living_room_right_window_on_off_wrapper - from: "off" - to: "on" - condition: - condition: and - conditions: - - condition: template - value_template: "{{ not is_state('climate.toshiba_ac', 'off') }}" - action: - - service: climate.turn_off - entity_id: climate.toshiba_ac - - service: logbook.log - data: - name: "💨 Climate Module · " - message: "AC · Switching off · Window opene" - domain: climate + - platform: time + at: "05:00:00" - - alias: Climate · AC · Turn off if cold - trigger: - platform: numeric_state - entity_id: sensor.trisensor_temperature - below: 20 - condition: - condition: and - conditions: - - condition: template - value_template: "{{ not is_state('climate.toshiba_ac', 'off') }}" - action: - - service: climate.turn_off - entity_id: climate.toshiba_ac - - service: logbook.log - data: - name: "💨 Climate Module · " - message: "AC · Switching off · Below 20 degrees" - domain: climate + # TODO: this below trigger works only for summer :) + - platform: numeric_state + entity_id: sensor.trisensor_temperature + below: 20 - - alias: Climate · AC · Turn off if working at night - trigger: - platform: time - at: "05:00:00" + - platform: state + entity_id: + - binary_sensor.living_room_right_window_on_off_wrapper + - binary_sensor.bedroom_right_window_on_off_wrapper + from: "off" + to: "on" condition: - condition: and - conditions: - - condition: template - value_template: "{{ not is_state('climate.toshiba_ac', 'off') }}" + condition: template + value_template: "{{ not is_state('climate.toshiba_ac', 'off') }}" action: - service: climate.turn_off entity_id: climate.toshiba_ac - service: logbook.log data: name: "💨 Climate Module · " - message: "AC · Switching off · It's 5 AM" + message: "AC · Switching off" domain: climate diff --git a/config/packages/modules/speech.yaml b/config/packages/modules/speech.yaml index 4efe0b1..f8eeeb0 100644 --- a/config/packages/modules/speech.yaml +++ b/config/packages/modules/speech.yaml @@ -130,3 +130,23 @@ automation: data_template: message_id: "{{ trigger.event.data.message.message_id}}" chat_id: "{{ trigger.event.data.chat_id }}" + + - alias: Speech · Disable when meeting starts + trigger: + platform: state + entity_id: binary_sensor.in_a_meeting + from: "off" + to: "on" + action: + - service: input_boolean.turn_off + entity_id: input_boolean.speech_notifications + + - alias: Speech · Enable when meeting is over + trigger: + platform: state + entity_id: binary_sensor.in_a_meeting + from: "on" + to: "off" + action: + - service: input_boolean.turn_on + entity_id: input_boolean.speech_notifications diff --git a/config/packages/sensors/meeting.yaml b/config/packages/sensors/meeting.yaml new file mode 100644 index 0000000..26616ce --- /dev/null +++ b/config/packages/sensors/meeting.yaml @@ -0,0 +1,11 @@ +binary_sensor: + - platform: template + sensors: + in_a_meeting: + friendly_name: In a meeting + value_template: >- + + {% set slack_emoji = state_attr('sensor.slack_georgi', 'status_emoji') %} + {% set slack_status = state_attr('sensor.slack_georgi', 'status_text') %} + + {{ slack_emoji == ':spiral_calendar_pad:' or 'meeting' in slack_status.lower() }}