Skip to content

Commit

Permalink
Update to 2024.5.2
Browse files Browse the repository at this point in the history
- presence_someone_arrives_home bugfix
- consolidate weather templates
- organize custom templates
- minor bugfixes
  • Loading branch information
jazzyisj committed May 9, 2024
1 parent 8486e4b commit 901d9af
Show file tree
Hide file tree
Showing 44 changed files with 456 additions and 306 deletions.
2 changes: 1 addition & 1 deletion automations/alarm/alarm_doorbell.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
continue_on_error: true

- variables:
file: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename('front_door') }}"
file: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename('front_door') }}"

- service: camera.snapshot
target:
Expand Down
10 changes: 5 additions & 5 deletions automations/alarm/alarm_notifications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@
- repeat:
sequence:
- variables:
file1: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename(cam1) }}"
file2: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename(cam2) }}"
file3: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename(cam3) }}"
file4: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename(cam4) }}"
file1: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename(cam1) }}"
file2: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename(cam2) }}"
file3: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename(cam3) }}"
file4: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename(cam4) }}"

- service: camera.snapshot
target:
Expand Down Expand Up @@ -313,7 +313,7 @@
state: "on"
sequence:
- variables:
file1: "alarm_snapshots/{% from 'file.jinja' import snapshot_filename %}{{ snapshot_filename(cam1) }}"
file1: "alarm_snapshots/{% from 'camera.jinja'import snapshot_filename %}{{ snapshot_filename(cam1) }}"

- service: camera.snapshot
target:
Expand Down
9 changes: 5 additions & 4 deletions automations/camera/camera_object_detected.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
description: "Object detected notification."
mode: parallel
trace:
stored_traces: 30 #TEST
stored_traces: 30
variables:
id: "{{ trigger.payload_json['after']['id'] }}"
object: "{{ trigger.payload_json['after']['label'] }}"
Expand All @@ -18,11 +18,12 @@
- platform: mqtt
topic: frigate/events
condition:
- condition: template
value_template: "{{ new }}"
- condition: state
entity_id: input_boolean.camera_object_detection
state: "on"

- condition: template
value_template: "{{ object in ['person', 'car'] }}"
value_template: "{{ new }}"
action:
- parallel:
- sequence:
Expand Down
1 change: 1 addition & 0 deletions automations/hass/hass_alert_notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- group.unknown_devices
attribute: entity_id
to:
for: 60

# must trigger when alert turns on/off
- platform: state
Expand Down
8 changes: 4 additions & 4 deletions automations/notify/notify_alert_announcements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
Attention! The allergy risk alert is now on.
The allergy risk for today is {{ states('sensor.allergy_risk_today') }}, and it will be {{ states('sensor.allergy_risk_tomorrow') }} tomorrow.
{%- elif t == 'alert.precipitation' %}
{%- from 'speech.jinja' import precipitation_text %}
{%- from 'weather.jinja' import precipitation_text %}
Attention! {{- precipitation_text() }}
Make sure you get Charlie walked!
{%- elif t == 'alert.wind' %}
Expand Down Expand Up @@ -128,7 +128,7 @@
{%- elif t == 'alert.bathroom_mold_risk' %}
Attention! The bathroom mold risk alert is active.
{%- elif t == 'alert.door_lock_jammed' %}
{% from 'speech.jinja' import clist_locks %}
{% from 'lock.jinja' import clist_locks %}
{%- set locks = states.binary_sensor
| selectattr('entity_id', 'contains', '_door_lock_lock_jammed')
| selectattr('state', 'eq', 'on')
Expand All @@ -139,7 +139,7 @@
{%- set plural = 's are' if locks | count > 1 else ' is' -%}
Attention! The {{ clist_locks(locks) }} door lock{{ plural }} jammed!
{%- elif t == 'alert.door_lock_failed' %}
{%- from 'speech.jinja' import clist_locks %}
{%- from 'lock.jinja' import clist_locks %}
{%- set locks = states.binary_sensor
| selectattr('entity_id', 'contains', '_door_lock_system_hardware_failure')
| selectattr('state', 'eq', 'on')
Expand All @@ -150,7 +150,7 @@
{%- set plural = 's have' if locks | count > 1 else ' has' -%}
Attention! The {{ clist_locks(locks) }} door lock{{ plural }} failed!
{%- elif t == 'alert.door_lock_keypad_disabled' %}
{%- from 'speech.jinja' import clist_locks %}
{%- from 'lock.jinja' import clist_locks %}
{%- set locks = states.binary_sensor
| selectattr('entity_id', 'contains', '_door_lock_keypad_temporary_disabled')
| selectattr('state', 'eq', 'on')
Expand Down
2 changes: 1 addition & 1 deletion automations/presence/presence_occupancy_notification.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@
{%- if zone != 'master' %}, and the {{ other_zone }} alarm is {{ states('sensor.' ~ other_zone ~ '_alarm_status') -}}{%- endif %}
.
{%- endif %}
{{ 'Personalized occupant automations are disabled in Guest mode.' if states('input_select.occupancy_mode') == 'Guest' }}
{{ 'Personalized occupant automations are disabled.' if states('input_select.occupancy_mode') == 'Guest' }}
ignore_away: true
save_message: "{{ is_state('binary_sensor.mobile_phone_in_use','on') }}"
continue_on_error: true
Expand Down
16 changes: 7 additions & 9 deletions automations/presence/presence_someone_arrives_home.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
- unavailable
for: 5 # allow first_home to calculate
action:
- if: "{{ first_home }}"
then:
- service: input_select.select_option
target:
entity_id: input_select.occupancy_mode
data:
option: >
{% from 'presence.jinja' import occupancy_mode %}
{{ occupancy_mode() }}
- service: input_select.select_option
target:
entity_id: input_select.occupancy_mode
data:
option: >
{% from 'presence.jinja' import occupancy_mode %}
{{ occupancy_mode() }}
- parallel:
- sequence:
Expand Down
4 changes: 2 additions & 2 deletions automations/weather/precipitation_alert.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
action:
- variables:
file: >
{%- from 'file.jinja' import snapshot_filename -%}
{%- from 'camera.jinja'import snapshot_filename -%}
weather_snapshots/{{- snapshot_filename('windsor_radar') -}}
- service: camera.snapshot
Expand All @@ -57,7 +57,7 @@
- service: notify.jason
data:
message: |
{%- from 'speech.jinja' import precipitation_text -%}
{%- from 'weather.jinja' import precipitation_text -%}
{{- precipitation_text() -}}
data:
tag: windsor_radar
Expand Down
File renamed without changes.
18 changes: 18 additions & 0 deletions custom_templates/door.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{%- macro window_door_sensor(entity_name) -%}
:host {
--paper-item-icon-color:
{%- if is_state('input_boolean.' ~ entity_name, 'on') %} var(--state-icon-color)
{%- else %} var(--entity-minor-color)
{%- endif -%}
;
--state-binary_sensor-active-color:
{%- set sensor = 'binary_sensor.' ~ entity_name ~ '_open_alert' %}
{%- set trigger = state_attr('alarm_control_panel.master', 'open_sensors') if state_attr('alarm_control_panel.master', 'open_sensors') else '' %}
{%- if is_state('input_boolean.alarm_triggered', 'on') and sensor in trigger %} var(--entity-critical-color)
{%- elif is_state(sensor, 'on') and not is_state('alert.hvac_window_door_open', 'idle') %} var(--entity-severe-color)
{%- elif is_state('input_boolean.' ~ entity_name, 'off') %} var(--state-warning-color)
{%- else %} var(--state-active-color)
{%- endif -%}
;
}
{%- endmacro -%}
26 changes: 26 additions & 0 deletions custom_templates/light.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@
{{- timer if has_value(timer) else none -}}
{%- endmacro -%}

{%- macro light_switch(entity, switch) -%}
.primary {
color:
{%- set manual = state_attr(switch, 'manual_control') %}
{%- if manual != none %}
{%- if entity in manual %} var(--entity-warning-color)
{%- else %} var(--primary-text-color)
{%- endif %}
{%- else %} var(--primary-text-color)
{%- endif -%}
!important;
}
{%- endmacro -%}

{%- macro adaptive_switch(light) -%}
{%- if state_attr(light, 'rgb_light') == 'slave' %}
{%- set light = state_attr(light, 'master') %}
Expand All @@ -35,4 +49,16 @@
{%- endif %}
{{- light in state_attr(switch, 'manual_control')
if switch != none and state_attr(switch, 'manual_control') != none else false -}}
{%- endmacro -%}

{%- macro scene_rgb_state(scene) -%}
rgb({{ states('input_number.rgb_red_' ~ scene) | int }},
{{- states('input_number.rgb_green_' ~ scene) | int }},
{{- states('input_number.rgb_blue_' ~ scene) | int }})
{%- endmacro -%}

{%- macro scene_rgb_attribute(scene) -%}
[{{ states('input_number.rgb_red_' ~ scene) | int }},
{{- states('input_number.rgb_green_' ~ scene) | int }},
{{- states('input_number.rgb_blue_' ~ scene) | int }}]
{%- endmacro -%}
12 changes: 12 additions & 0 deletions custom_templates/lock.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{%- macro clist_locks(locks) -%}
{%- set msg = namespace(value='') %}
{%- set qty = namespace(value=0) %}
{%- for item in locks %}
{%- set qty.value = qty.value | int(0) + 1 %}
{%- if not loop.first %}{% set msg.value = msg.value ~ ', ' %}{% endif %}
{%- set msg.value = msg.value ~ states[item].object_id | replace('_door_lock', '') | replace('_', ' ') | title %}
{%- endfor %}
{%- set clist = ', and ' if msg.value.split(', ') | count > 2 else ' and ' %}
{%- set plural = 's have' if qty.value | int(0) > 1 else ' has' %}
{{- clist.join(msg.value.rsplit(', ', 1)) -}}
{%- endmacro -%}
11 changes: 0 additions & 11 deletions custom_templates/rgb.jinja

This file was deleted.

12 changes: 12 additions & 0 deletions custom_templates/schedule.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{%- macro list_events(events) -%}
{%- for event in events %}
{%- if (event.start is defined) %}
{%- if (event.start | as_datetime).day == now().day %}
{{ event.start | as_timestamp | timestamp_custom('Today at %-I:%M %p') }}: {% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- else %}
{{ event.start | as_timestamp | timestamp_custom('%A at %-I:%M %p') }}: {% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- endif %}
{%- else %}{% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- endif %}
{%- endfor %}.
{%- endmacro -%}
34 changes: 0 additions & 34 deletions custom_templates/speech.jinja
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
{%- macro precipitation_text() -%}
{%- from 'speech.jinja' import plural_qty -%}
{%- from 'speech.jinja' import full_cardinal_direction -%}
{%- set current = states('sensor.precipitation_type') | lower %}
{%- set type = state_attr('sensor.precipitation_start', 'type') | lower %}
{%- set time = state_attr('sensor.precipitation_start', '12hour') %}
{%- set dist = states('sensor.nearest_storm_distance') | int(-1) %}
{%- set dir = full_cardinal_direction(states('sensor.nearest_storm_bearing') | int(-1)) %}
{%- if is_state('binary_sensor.precipitation_active','on') %}
It is {{ current }}ing right now.
{%- elif time != none %}
Possibility of {{ type }} around {{ time }}.
{%- if dist > 0 %}
The storm is {{ iif(dist > 0,
plural_qty('kilometer', dist, false) ~ ' away', ' in the immediate vicinity') }}
{{- iif(dir != 'unknown', ' approaching from the ' ~ dir, '') }}.
{%- endif %}
{%- endif -%}
{%- endmacro -%}

{%- macro list_events(events) -%}
{%- for event in events %}
{%- if (event.start is defined) %}
{%- if (event.start | as_datetime).day == now().day %}
{{ event.start | as_timestamp | timestamp_custom('Today at %-I:%M %p') }}: {% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- else %}
{{ event.start | as_timestamp | timestamp_custom('%A at %-I:%M %p') }}: {% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- endif %}
{%- else %}{% if event.summary is defined %}{{ event.summary }}{% endif %}
{%- endif %}
{%- if event.description is defined %} - {{ event.description }}{% endif %}
{%- endfor %}.
{%- endmacro -%}

{%- macro twelve_hour(entity) -%}
{{- states(entity) | as_timestamp(none) | timestamp_custom('%-I:%M %p', true, none) -}}
{%- endmacro -%}
Expand Down
35 changes: 1 addition & 34 deletions custom_templates/style.jinja
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{%- macro alert_switch(entity) -%}
{%- set active_alert = states.alert | selectattr('attributes.category', 'eq', states[entity].object_id[:-7])
| selectattr('state', 'ne', 'idle') | list | count > 0 -%}
| selectattr('state', 'ne', 'idle') | list | count > 0 if states[entity] != none else false -%}
:host {
--paper-item-icon-color:
{%- if active_alert %} var(--entity-severe-color)
Expand All @@ -18,39 +18,6 @@
}
{%- endmacro -%}

{%- macro window_door_sensor(entity_name) -%}
:host {
--paper-item-icon-color:
{%- if is_state('input_boolean.' ~ entity_name, 'on') %} var(--state-icon-color)
{%- else %} var(--entity-minor-color)
{%- endif -%}
;
--state-binary_sensor-active-color:
{%- set sensor = 'binary_sensor.' ~ entity_name ~ '_open_alert' %}
{%- set trigger = state_attr('alarm_control_panel.master', 'open_sensors') if state_attr('alarm_control_panel.master', 'open_sensors') else '' %}
{%- if is_state('input_boolean.alarm_triggered', 'on') and sensor in trigger %} var(--entity-critical-color)
{%- elif is_state(sensor, 'on') and not is_state('alert.hvac_window_door_open', 'idle') %} var(--entity-severe-color)
{%- elif is_state('input_boolean.' ~ entity_name, 'off') %} var(--state-warning-color)
{%- else %} var(--state-active-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro light_switch(entity, switch) -%}
.primary {
color:
{%- set manual = state_attr(switch, 'manual_control') %}
{%- if manual != none %}
{%- if entity in manual %} var(--entity-warning-color)
{%- else %} var(--primary-text-color)
{%- endif %}
{%- else %} var(--primary-text-color)
{%- endif -%}
!important;
}
{%- endmacro -%}

{%- macro popup_style() -%}
div.mdc-dialog__scrim {
backdrop-filter: grayscale(100%) brightness(25%) !important;
Expand Down
Loading

0 comments on commit 901d9af

Please sign in to comment.