Tweaking location sensors and presence things.

This commit is contained in:
Jeffrey Stone 2022-02-24 23:29:25 -05:00
parent aee5b1e79b
commit 914e65f0df
1 changed files with 259 additions and 257 deletions

View File

@ -20,6 +20,7 @@ input_datetime:
has_time: true has_time: true
# Testing Proximity Sensors # Testing Proximity Sensors
proximity: proximity:
home_jeff: home_jeff:
@ -46,64 +47,64 @@ sensor:
- platform: template - platform: template
sensors: sensors:
jeff_location: jeff_location:
friendly_name: "Jeff's Current Location" friendly_name: "Jeff"
unit_of_measurement: '' unit_of_measurement: ""
value_template: >- value_template: >-
{% set person = states.person.jeffrey.state %} {% set person = states.person.jeffrey.state %}
{%- if person in ['Sprouts','Kroger1','Kroger2'] %} {%- if person in ['Sprouts','Kroger1','Kroger2'] %}
Grocery Store Grocery Store
{% elif person in ['HomeDepot','Lowes'] %} {% elif person in ['HomeDepot','Lowes'] %}
Home Improvement Store Home Improvement Store
{% elif person in ['Walmart','Target'] %} {% elif person in ['Walmart','Target'] %}
Super Store Super Store
{% else %}
{% if person in ['not_home'] %}
{{ state_attr('device_tracker.life360_jeffrey_stone','address') }}
{% else %} {% else %}
{% if person in ['not_home'] %} {{ states('person.jeffrey') }}
{{ states.device_tracker.life360_jeffrey_stone.attributes.address }}
{% else %}
{{ states.person.jeffrey.state }}
{%- endif %}
{%- endif %} {%- endif %}
{%- endif %}
- platform: template - platform: template
sensors: sensors:
skylar_location: skylar_location:
friendly_name: "Skylar's Current Location" friendly_name: "Skylar"
unit_of_measurement: '' unit_of_measurement: ""
value_template: >- value_template: >-
{% if is_state('input_boolean.skylar_school', 'on') %} {% if is_state('input_boolean.skylar_school', 'on') %}
school school
{% elif is_state('calendar.skylar_events', 'on') %} {% elif is_state('calendar.skylar_events', 'on') %}
{{ states.calendar.skylar_events.attributes.message }} {{ state_attr('calendar.skylar_events', 'message') }}
{%- elif is_state('person.jeffrey', 'home') and is_state('person.katherine', 'home') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('person.jeffrey', 'home') and is_state('person.katherine', 'home') and is_state('input_boolean.skylar_school', 'off')%}
home home
{%- elif is_state('person.jeffrey', 'Summit') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('person.jeffrey', 'Summit') and is_state('input_boolean.skylar_school', 'off')%}
{{ states.sensor.kat_location.state }} {{ states('sensor.kat_location') }}
{%- elif is_state('person.katherine', 'ZooAtlanta') and is_state('input_boolean.skylar_school', 'off')%} {%- elif is_state('person.katherine', 'ZooAtlanta') and is_state('input_boolean.skylar_school', 'off')%}
{{ states.person.jeffrey.state }} {{ states('person.jeffrey') }}
{% else %} {% else %}
{{ states.person.skylar.state }} Unknown
{%- endif %} {%- endif %}
- platform: template - platform: template
sensors: sensors:
kat_location: kat_location:
friendly_name: "Kat's Current Location" friendly_name: "Kat"
unit_of_measurement: '' unit_of_measurement: ""
value_template: >- value_template: >-
{% set person = states.person.katherine.state %} {% set person = states('person.katherine') %}
{%- if person in ['Sprouts','Kroger1','Kroger2'] %} {%- if person in ['Sprouts','Kroger1','Kroger2'] %}
Grocery Store Grocery Store
{% elif person in ['HomeDepot','Lowes'] %} {% elif person in ['HomeDepot','Lowes'] %}
Home Improvement Store Home Improvement Store
{% elif person in ['Walmart','Target'] %} {% elif person in ['Walmart','Target'] %}
Super Store Super Store
{% else %}
{%- if person in ['ZooAtlanta'] %}
Zoo Atlanta
{% elif person in ['not_home'] %}
{{ state_attr('device_tracker.life360_kat_stone', 'address') }}
{% else %} {% else %}
{%- if person in ['ZooAtlanta'] %} {{ states('person.katherine') }}
Zoo Atlanta
{% elif person in ['not_home'] %}
{{ states.device_tracker.life360_kat_stone.attributes.address }}
{% else %}
{{ states.person.katherine.state }}
{%- endif %}
{%- endif %} {%- endif %}
{%- endif %}
- platform: mqtt - platform: mqtt
name: "Family Status" name: "Family Status"
state_topic: "house/family/status" state_topic: "house/family/status"
@ -134,19 +135,19 @@ automation:
trigger: trigger:
- platform: state - platform: state
entity_id: binary_sensor.skylar_bedroom_motion_occupancy entity_id: binary_sensor.skylar_bedroom_motion_occupancy
to: 'on' to: "on"
from: 'off' from: "off"
- platform: state - platform: state
entity_id: binary_sensor.skylar_room_occupancy entity_id: binary_sensor.skylar_room_occupancy
to: 'on' to: "on"
from: 'off' from: "off"
condition: condition:
- condition: time - condition: time
after: '05:00:00' after: "05:00:00"
before: '08:30:00' before: "08:30:00"
- condition: state - condition: state
entity_id: input_boolean.skylar_awake entity_id: input_boolean.skylar_awake
state: 'off' state: "off"
action: action:
- service: input_datetime.set_datetime - service: input_datetime.set_datetime
entity_id: input_datetime.skylar_awake_at entity_id: input_datetime.skylar_awake_at
@ -154,6 +155,8 @@ automation:
time: "{{ now().strftime('%H:%M') }}" time: "{{ now().strftime('%H:%M') }}"
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.skylar_awake entity_id: input_boolean.skylar_awake
- service: switch.turn_off
entity_id: switch.rainbow_light
- id: skylar_early_morning_tv - id: skylar_early_morning_tv
alias: Skylar Early Morning TV alias: Skylar Early Morning TV
@ -161,18 +164,21 @@ automation:
trigger: trigger:
- platform: state - platform: state
entity_id: media_player.theater_tv entity_id: media_player.theater_tv
to: 'off' to: "on"
from: 'on' from: "off"
- platform: state - platform: state
entity_id: media_player.croft_tv entity_id: media_player.croft_tv
to: 'playing' to: "playing"
condition: condition:
- condition: time - condition: time
after: '05:00:00' after: "05:00:00"
before: '08:30:00' before: "08:30:00"
- condition: state - condition: state
entity_id: input_boolean.skylar_dressed_reminder entity_id: input_boolean.skylar_dressed_reminder
state: 'off' state: "off"
- condition: state
entity_id: input_boolean.skylar_awake
state: "on"
action: action:
- service: script.status_annc - service: script.status_annc
data: data:
@ -191,51 +197,50 @@ automation:
alias: Kat Arrives at Zoo alias: Kat Arrives at Zoo
initial_state: true initial_state: true
trigger: trigger:
- platform: zone - platform: zone
event: enter event: enter
zone: zone.zoo_atlanta zone: zone.zoo_atlanta
entity_id: person.katherine entity_id: person.katherine
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.kat_travel_monitor entity_id: input_boolean.kat_travel_monitor
- service: script.status_annc - service: script.status_annc
data: data:
who: '{{ states.sensor.room_presence.state }}' who: "{{ states('sensor.room_audio') }}"
speech_message: 'Kat has arrived at work.' speech_message: "Kat has arrived at work."
- id: kat_leaves_zoo - id: kat_leaves_zoo
alias: Kat Leaves Zoo Notification alias: Kat Leaves Zoo Notification
initial_state: true initial_state: true
trigger: trigger:
- platform: zone - platform: zone
event: leave event: leave
zone: zone.zoo_atlanta zone: zone.zoo_atlanta
entity_id: person.katherine entity_id: person.katherine
action: action:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.kat_travel_monitor entity_id: input_boolean.kat_travel_monitor
- service: script.status_annc - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_presence.state }}' who: "{{ states('sensor.room_audio') }}"
call_interpruption: 1 call_interpruption: 1
call_kat_location: 1 call_kat_location: 1
- id: skylar_at_school - id: skylar_at_school
alias: Skylar is at School alias: Skylar is at School
trigger: trigger:
- entity_id: person.jeffrey - entity_id: person.jeffrey
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: person.katherine - entity_id: person.katherine
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: person.skylar - entity_id: person.skylar
event: enter event: enter
platform: zone platform: zone
zone: zone.starling zone: zone.starling
condition: condition:
- condition: time - condition: time
before: "13:30:00" before: "13:30:00"
@ -247,31 +252,31 @@ automation:
- fri - fri
- condition: state - condition: state
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
state: 'off' state: "off"
action: action:
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
- service: script.text_alert - service: script.text_alert
data: data:
who: parents who: parents
message: "Skylar has been dropped off at school." message: "Skylar has been dropped off at school."
initial_state: true initial_state: true
- id: skylar_left_school - id: skylar_left_school
alias: Skylar left School alias: Skylar left School
trigger: trigger:
- entity_id: person.jeffrey - entity_id: person.jeffrey
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: person.katherine - entity_id: person.katherine
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
- entity_id: person.skylar - entity_id: person.skylar
event: leave event: leave
platform: zone platform: zone
zone: zone.starling zone: zone.starling
condition: condition:
- condition: time - condition: time
after: "11:30:00" after: "11:30:00"
@ -283,54 +288,54 @@ automation:
- fri - fri
- condition: state - condition: state
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
state: 'on' state: "on"
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.skylar_school entity_id: input_boolean.skylar_school
- service: script.text_alert - service: script.text_alert
data: data:
who: parents who: parents
message: "Skylar has been picked up from school." message: "Skylar has been picked up from school."
initial_state: true initial_state: true
- id: jeff_arrives_summit - id: jeff_arrives_summit
alias: Jeff Arrives At Summit alias: Jeff Arrives At Summit
trigger: trigger:
- entity_id: person.jeffrey - entity_id: person.jeffrey
event: enter event: enter
platform: zone platform: zone
zone: zone.summit zone: zone.summit
action: action:
- service: script.text_notify - service: script.text_notify
data: data:
who: "kat" who: "kat"
message: "Jeff has arrived at Summit" message: "Jeff has arrived at Summit"
- service: script.jeff_destination_na
initial_state: true initial_state: true
- id: jeff_arrives_summit_notification - id: e1cb15b0-0423-11eb-adc1-0242ac120002
alias: Notify Kat Jeff At Summit alias: Zone Debugger
trigger: trigger:
- entity_id: person.jeffrey - platform: state
event: enter entity_id: person.jeffrey
platform: zone condition:
zone: zone.summit - condition: state
entity_id: input_boolean.jeff_location_debug
state: 'on'
action: action:
- service: script.jeff_destination_na - service: script.jeff_location_debug
initial_state: true
- id: jeff_leaves_summit - id: jeff_leaves_summit
alias: Jeff Leaves Summit alias: Jeff Leaves Summit
initial_state: true initial_state: true
trigger: trigger:
- entity_id: person.jeffrey - entity_id: person.jeffrey
event: leave event: leave
platform: zone platform: zone
zone: zone.summit zone: zone.summit
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.jeff_traffic_alert_home entity_id: input_boolean.jeff_traffic_alert_home
- id: welcome_home - id: welcome_home
alias: Welcome Home alias: Welcome Home
@ -343,133 +348,120 @@ automation:
- person.uncle_matt - person.uncle_matt
- person.papa - person.papa
- person.skylar - person.skylar
from: 'not_home' from: "not_home"
to: 'home' to: "home"
action: action:
- choose: - choose:
- conditions: - conditions:
- condition: state - condition: state
entity_id: input_boolean.welcome_home entity_id: input_boolean.welcome_home
state: "on" state: "on"
sequence: sequence:
- service: script.turn_on - service: script.turn_on
entity_id: script.welcome_briefing entity_id: script.welcome_briefing
default: default:
- service: group.set - service: group.set
data: data:
object_id: "arriving" object_id: "arriving"
add_entities: >- add_entities: >-
{{ trigger.to_state.entity_id }} {{ trigger.to_state.entity_id }}
- wait_template: "{{ is_state('binary_sensor.laundry_room_door', 'on') }}" - wait_template: "{{ is_state('binary_sensor.laundry_room_door', 'on') }}"
timeout: '00:3:00' timeout: "00:3:00"
- service: script.status_annc - service: script.status_annc
data_template: data_template:
who: '{{ states.sensor.room_presence.state }}' who: "{{ states.sensor.room_presence.state }}"
call_interuption: 1 call_interuption: 1
speech_message: > speech_message: >
{% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %} {% set person = expand('group.arriving')|map(attribute='name')|join(' and ') %}
{% set peoplecount = expand('group.arriving') | count %} {% set peoplecount = expand('group.arriving') | count %}
{% if peoplecount == 1 %} {% if peoplecount == 1 %}
{% set is_are = ' is ' %} {% set is_are = ' is ' %}
{% set has_have = ' has ' %} {% set has_have = ' has ' %}
{% else %} {% else %}
{% set is_are = ' are ' %} {% set is_are = ' are ' %}
{% set has_have = ' have ' %} {% set has_have = ' have ' %}
{% endif %} {% endif %}
{%- macro greeting_sentence(person, is_are, has_have) -%} {%- macro greeting_sentence(person, is_are, has_have) -%}
{{ [ {{ [
person ~ has_have + " arrived.", person ~ has_have + " arrived.",
"My sensors are picking up the presence of additional humans. " ~ person ~ has_have + " been identified as home.", "My sensors are picking up the presence of additional humans. " ~ person ~ has_have + " been identified as home.",
"Guess who is home?" ~ person ~ is_are, "Guess who is home?" ~ person ~ is_are,
"I am sensing a disturbance in the force. " ~ person +" must be home!", "I am sensing a disturbance in the force. " ~ person +" must be home!",
person ~ is_are + "now in the house.", person ~ is_are + "now in the house.",
person ~ is_are + " now here. Hash tag Welcome Home.", person ~ is_are + " now here. Hash tag Welcome Home.",
person ~ is_are + " now here. Hash tag Home.", person ~ is_are + " now here. Hash tag Home.",
"I know a secret! " ~ person ~ is_are +" home!", "I know a secret! " ~ person ~ is_are +" home!",
"Just a quick announcement. " ~ person ~ has_have +" arrived!", "Just a quick announcement. " ~ person ~ has_have +" arrived!",
"Hey" ~ person + "! High Five! Glad you are finally home.", "Hey" ~ person + "! High Five! Glad you are finally home.",
"Just a quick announcement. " ~ person ~ has_have + " arrived!", "Just a quick announcement. " ~ person ~ has_have + " arrived!",
person ~ has_have + " finally made it home." person ~ has_have + " finally made it home."
] | random }} ] | random }}
{%- endmacro -%} {%- endmacro -%}
{{greeting_sentence(person, is_are, has_have)}} {{greeting_sentence(person, is_are, has_have)}}
- delay: 00:02:00 - delay: 00:02:00
- service: group.set - service: group.set
data: data:
object_id: "arriving" object_id: "arriving"
entities: [] entities: []
- id: guests_have_arrived - id: guests_have_arrived
alias: Guests have arrived alias: Guests have arrived
trigger: trigger:
- entity_id: person.papa - entity_id: person.papa
event: enter event: enter
platform: zone platform: zone
zone: zone.home zone: zone.home
- entity_id: person.uncle_matt - entity_id: person.uncle_matt
event: enter event: enter
platform: zone platform: zone
zone: zone.home zone: zone.home
action: action:
- service: script.standby - service: script.standby
- service: script.family_is_home - service: script.family_is_home
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.guest_mode entity_id: input_boolean.guest_mode
initial_state: true initial_state: true
- id: disable_bad_traffic_home_jeff - id: disable_bad_traffic_home_jeff
alias: Disabling Jeff Bad Traffic Home alias: Disabling Jeff Bad Traffic Home
initial_state: true initial_state: true
trigger: trigger:
- platform: numeric_state - platform: numeric_state
entity_id: sensor.jeff_ett_home entity_id: sensor.jeff_ett_home
below: 40 below: 40
- platform: state - platform: state
entity_id: sensor.jeff_destination entity_id: sensor.jeff_destination
to: Home to: Home
condition: condition:
- condition: state - condition: state
entity_id: input_boolean.jeff_traffic_alert_home entity_id: input_boolean.jeff_traffic_alert_home
state: 'on' state: "on"
action: action:
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.jeff_traffic_alert_home entity_id: input_boolean.jeff_traffic_alert_home
script: script:
family_is_home: family_is_home:
sequence: sequence:
- condition: state - condition: state
entity_id: sensor.family_status entity_id: group.family
state: Away state: "home"
- service: script.standby - service: script.standby
- service: mqtt.publish
data:
topic: house/family/status
payload_template: Home
retain: true
- service: script.turn_on
entity_id: script.welcome_briefing
family_is_away: family_is_away:
sequence: sequence:
- condition: state - condition: state
entity_id: sensor.family_status entity_id: group.family
state: Home state: "not_home"
- service: script.appliances_off - service: script.appliances_off
- service: scene.turn_on - service: scene.turn_on
entity_id: scene.lights_out entity_id: scene.lights_out
- service: input_boolean.turn_on - service: input_boolean.turn_on
entity_id: input_boolean.sentry_mode entity_id: input_boolean.sentry_mode
- service: scene.turn_on - service: scene.turn_on
entity_id: scene.all_fans_off entity_id: scene.all_fans_off
- service: mqtt.publish - service: input_boolean.turn_on
data: entity_id: input_boolean.welcome_home
topic: house/family/status
payload_template: Away
retain: true
- service: input_boolean.turn_on
entity_id: input_boolean.welcome_home
reset_skylar_sensors: reset_skylar_sensors:
sequence: sequence:
@ -480,3 +472,13 @@ script:
time: "00:00:00" time: "00:00:00"
- service: input_boolean.turn_off - service: input_boolean.turn_off
entity_id: input_boolean.skylar_awake entity_id: input_boolean.skylar_awake
jeff_location_debug:
sequence:
- condition: state
entity_id: input_boolean.jeff_location_debug
state: 'on'
- service: script.text_alert
data:
who: jeff
message: "Jeff is at {{ states('person.jeffrey') }}"