mirror of
https://github.com/GeorgeSG/sarah.git
synced 2026-06-09 23:02:59 +00:00
Rename functions to modules. Update README
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
# https://www.home-assistant.io/integrations/light
|
||||
# https://www.home-assistant.io/integrations/light.group/
|
||||
light:
|
||||
- platform: group
|
||||
name: Living room main lights
|
||||
entities:
|
||||
- light.living_room_1
|
||||
- light.living_room_2
|
||||
- light.living_room_3
|
||||
- light.living_room_4
|
||||
|
||||
- platform: group
|
||||
name: Living room all lights
|
||||
entities:
|
||||
- light.living_room_main_lights
|
||||
- light.pc
|
||||
|
||||
- platform: group
|
||||
name: All lights
|
||||
entities:
|
||||
- light.living_room_all_lights
|
||||
- light.bedside_light
|
||||
|
||||
homeassistant:
|
||||
customize:
|
||||
light.living_room_1:
|
||||
friendly_name: Living room 1
|
||||
|
||||
light.living_room_2:
|
||||
friendly_name: Living room 2
|
||||
|
||||
light.living_room_3:
|
||||
friendly_name: Living room 3
|
||||
|
||||
light.living_room_4:
|
||||
friendly_name: Living room 4
|
||||
@@ -0,0 +1,16 @@
|
||||
script:
|
||||
music_play:
|
||||
alias: "Music - Play"
|
||||
sequence:
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.master_bedroom
|
||||
data_template:
|
||||
volume_level: "{{ volume | default(0.3) }}"
|
||||
- service: media_player.shuffle_set
|
||||
entity_id: media_player.master_bedroom
|
||||
data_template:
|
||||
shuffle: "{{ shuffle | default(true) }}"
|
||||
- service: media_player.select_source
|
||||
entity_id: media_player.master_bedroom
|
||||
data_template:
|
||||
source: "{{ playlist | default('Evening Chill') }}"
|
||||
@@ -0,0 +1,124 @@
|
||||
#
|
||||
# ─── CONFIGURATION ──────────────────────────────────────────────────────────────
|
||||
#
|
||||
|
||||
# https://www.home-assistant.io/components/person
|
||||
person:
|
||||
- name: Georgi
|
||||
id: !secret georgi_user_id
|
||||
user_id: !secret georgi_user_id
|
||||
device_trackers:
|
||||
- device_tracker.carbon
|
||||
|
||||
# https://www.home-assistant.io/integrations/device_tracker
|
||||
device_tracker:
|
||||
- platform: tile
|
||||
username: !secret tile_username
|
||||
password: !secret tile_password
|
||||
|
||||
# https://www.home-assistant.io/components/zone
|
||||
zone:
|
||||
- name: Home
|
||||
latitude: !secret home_latitude
|
||||
longitude: !secret home_longitude
|
||||
radius: 20
|
||||
icon: mdi:home
|
||||
|
||||
- name: Work
|
||||
latitude: !secret work_latitude
|
||||
longitude: !secret work_longitude
|
||||
radius: 60
|
||||
icon: mdi:worker
|
||||
|
||||
#
|
||||
# ─── ENTITIES ───────────────────────────────────────────────────────────────────
|
||||
#
|
||||
|
||||
input_boolean:
|
||||
georgi_home:
|
||||
name: Georgi home
|
||||
icon: mdi:account
|
||||
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
georgi_home:
|
||||
friendly_name: Georgi
|
||||
device_class: presence
|
||||
value_template: "{{ is_state('input_boolean.georgi_home', 'on') }}"
|
||||
entity_id: input_boolean.georgi_home
|
||||
icon_template: >
|
||||
{% if is_state('input_boolean.georgi_home', 'on') %} mdi:account
|
||||
{% else %} mdi:account-off-outline
|
||||
{% endif %}
|
||||
|
||||
automation:
|
||||
# When my state changes to "home", wait for 15 minutes for the door to be opened, and then mark me as home
|
||||
- id: presence_arrival_detecion
|
||||
alias: Presence - Arrival detection
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: person.georgi
|
||||
to: "home"
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: input_boolean.georgi_home
|
||||
state: "off"
|
||||
action:
|
||||
- service: script.telegram_say
|
||||
data:
|
||||
title: "*Presence - Arrival detection*"
|
||||
message: "🏠 Device marked as home. Waiting for door to open!"
|
||||
- wait_template: "{{ is_state('binary_sensor.front_door_on_off', 'on') }}"
|
||||
continue_on_timeout: false
|
||||
timeout: 00:15:00
|
||||
- service: input_boolean.turn_on
|
||||
entity_id: input_boolean.georgi_home
|
||||
- service: script.telegram_say
|
||||
data:
|
||||
title: "*Presence - Arrival detection*"
|
||||
message: "✅ Hey, I've marked you as home now!"
|
||||
|
||||
- id: leaving_home
|
||||
alias: Presence - Leaving home
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: person.georgi
|
||||
to: "not_home"
|
||||
action:
|
||||
- service: script.routine_leaving_home
|
||||
|
||||
- id: coming_home
|
||||
alias: Presence - Coming home
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: person.georgi
|
||||
to: "home"
|
||||
action:
|
||||
- service: script.routine_coming_home
|
||||
|
||||
#
|
||||
# ─── CUSTOMIZATION ──────────────────────────────────────────────────────────────
|
||||
#
|
||||
|
||||
homeassistant:
|
||||
customize:
|
||||
device_tracker.carbon:
|
||||
icon: mdi:cellphone-iphone
|
||||
|
||||
device_tracker.tile_p_6e3c33752f24f417254c039040a984bd:
|
||||
friendly_name: "Georgi's iPhone Tile"
|
||||
icon: mdi:cellphone-iphone
|
||||
|
||||
device_tracker.tile_1bcb2b3021b9f96b:
|
||||
friendly_name: "Keys Tile"
|
||||
icon: mdi:key-variant
|
||||
|
||||
automation.coming_home:
|
||||
icon: mdi:home-account
|
||||
|
||||
automation.leaving_home:
|
||||
icon: mdi:home
|
||||
|
||||
automation.presence_arrival_detecion:
|
||||
icon: mdi:account-plus-outline
|
||||
@@ -0,0 +1,94 @@
|
||||
binary_sensor:
|
||||
- platform: template
|
||||
sensors:
|
||||
camera_state:
|
||||
friendly_name: Security camera
|
||||
device_class: safety
|
||||
value_template: >-
|
||||
{{ state_attr('camera.amcrest_camera', 'motion_recording') != 'on' }}
|
||||
|
||||
switch:
|
||||
- platform: template
|
||||
switches:
|
||||
camera:
|
||||
friendly_name: Security camera
|
||||
value_template: "{{ state_attr('camera.amcrest_camera', 'motion_recording') == 'on' }}"
|
||||
icon_template: >
|
||||
{% if state_attr('camera.amcrest_camera', 'motion_recording') == 'on' %} mdi:shield-home
|
||||
{% else %} mdi:shield-off
|
||||
{% endif %}
|
||||
turn_on:
|
||||
service: script.security_camera_on
|
||||
turn_off:
|
||||
service: script.security_camera_off
|
||||
|
||||
script:
|
||||
security_camera_on:
|
||||
alias: Security camera - Turn on
|
||||
sequence:
|
||||
- service: camera.turn_on
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: amcrest.goto_preset
|
||||
entity_id: camera.amcrest_camera
|
||||
data:
|
||||
preset: 1
|
||||
- service: amcrest.enable_motion_recording
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: amcrest.enable_recording
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: amcrest.enable_audio
|
||||
entity_id: camera.amcrest_camera
|
||||
|
||||
security_camera_off:
|
||||
alias: Security camera - Turn off
|
||||
sequence:
|
||||
- service: amcrest.goto_preset
|
||||
entity_id: camera.amcrest_camera
|
||||
data:
|
||||
preset: 3
|
||||
- service: amcrest.disable_motion_recording
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: amcrest.disable_recording
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: amcrest.disable_audio
|
||||
entity_id: camera.amcrest_camera
|
||||
- service: camera.turn_off
|
||||
entity_id: camera.amcrest_camera
|
||||
|
||||
alarm_start:
|
||||
sequence:
|
||||
- service: media_player.play_media
|
||||
data:
|
||||
entity_id: media_player.master_bedroom
|
||||
media_content_id: "https://raw.githubusercontent.com/saeedsohi/siren/master/FireTrucksSirens.mp3"
|
||||
media_content_type: music
|
||||
- service: light.turn_on
|
||||
entity_id: light.bedside_light
|
||||
data:
|
||||
brightness_pct: 100
|
||||
- service: light.turn_on
|
||||
entity_id: light.bedside_light
|
||||
data:
|
||||
effect: Police
|
||||
|
||||
alarm_stop:
|
||||
sequence:
|
||||
- service: media_player.media_stop
|
||||
entity_id: media_player.master_bedroom
|
||||
- service: light.turn_on
|
||||
entity_id: light.bedside_light
|
||||
data:
|
||||
brightness_pct: 60
|
||||
kelvin: 2400
|
||||
|
||||
# Hack - the switch.camera initial state is wrong (ON) when the server starts.
|
||||
automation:
|
||||
- id: camera_turn_off_on_startup
|
||||
alias: Camera - Startup
|
||||
trigger:
|
||||
- platform: homeassistant
|
||||
event: start
|
||||
action:
|
||||
- delay: 00:00:10
|
||||
- service: switch.turn_off
|
||||
entity_id: switch.camera
|
||||
@@ -0,0 +1,98 @@
|
||||
input_boolean:
|
||||
speech_notifications:
|
||||
name: Speech notifications
|
||||
icon: mdi:chat
|
||||
|
||||
sarah_talking:
|
||||
name: SARAH talking
|
||||
icon: mdi:chat
|
||||
initial: off
|
||||
|
||||
script:
|
||||
say:
|
||||
alias: Speech - Say
|
||||
sequence:
|
||||
# Don't talk while in sleep mode.
|
||||
- condition: state
|
||||
entity_id: input_boolean.sleep_mode
|
||||
state: "off"
|
||||
# Combine partials for speech message.
|
||||
- service: script.say_discretely
|
||||
data_template:
|
||||
message: >-
|
||||
{%- if partials is defined -%}
|
||||
{%- for partial in partials -%}
|
||||
{{ partial }}{{ " " }}
|
||||
{%- endfor -%}
|
||||
{%- else -%}
|
||||
{{ message }}
|
||||
{%- endif -%}
|
||||
|
||||
say_discretely:
|
||||
alias: Speech - Say discretely
|
||||
sequence:
|
||||
# Figure out whether to talk or send a text.
|
||||
- service_template: >
|
||||
{% if is_state('media_player.master_bedroom', 'playing')
|
||||
or is_state('input_boolean.speech_notifications', 'off')
|
||||
or is_state('input_boolean.georgi_home', 'off') %}
|
||||
script.telegram_say
|
||||
{% else %}
|
||||
script.sonos_blast
|
||||
{% endif %}
|
||||
data_template:
|
||||
title: "💬 *Speech Module*" # For telegram only
|
||||
message: "{{ message }}"
|
||||
|
||||
telegram_say:
|
||||
alias: Speech - Telegram say
|
||||
sequence:
|
||||
- service: notify.telegram
|
||||
data_template:
|
||||
title: "{{ title }}"
|
||||
message: "{{ message }}"
|
||||
|
||||
sonos_blast:
|
||||
alias: Speech - Sonos blast
|
||||
sequence:
|
||||
# Mark SARAH as talking.
|
||||
- service: input_boolean.turn_on
|
||||
entity_id: input_boolean.sarah_talking
|
||||
# Don't shout :)
|
||||
- service: media_player.volume_set
|
||||
entity_id: media_player.master_bedroom
|
||||
data_template:
|
||||
volume_level: >-
|
||||
{% if now().strftime('%H')|int < 6 and now().strftime('%H')|int > 1 %}
|
||||
0.2
|
||||
{% else %}
|
||||
0.5
|
||||
{% endif %}
|
||||
# Say message.
|
||||
- service: tts.amazon_polly_say
|
||||
data_template:
|
||||
entity_id: media_player.master_bedroom
|
||||
message: "{{ message }}"
|
||||
# Wait for phrase to be over and mark as not talking.
|
||||
- delay: 00:00:01
|
||||
- wait_template: "{{ is_state('media_player.master_bedroom', 'paused') }}"
|
||||
timeout: 00:02:00
|
||||
- service: input_boolean.turn_off
|
||||
entity_id: input_boolean.sarah_talking
|
||||
|
||||
sonos_say:
|
||||
alias: Speech - Sonos say
|
||||
sequence:
|
||||
- service: sonos.snapshot
|
||||
data_template:
|
||||
with_group: yes
|
||||
entity_id: media_player.master_bedroom
|
||||
- delay: 00:00:02
|
||||
- service: script.sonos_blast
|
||||
data_template:
|
||||
message: "{{ message }}"
|
||||
- delay: 00:00:05
|
||||
- service: sonos.restore
|
||||
data_template:
|
||||
with_group: yes
|
||||
entity_id: media_player.master_bedroom
|
||||
@@ -0,0 +1,17 @@
|
||||
script:
|
||||
sarah_restart:
|
||||
alias: System - Restart SARAH
|
||||
sequence:
|
||||
service: homeassistant.restart
|
||||
|
||||
automation:
|
||||
- id: system_announce_start
|
||||
alias: System - Announce start
|
||||
trigger:
|
||||
platform: homeassistant
|
||||
event: start
|
||||
action:
|
||||
- delay: 00:00:06
|
||||
- service: script.say
|
||||
data:
|
||||
message: "Hey! I was out for a bit, but I'm back online!"
|
||||
Reference in New Issue
Block a user