Reduce and refactor automations

This commit is contained in:
Georgi Gardev
2022-12-01 16:02:00 +02:00
parent c35975492f
commit d58a40a0c2
12 changed files with 174 additions and 334 deletions
@@ -1,25 +0,0 @@
blueprint:
name: Light sun set temperature
domain: automation
input:
light:
temp:
after_offset:
default: "+00:00:00"
mode: parallel
trigger:
platform: sun
event: sunset
offset: !input after_offset
condition:
- condition: state
entity_id: !input light
state: "on"
action:
- service: light.turn_on
data_template:
entity_id: !input light
color_temp: !input temp
@@ -50,8 +50,6 @@ cards:
- automation.presence_player_2_leaving
- automation.presence_coming_home
- automation.presence_leaving_home
- automation.routine_coming_home_left_work
- automation.presence_leaving_work
- type: entities
title: Switches
@@ -63,7 +61,6 @@ cards:
- automation.bedroom_opple
- automation.bedroom_bedside_switch
- automation.bedroom_bedside_second_switch
- automation.guest_bedroom_aqara_switch
- automation.bathroom_switch
- type: entities
@@ -75,17 +72,8 @@ cards:
- automation.lighting_turn_off_all_lights_after_sunrise
- type: divider
- automation.lighting_temperature_adjust_on_start
- automation.lighting_temperature_sunset_living_room_main
- automation.lighting_temperature_sunset_pc
- automation.lighting_temperature_sunset_bedroom_main
- automation.lighting_temperature_sunset_kitchen_main
- automation.lighting_temperature_sunset_kitchen_secondary
- automation.lighting_temperature_night_living_room_main
- automation.lighting_temperature_night_pc
- automation.lighting_temperature_night_bedroom_main
- automation.lighting_temperature_night_kitchen_main
- automation.lighting_temperature_night_kitchen_secondary
- automation.lighting_temperature_adjust_on_start
- automation.lighting_temperature_based_on_sun
- automation.lighting_temperature_change
- type: divider
- automation.lighting_bedroom_door_open
- type: divider
@@ -96,7 +84,6 @@ cards:
- automation.lighting_hallway_motion_on
- automation.lighting_hallway_motion_off
- type: divider
- automation.lighting_sync_tasmota_states_on_start_up
- automation.lighting_sync_zigbee_states_on_start_up
- type: divider
- automation.trust_remote_guest_bedroom
@@ -110,10 +97,8 @@ cards:
icon: mdi:play-box-outline
entities:
- automation.tv_join_beam_to_sonos_group_when_off
- automation.tv_state_sync_on_tv_on
- automation.tv_state_sync_on_tv_off
- automation.tv_state_sync_on_shield_on
- automation.tv_state_sync_on_shield_off
- automation.tv_state_sync_tv_state
- automation.tv_state_sync_shield_state
- automation.tv_prepare_for_casting
- type: divider
- automation.tv_plex_setup_house_for_plex
@@ -133,21 +118,15 @@ cards:
title: Bedroom Mode
show_header_toggle: false
entities:
- automation.bedroom_mode_set_to_day
- automation.bedroom_mode_set_to_bed
- automation.bedroom_mode_set_to_night
- automation.bedroom_mode_change
- automation.guest_bedroom_mode_set_to_night
- automation.house_mode_set_to_day
- automation.house_mode_set_to_night
- automation.house_mode_change
- type: entities
title: Guest mode
show_header_toggle: false
entities:
- automation.guest_mode_enable
- automation.guest_mode_disable
- automation.guest_mode_enable_from_telegram
- automation.guest_mode_disable_from_telegram
- automation.guest_mode_change
- type: entities
title: Domestina
@@ -97,6 +97,13 @@
entity: switch.mercury_home_mode
name: Mercury
- type: custom:decluttering-card
template: v3_section_title
variables:
- title: Lighting
- type: entities
entities:
- input_number.global_light_temp
- type: custom:decluttering-card
template: v3_section_title
variables:
+1 -9
View File
@@ -229,15 +229,7 @@ automation:
- service: philips_airpurifier_http.set_target_humidity
entity_id: fan.philips_airpurifier
data_template:
humidity: >-
{% set state = states('input_select.purifier_target_humidity') | int %}
{% if state == 40 %}
40
{% elif state == 50 %}
50
{% else %}
60
{% endif %}
humidity: "{{ states('input_select.purifier_target_humidity') | int }}"
- alias: Purifier · Sync humidity
trigger:
+45 -51
View File
@@ -87,66 +87,60 @@ automation:
message: "Sonos Group · TV off - joining Beam to Sonos Group"
domain: media_player
- alias: TV · State · Sync on TV on
- alias: TV · State · Sync TV state
trigger:
platform: state
entity_id: media_player.living_room_tv
to: "on"
action:
- service: media_player.turn_on
- choose:
- conditions: "{{ trigger.to_state == 'off' }}"
sequence:
- service: media_player.turn_off
entity_id: media_player.nvidia_shield
- service: logbook.log
data:
name: "📺 Media Module · "
message: "Sync TV state · Turning Shield off - TV is off"
domain: media_player
- conditions: "{{ trigger.to_state == 'on' }}"
sequence:
- service: media_player.turn_on
entity_id: media_player.nvidia_shield
- service: logbook.log
data_template:
name: "📺 Media Module · "
message: Sync TV state · Turning Shield on - TV is {{ trigger.to_state }}
domain: media_player
- alias: TV · State · Sync Shield state
trigger:
- platform: state
entity_id: media_player.nvidia_shield
- service: logbook.log
data:
name: "📺 Media Module · "
message: "Sync TV state · Turning Shield on - TV is on"
domain: media_player
- alias: TV · State · Sync on TV off
trigger:
platform: state
entity_id: media_player.living_room_tv
to: "off"
action:
- service: media_player.turn_off
from: "on"
id: "off"
- platform: state
entity_id: media_player.nvidia_shield
- service: logbook.log
data:
name: "📺 Media Module · "
message: "Sync TV state · Turning Shield off - TV is off"
domain: media_player
- alias: TV · State · Sync on Shield on
trigger:
platform: state
entity_id: media_player.nvidia_shield
from: "off"
from: "off"
id: "on"
action:
- service: media_player.turn_on
entity_id: media_player.living_room_tv
- delay: "00:00:15"
- service: media_player.select_source
entity_id: media_player.living_room_tv
data:
source: "Shield"
- choose:
- conditions: "{{ trigger.id == 'on' }}"
sequence:
- service: media_player.turn_on
entity_id: media_player.living_room_tv
- delay: "00:00:15"
- service: media_player.select_source
entity_id: media_player.living_room_tv
data:
source: "Shield"
- conditions: "{{ trigger.id == 'off' }}"
sequence:
- service: media_player.turn_off
entity_id: media_player.living_room_tv
- service: logbook.log
data:
data_template:
name: "📺 Media Module · "
message: "Sync TV state · Turning TV on - Shield is on"
domain: media_player
- alias: TV · State · Sync on Shield off
trigger:
platform: state
entity_id: media_player.nvidia_shield
to: "off"
condition: "{{ is_state_attr('media_player.living_room_tv', 'source', 'Shield') }}"
action:
- service: media_player.turn_off
entity_id: media_player.living_room_tv
- service: logbook.log
data:
name: "📺 Media Module · "
message: "Sync TV state · Turning TV off - Shield is off"
message: Sync TV state · Turning TV on - Shield is {{ trigger.id }}
domain: media_player
- alias: TV · Prepare for casting
+1 -3
View File
@@ -16,9 +16,7 @@ group:
- automation.music_living_room_play_pause_on_desk_switch_hold
- automation.music_master_bedroom_play_pause_on_switch_hold
- automation.notification_door_opened
- automation.bedroom_mode_set_to_night
- automation.bedroom_mode_set_to_bed
- automation.bedroom_mode_set_to_day
- automation.bedroom_mode_change
- automation.bedroom_mode_toggle_on_bedside_switch_hold
- automation.security_door_opened_while_away
- automation.purifier_turn_on_low_humidity
+18 -61
View File
@@ -7,68 +7,25 @@ input_boolean:
icon: mdi:cogs
automation:
- alias: Guest mode · Enable
- alias: Guest mode · Change
trigger:
platform: state
entity_id: input_boolean.guest_mode
from: "off"
to: "on"
action:
- service: automation.turn_off
entity_id:
- automation.presence_leaving_home
- automation.presence_coming_home
- service: input_boolean.turn_off
entity_id: input_boolean.speech_notifications
- alias: Guest mode · Disable
trigger:
platform: state
entity_id: input_boolean.guest_mode
from: "on"
to: "off"
action:
- service: automation.turn_on
entity_id:
- automation.presence_leaving_home
- automation.presence_coming_home
- service: input_boolean.turn_on
entity_id: input_boolean.speech_notifications
- alias: Guest mode · Enable · From Telegram
trigger:
platform: event
event_type: telegram_command
event_data:
command: "/guest_mode_on"
action:
- service: input_boolean.turn_on
entity_id: input_boolean.guest_mode
- service: notify.telegram
data:
title: "⚙️ *System Module · Telegram*"
message: "Okay, turning Guest mode on!"
- service: logbook.log
data:
name: "⚙️ System Module · "
message: "Telegram · Turning Guest mode on"
domain: input_boolean
- alias: Guest mode · Disable · From Telegram
trigger:
platform: event
event_type: telegram_command
event_data:
command: "/guest_mode_off"
action:
- service: input_boolean.turn_off
entity_id: input_boolean.guest_mode
- service: notify.telegram
data:
title: "⚙️ *System Module · Telegram*"
message: "Okay, turning Guest mode off!"
- service: logbook.log
data:
name: "⚙️ System Module · "
message: "Telegram · Turning Guest mode off"
domain: input_boolean
choose:
- conditions: "{{ trigger.to_state == 'on' }}"
sequence:
- service: automation.turn_off
entity_id:
- automation.presence_leaving_home
- automation.presence_coming_home
- service: input_boolean.turn_off
entity_id: input_boolean.speech_notifications
- conditions: "{{ trigger.to_state == 'off' }}"
sequence:
- service: automation.turn_on
entity_id:
- automation.presence_leaving_home
- automation.presence_coming_home
- service: input_boolean.turn_on
entity_id: input_boolean.speech_notifications
+19 -30
View File
@@ -71,29 +71,21 @@ script:
option: "{{ is_state('input_select.bedroom_mode', 'day') | iif('night', 'day') }}"
automation:
- alias: Bedroom mode · Set to day
- alias: Bedroom mode · Change
trigger:
platform: state
entity_id: input_select.bedroom_mode
to: "day"
action:
- service: script.routine_bedroom_morning
- alias: Bedroom mode · Set to bed
trigger:
platform: state
entity_id: input_select.bedroom_mode
to: "bed"
action:
- service: script.routine_bedroom_bedtime
- alias: Bedroom mode · Set to night
trigger:
platform: state
entity_id: input_select.bedroom_mode
to: "night"
action:
- service: script.bedroom_good_night
- choose:
- conditions: "{{ trigger.to_state == 'day' }}"
sequence:
- service: script.routine_bedroom_morning
- conditions: "{{ trigger.to_state == 'bed' }}"
sequence:
- service: script.routine_bedroom_bedtime
- conditions: "{{ trigger.to_state == 'night' }}"
sequence:
- service: script.bedroom_good_night
- alias: Guest Bedroom mode · Set to night
trigger:
@@ -104,18 +96,15 @@ automation:
- service: light.turn_off
entity_id: light.tradfri_large
- alias: House mode · Set to day
- alias: House mode · Change
trigger:
platform: state
entity_id: sensor.house_mode
to: "day"
action:
- service: script.routine_waking_up
- alias: House mode · Set to night
trigger:
platform: state
entity_id: sensor.house_mode
to: "night"
action:
- service: script.routine_good_night
choose:
- conditions: "{{ trigger.to_state == 'day' }}"
sequence:
- service: script.routine_waking_up
- conditions: "{{ trigger.to_state == 'night' }}"
sequence:
- service: script.routine_good_night
+76 -81
View File
@@ -1,86 +1,81 @@
input_number:
global_light_temp:
name: Light temperature
min: 100
max: 500
step: 1
icon: mdi:lightbulb-night-outline
automation:
- alias: Lighting · Temperature · Adjust on start
use_blueprint:
path: light_on_set_temperature.yaml
input:
light:
- light.living_room_main
- light.pc
- light.master_bedroom_main
- light.kitchen_main
- light.kitchen_secondary
mode: parallel
trigger:
platform: state
entity_id:
- light.living_room_main
- light.pc
- light.master_bedroom_main
- light.kitchen_main
- light.kitchen_secondary
action:
- service: light.turn_on
data_template:
entity_id: "{{ trigger.entity_id }}"
color_temp: "{{ states('input_number.global_light_temp') }}"
- alias: Lighting · Temperature · Sunset · Living room main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.living_room_main
temp: 400
- alias: Lighting · Temperature · Based on sun
id: lighting_temperature_based_on_sun
trigger:
- platform: sun
event: sunrise
id: "300"
- platform: sun
event: sunset
offset: "-01:00:00"
id: "380"
- platform: sun
event: sunset
id: "400"
- platform: sun
event: sunset
offset: "+01:00:00"
id: "433"
- platform: sun
event: sunset
offset: "+02:00:00"
id: "466"
- platform: sun
event: sunset
offset: "+03:00:00"
id: "500"
- alias: Lighting · Temperature · Sunset · PC
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.pc
temp: 400
action:
- service: input_number.set_value
entity_id: input_number.global_light_temp
data_template:
value: "{{ trigger.id | int }}"
- alias: Lighting · Temperature · Sunset · Bedroom main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.master_bedroom_main
temp: 400
- alias: Lighting · Temperature · Sunset · Kitchen main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.kitchen_main
temp: 400
- alias: Lighting · Temperature · Sunset · Kitchen secondary
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.kitchen_secondary
temp: 400
- alias: Lighting ·Temperature · Night · Living room main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.living_room_main
temp: 500
after_offset: "+03:00:00"
- alias: Lighting ·Temperature · Night · PC
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.pc
temp: 500
after_offset: "+03:00:00"
- alias: Lighting ·Temperature · Night · Bedroom main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.master_bedroom_main
temp: 500
after_offset: "+03:00:00"
- alias: Lighting ·Temperature · Night · Kitchen main
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.kitchen_main
temp: 500
after_offset: "+03:00:00"
- alias: Lighting ·Temperature · Night · Kitchen secondary
use_blueprint:
path: light_sun_set_temperature.yaml
input:
light: light.kitchen_secondary
temp: 500
after_offset: "+03:00:00"
- alias: Lighting · Temperature · Change
id: "lighting_temperature_change"
trigger:
platform: state
entity_id: input_number.global_light_temp
action:
- service: scene.apply
data_template:
entities:
light.living_room_main:
state: "{{ states('light.living_room_main') }}"
color_temp: "{{ trigger.to_state }}"
light.pc:
state: "{{ states('light.pc') }}"
color_temp: "{{ trigger.to_state }}"
light.master_bedroom_main:
state: "{{ states('light.master_bedroom_main') }}"
color_temp: "{{ trigger.to_state }}"
light.kitchen_main:
state: "{{ states('light.kitchen_main') }}"
color_temp: "{{ trigger.to_state }}"
light.kitchen_secondary:
state: "{{ states('light.kitchen_secondary') }}"
color_temp: "{{ trigger.to_state }}"
-14
View File
@@ -158,20 +158,6 @@ automation:
action:
- service: script.routine_coming_home
- alias: Presence · Leaving work
trigger:
platform: state
entity_id: person.georgi
from: "Work"
to: "not_home"
action:
- service: notify.telegram
data:
title: "🏠 *Presence Module · Leaving Work*"
message: "Hey, I see you're leaving work. Are you coming home?"
data:
inline_keyboard:
- "Yes:/leaving_work_to_home, No:/do_nothing"
#
# ─── CUSTOMIZATION ──────────────────────────────────────────────────────────────
-28
View File
@@ -108,31 +108,3 @@ script:
}}
- delay: 00:00:02
- service: script.music_play
automation:
- alias: Routine · Coming home · Left work
trigger:
platform: event
event_type: telegram_callback
event_data:
command: "/leaving_work_to_home"
action:
- service: telegram_bot.edit_replymarkup
data_template:
message_id: "last"
chat_id: "{{ trigger.event.data.chat_id }}"
inline_keyboard:
- service: notify.telegram
data_template:
title: "🏠 *Presence Module · Leaving Work*"
message: >-
{{
[
"Okay, I'll be expecting you!",
"Awesome! I'm prepping for your arrival",
"Cool, I'll be ready!"
] | random
}}
- service: script.turn_on_all_radiators
- service: script.toshiba_ac_on_cool_if_hot
@@ -3,15 +3,11 @@
{%- set getting_hot = [
" to cool down a bit.",
". It's getting hot!",
", or you're probably gonna boil!",
", or you're gonna simmer!"
] -%}
{%- set getting_cold = [
" to warm up a bit.",
". It's getting chilly!",
", or you're probably gonna freeze!",
", or you're gonna ice up!"
] -%}
{%- if (states('sensor.dark_sky_temperature') | int) < (states('sensor.bedroom_weather_temperature') | int) -%}