Skip to content

Commit

Permalink
Update to 2024.10.0
Browse files Browse the repository at this point in the history
- add array_to_clist custom template
- depracate list_people custom template
- replace clist_locks with list_locks custom template
- update plural_word custom template
- update affected automations
- reafactor waste day notifications
- remove unecessary system_log.write calls
- reafactor camera object detection
- update frigate camera naming (remove '_frigate')
- remove frigate improve_contrast entities
  • Loading branch information
jazzyisj committed Sep 27, 2024
1 parent 826bdc6 commit c3c6304
Show file tree
Hide file tree
Showing 84 changed files with 904 additions and 905 deletions.
2 changes: 1 addition & 1 deletion .HA_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2024.10.0b0
2024.10.0b1
2 changes: 1 addition & 1 deletion automations/alarm/alarm_doorbell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

- action: camera.snapshot
target:
entity_id: camera.front_door_frigate
entity_id: camera.front_door
data:
filename: "/config/www/{{ file }}"

Expand Down
12 changes: 6 additions & 6 deletions automations/alarm/alarm_open_sensor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@
alert: true
save_message: false
message: |
{%- set entities = expand(state_attr('alarm_control_panel.master', 'open_sensors')) -%}
{%- set names = entities | map(attribute='name') | join(', ') | replace(' Open Alert', '') -%}
{%- set clist = ', and ' if names.split(', ') | count > 2 else ' and ' -%}
{%- set qty = entities | count -%}
{%- set plural = 'are' if qty > 1 else 'is' -%}
{%- from 'speech.jinja' import array_to_clist %}
{%- from 'speech.jinja' import plural_word %}
{%- set entities = expand(state_attr('alarm_control_panel.master', 'open_sensors'))
| map(attribute='name') | list %}
{%- set sensors = array_to_clist(entities, true) | replace(' Open Alert', '') %}
Attention! The house alarm could not be armed!
The {{ clist.join(names.rsplit(', ', 1)) }} {{ plural }} open!
The {{ sensors }}{{ plural_word('', entities|count, true) }} open!
continue_on_error: true

- if:
Expand Down
15 changes: 8 additions & 7 deletions automations/alarm/alarm_triggered_notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,28 +152,28 @@

- action: camera.snapshot
target:
entity_id: "camera.{{ cam1 }}_frigate"
entity_id: "camera.{{ cam1 }}"
data:
filename: "/config/www/{{ file1 }}"
continue_on_error: true

- action: camera.snapshot
target:
entity_id: "camera.{{ cam2 }}_frigate"
entity_id: "camera.{{ cam2 }}"
data:
filename: "/config/www/{{ file2 }}"
continue_on_error: true

- action: camera.snapshot
target:
entity_id: "camera.{{ cam3 }}_frigate"
entity_id: "camera.{{ cam3 }}"
data:
filename: "/config/www/{{ file3 }}"
continue_on_error: true

- action: camera.snapshot
target:
entity_id: "camera.{{ cam4 }}_frigate"
entity_id: "camera.{{ cam4 }}"
data:
filename: "/config/www/{{ file4 }}"
continue_on_error: true
Expand Down Expand Up @@ -232,9 +232,10 @@
data:
title: "House Alarm Triggered!"
message: |
{%- from 'presence.jinja' import list_people -%}
{%- from 'speech.jinja' import clist_suffix %}
{%- set home = state_attr('binary_sensor.someone_home', 'home') %}
The house alarm was triggered by the {{ states('input_text.current_alarm') }} at {{ now().strftime('%-I:%M %p') }}.
{{ list_people(state_attr('binary_sensor.someone_home', 'home'), true) }} home.
{{ clist_suffix(home, true, true, '') }} home.
data:
images:
- "/config/www/{{ file1 }}"
Expand Down Expand Up @@ -310,7 +311,7 @@

- action: camera.snapshot
target:
entity_id: "camera.{{ cam1 }}_frigate"
entity_id: "camera.{{ cam1 }}"
data:
filename: "/config/www/{{ file1 }}"
continue_on_error: true
Expand Down
12 changes: 3 additions & 9 deletions automations/camera/camera_indoor_camera_control.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
description: "Turn indoor cameras on and off."
mode: restart
variables:
entities: >
entities: > #VERIFY
{{ expand('group.wyze_cameras')
| select('in', expand('group.indoor_cameras'))
| map(attribute='object_id') | list
| map('regex_replace', find='(.*)_frigate',
| map(attribute='entity_id') | list
| map('regex_replace', find='camera.(.*)',
replace='switch.\\1_camera_power', ignorecase=False) | list }}
triggers:
- platform: homeassistant
Expand Down Expand Up @@ -41,12 +41,6 @@
actions:
- if: "{{ entities == none or entities | count == 0 }}"
then:
- action: system_log.write
data:
logger: "{{ this.entity_id }}"
level: info
message: "Stop: No valid entities."

- stop: "No valid entities."
else:
- if: "{{ is_state('binary_sensor.someone_home', 'on') }}"
Expand Down
66 changes: 41 additions & 25 deletions automations/camera/camera_object_detected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
- id: camera_object_detected
alias: "[Camera] Object Detected"
description: "Object detected notification."
mode: parallel
mode: queued
trace:
stored_traces: 30
variables:
id: "{{ trigger.payload_json['after']['id'] }}"
object: "{{ trigger.payload_json['after']['label'] }}"
camera: "{{ trigger.payload_json['after']['camera'] | replace('_frigate', '') }}"
camera: "{{ trigger.payload_json['after']['camera'] }}"
start_time: "{{ trigger.payload_json['after']['start_time'] }}"
new: "{{ trigger.payload_json['type'] == 'new' }}"
entered_zones: "{{ trigger.payload_json['after']['entered_zones'] }}"
Expand All @@ -22,8 +22,15 @@
entity_id: input_boolean.camera_object_detection
state: "on"

- condition: template
- alias: "Detected object is new"
condition: template
value_template: "{{ new }}"

- alias: "Jason hasn't just arrived home"
condition: state
entity_id: binary_sensor.jason_home
attribute: just_arrived
state: false
actions:
- parallel:
- sequence:
Expand All @@ -35,30 +42,39 @@
and (is_state('binary_sensor.camera_object_tod', 'on')
or camera in ['front_door', 'side_door']) }}
then:
- action: script.tts_play
data:
provider: "Piper" #BUG tts.piper faster but gets cut off on cast speakers
min_volume: 60
always_play: true
save_message: false
#BUGFIX add Attention!, text so actual message isn't cut off
message: |
Attention!,
{%- if camera in ['front_door', 'side_door', 'back_door', 'patio_door', 'back_house',
'side_gate_front', 'side_gate_back'] %}
There is a {{ object }} at the {{ camera | replace('_', ' ') }}!
{%- elif camera in ['side_drive', 'front_drive'] %}
There is a {{ object }} in the {{ camera | replace('_', ' ') }}way!
{%- elif camera in ['front_yard', 'back_yard'] %}
There is a {{ object }} in the {{ camera | replace('_', ' ') }}!
{%- else %}
An object was detected!
{%- endif -%}
continue_on_error: true
# don't play tts message if we just played one, unless front door
- if:
- condition: template
value_template: >
{{ true if this.attributes.last_triggered == none or camera == 'front_door'
else now() - this.attributes.last_triggered > timedelta(seconds=120) }}
then:
- action: script.turn_on
target:
entity_id: script.tts_play
data:
variables:
provider: "Piper" #BUG tts.piper faster but gets cut off on cast speakers
min_volume: 60
always_play: true
save_message: false
#BUGFIX add Attention!, text so actual message isn't cut off
message: |
Attention!,
{%- if camera in ['front_door', 'side_door', 'back_door', 'patio_door', 'back_house',
'side_gate_front', 'side_gate_back'] %} {% set prep = 'at' %}
{% elif camera in ['side_drive', 'front_drive'] %} {% set prep = 'on' %}
{%- else %} {% set prep = 'in' %}
{%- endif %}
There is a {{ object }} {{ prep }} the {{ camera | replace('_', ' ') }}!
continue_on_error: true

- action: script.kiosk_display_camera
- action: script.turn_on
target:
entity_id: script.kiosk_display_camera
data:
camera: "{{ camera }}"
variables:
camera: "{{ camera }}"
continue_on_error: true

- sequence:
Expand Down
36 changes: 18 additions & 18 deletions automations/camera/camera_object_detection_control.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
state: "{{ states('alarm_control_panel.master') | replace('armed_vacation', 'armed_away') | replace('armed_', '') }}"
on_cams: >
{{ expand('group.frigate_cameras') | selectattr('attributes.' ~ state, 'eq', true)
| rejectattr('attributes.location', 'eq', 'indoor') | map(attribute='object_id') | list }}
| rejectattr('attributes.location', 'eq', 'indoor') | map(attribute='entity_id') | list }}
off_cams: >
{{ expand('group.frigate_cameras') | rejectattr('attributes.' ~ state, 'eq', true)
| rejectattr('attributes.location', 'eq', 'indoor') | map(attribute='object_id') | list }}
| rejectattr('attributes.location', 'eq', 'indoor') | map(attribute='entity_id') | list }}
triggers:
#BUGFIX reset detect/motion after frigate restart
- platform: state
Expand Down Expand Up @@ -44,34 +44,34 @@
- action: switch.turn_on
target:
# no detection on side gate, back yard cams
entity_id: >
entity_id: > #VERIFY
{% set detect = on_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_detect', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_detect', ignorecase=False) | list %}
{% set motion = on_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_motion', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_motion', ignorecase=False) | list %}
{% set recordings = on_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_recordings', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_recordings', ignorecase=False) | list %}
{% set snapshots = on_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_snapshots', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_snapshots', ignorecase=False) | list %}
{{ detect + motion + recordings + snapshots }}
- action: switch.turn_off
target:
entity_id: >
{% set detect = off_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_detect', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_detect', ignorecase=False) | list %}
{% set recordings = off_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_recordings', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_recordings', ignorecase=False) | list %}
{% set snapshots = off_cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_snapshots', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_snapshots', ignorecase=False) | list %}
{{ detect + recordings + snapshots }}
# detect switches must bet turned off first or motion switches won't turn off
- action: switch.turn_off
target:
entity_id: >
{{ off_cams | map('regex_replace', find='(.*)_frigate',
replace='switch.\\1_frigate_motion', ignorecase=False) | list }}
{{ off_cams | map('regex_replace', find='camera.(.*)',
replace='switch.\\1_motion', ignorecase=False) | list }}
###############################################################################
## Camera - Turn Off Object Detection
Expand All @@ -81,7 +81,7 @@
description: "Turn off camera object detection."
max_exceeded: silent
variables:
cams: "{{ expand('group.frigate_cameras') | map(attribute='object_id') | list }}"
cams: "{{ expand('group.frigate_cameras') | map(attribute='entity_id') | list }}"
triggers:
- platform: state
entity_id: input_boolean.camera_object_detection
Expand All @@ -105,16 +105,16 @@
target:
entity_id: >
{% set detect = cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_detect', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_detect', ignorecase=False) | list %}
{% set recordings = cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_recordings', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_recordings', ignorecase=False) | list %}
{% set snapshots = cams | map('regex_replace',
find='(.*)_frigate', replace='switch.\\1_frigate_snapshots', ignorecase=False) | list %}
find='camera.(.*)', replace='switch.\\1_snapshots', ignorecase=False) | list %}
{{ detect + recordings + snapshots }}
# detect switches must bet turned off first or motion switches won't turn off
- action: switch.turn_off
target:
entity_id: >
{{ cams | map('regex_replace', find='(.*)_frigate',
replace='switch.\\1_frigate_motion', ignorecase=False) | list }}
{{ cams | map('regex_replace', find='camera.(.*)',
replace='switch.\\1_motion', ignorecase=False) | list }}
30 changes: 15 additions & 15 deletions automations/camera/camera_update_group_entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,20 @@

- platform: state
entity_id: &cameras
- camera.side_drive_frigate
- camera.side_door_frigate
- camera.front_drive_frigate
- camera.front_door_frigate
- camera.front_yard_frigate
- camera.side_gate_front_frigate
- camera.side_gate_back_frigate
- camera.back_yard_frigate
- camera.back_door_frigate
- camera.patio_door_frigate
- camera.back_house_frigate
- camera.garage_inside_frigate
- camera.charlie_crate_frigate
- camera.living_room_frigate
- camera.side_driveway
- camera.side_door
- camera.front_driveway
- camera.front_door
- camera.front_yard
- camera.side_gate_front
- camera.side_gate_back
- camera.back_yard
- camera.back_door
- camera.patio_door
- camera.back_house
- camera.garage_inside
- camera.charlie_crate
- camera.living_room
to:
- unknown
- unavailable
Expand Down Expand Up @@ -89,7 +89,7 @@
{{ states.camera
| selectattr('attributes.frigate', 'defined')
| selectattr('attributes.frigate', 'eq', true)
| rejectattr('entity_id', 'in', ['camera.garage_inside_frigate', 'camera.charlie_crate_frigate', 'camera.living_room_frigate'])
| rejectattr('entity_id', 'in', ['camera.garage_inside', 'camera.charlie_crate', 'camera.living_room'])
| map(attribute='entity_id') | list | sort }}
- action: group.set
Expand Down
6 changes: 3 additions & 3 deletions automations/hass/hass_update_group_entities.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@
- action: group.set
data:
object_id: unavailable_entities_filtered
#TEMP exclude garage_inside_frigate - cam not working
#TEMP exclude garage_inside - cam not working
#TEMP exclude disabled chromecast sensors
#TEMP exclude front_door_lock - lock not working
entities: >
Expand All @@ -157,14 +157,14 @@
| rejectattr('entity_id', 'in', integration_entities('dlna_dmr'))
| rejectattr('entity_id', 'in', state_attr('group.ignored_unavailable_entities','entity_id') | default([]))
| rejectattr('entity_id', 'in', ['sensor.deck_chromecast', 'sensor.office_chromecast'])
| rejectattr('entity_id', 'contains', 'garage_inside_frigate')
| rejectattr('entity_id', 'contains', 'garage_inside')
| rejectattr('entity_id', 'contains', 'front_door_lock')
| rejectattr('entity_id', 'contains', 'daily_energy_consumption')
| rejectattr('entity_id', 'contains', 'jason_laptop_media_player')
| rejectattr('entity_id', 'contains', 'jason_phone_media_player')
| rejectattr('entity_id', 'contains', 'jason_tablet_media_player')
| rejectattr('entity_id', 'contains', '_next_cycle')
| rejectattr('entity_id', 'search', '_door_lock_intrusion|_door_lock_lock_jammed|_door_lock_keypad_temporary_disabled|_door_lock_system_hardware_failure')
| rejectattr('entity_id', 'search', 'charlie_crate_camera|charlie_crate_frigate|living_room_camera|living_room_frigate')
| rejectattr('entity_id', 'search', 'charlie_crate_camera|charlie_crate|living_room_camera|living_room')
| rejectattr('entity_id', 'search', 'jphone_app|jtablet_app|jlaptop_chrome|jwork_chrome|_dlna|_timers|_alarms|_next_alarm')
| map(attribute='entity_id') | list | sort }}
16 changes: 14 additions & 2 deletions automations/lock/lock_reset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
###############################################################################
- id: lock_reset
alias: "[Lock] Reset"
description: "Reset lock jammed sensors."
description: "Reset lock alert sensors."
triggers:
- platform: state
id: alarm
entity_id: input_boolean.alarm_triggered
to: "off"
not_from:
- unknown
- unavailable

- platform: event
event_type: mobile_app_notification_action
event_data:
Expand All @@ -25,4 +33,8 @@
event_data:
action: reset_keypad_disabled_locks
actions:
- action: "script.{{ trigger.event.data['action'] }}"
- if: "{{ trigger.id == 'alarm' }}"
then:
- action: script.reset_intrusion_locks
else:
- action: "script.{{ trigger.event.data['action'] }}"
Loading

0 comments on commit c3c6304

Please sign in to comment.