Skip to content

Commit

Permalink
Update to 2025.2.0
Browse files Browse the repository at this point in the history
- update mobile high accuracy automations
- update low battery alert message
- update binary_sensor.jason_phone_connected
- add alert.jinja custom template file
- update custom templates
- disable bluetooth
  • Loading branch information
jazzyisj committed Feb 2, 2025
1 parent 214aa75 commit 078909d
Show file tree
Hide file tree
Showing 47 changed files with 297 additions and 249 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
conditions:
- alias: "Not out of town"
condition: template
value_template: "{{ states('sensor.home_jason_distance') | int(-1) <= 20, true) }}"
value_template: "{{ states('sensor.home_jason_distance') | int(-1) <= 20 }}"

- alias: "Near home if triggered by activity"
condition: template
value_template: >
{{ iif(trigger.entity_id == 'sensor.jphone_detected_activity',
states('sensor.home_jason_distance') | int(-1) <= 10, true) }}
states('sensor.home_jason_distance') | int(-1) <= 20, true) }}
- condition: template
value_template: >
Expand Down Expand Up @@ -109,9 +109,9 @@

- trigger: state
entity_id: sensor.jphone_detected_activity
to: still
from: in_vehicle
for:
minutes: 5
minutes: 10

- trigger: state
entity_id: binary_sensor.jason_phone_wifi_connected
Expand Down
48 changes: 48 additions & 0 deletions custom_templates/alert.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{%- macro alert_switch(entity) -%}
{%- set active_alert = states.alert | selectattr('attributes.category', 'eq',
states[entity].object_id | replace('_alerts', '')) | 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)
{%- elif is_state(entity, 'off') %} var(--entity-warning-color)
{%- else %} var(--state-icon-color)
{%- endif -%}
;
--state-active-color:
{%- if active_alert %} var(--entity-severe-color)
{%- else %} var(--state-active-color)
{%- endif -%}
;
--switch-unchecked-button-color: var(--entity-warning-color);
--switch-unchecked-track-color: var(--entity-warning-color);
}
{%- endmacro -%}

{%- macro alert_entities(category) -%}
{{ states.alert | selectattr('attributes.category', 'eq', category) | map(attribute='entity_id') | list }}
{%- endmacro -%}

{%- macro alert_zero_style(entity) -%}
:host {
--paper-item-icon-color:
{%- set state = states(entity) | int(-1) %}
{%- if state < 0 %} var(--entity-disabled-color)
{%- elif state == 0 %} var(--entity-warning-color)
{%- else %} var(--state-icon-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro alert_non_zero_style(entity) -%}
:host {
--paper-item-icon-color:
{%- set state = states(entity) | int(-1) %}
{%- if state < 0 %} var(--entity-disabled-color)
{%- elif state == 0 %} var(--state-icon-color)
{%- else %} var(--entity-warning-color)
{%- endif -%}
;
}
{%- endmacro -%}
45 changes: 45 additions & 0 deletions custom_templates/hass.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,49 @@
{%- endif -%}
{%- endfor -%}
{{ ns.unavailables | to_json }}
{%- endmacro -%}

{%- macro status_sensor_style(value, base, minor, warning, severe, critical) -%}
:host {
--paper-item-icon-color:
{%- set value = value | float(-1) -%}
{%- if value < base | float(-1) %} var(--entity-disabled-color)
{%- elif value == base | float or value < minor | float(-1) %} var(--state-icon-color)
{%- elif minor != base and value < warning | float(-1) %} var(--entity-minor-color)
{%- elif warning != base and value < severe | float(-1) %} var(--entity-warning-color)
{%- elif severe != base and value < critical | float(-1) %} var(--entity-severe-color)
{%- else %} var(--entity-critical-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro summary_status_sensor_style(entity) -%}
:host {
--paper-item-icon-color:
{% set value = states(entity) %}
{% if value == 'ok' %} var(--entity-ok-color)
{% elif value == 'minor' %} var(--entity-minor-color)
{% elif value == 'warning' %} var(--entity-warning-color)
{% elif value == 'severe' %} var(--entity-severe-color)
{% elif value == 'critical' %} var(--entity-critical-color)
{% else %} var(--entity-disabled-color)
{% endif %}
;
}
{%- endmacro -%}

{%- macro status_alert_color(value, base, minor, warning, severe, critical) -%}
:host {
--state-alert-on-color:
{%- set value = value | float(-1) -%}
{%- if value < base | float(-1) %} var(--entity-disabled-color)
{%- elif value == base | float or value < minor | float(-1) %} var(--state-icon-color)
{%- elif value != base and value < warning | float(-1) %} var(--entity-minor-color)
{%- elif value != base and value < severe | float(-1) %} var(--entity-warning-color)
{%- elif value != base and value < critical | float(-1) %} var(--entity-severe-color)
{%- else %} var(--entity-critical-color)
{%- endif -%}
;
}
{%- endmacro -%}
90 changes: 0 additions & 90 deletions custom_templates/style.jinja
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
{%- macro alert_switch(entity) -%}
{%- set active_alert = states.alert | selectattr('attributes.category', 'eq',
states[entity].object_id | replace('_alerts', '')) | 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)
{%- elif is_state(entity, 'off') %} var(--entity-warning-color)
{%- else %} var(--state-icon-color)
{%- endif -%}
;
--state-active-color:
{%- if active_alert %} var(--entity-severe-color)
{%- else %} var(--state-active-color)
{%- endif -%}
;
--switch-unchecked-button-color: var(--entity-warning-color);
--switch-unchecked-track-color: var(--entity-warning-color);
}
{%- endmacro -%}

{%- macro popup_style() -%}
div.mdc-dialog__scrim {
backdrop-filter: grayscale(100%) brightness(25%) !important;
Expand All @@ -28,72 +7,3 @@ div.mdc-dialog__surface {
background: transparent !important;
}
{%- endmacro -%}

{%- macro alert_zero_style(entity) -%}
:host {
--paper-item-icon-color:
{%- set state = states(entity) | int(-1) %}
{%- if state < 0 %} var(--entity-disabled-color)
{%- elif state == 0 %} var(--entity-warning-color)
{%- else %} var(--state-icon-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro alert_non_zero_style(entity) -%}
:host {
--paper-item-icon-color:
{%- set state = states(entity) | int(-1) %}
{%- if state < 0 %} var(--entity-disabled-color)
{%- elif state == 0 %} var(--state-icon-color)
{%- else %} var(--entity-warning-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro status_sensor_style(value, base, minor, warning, severe, critical) -%}
:host {
--paper-item-icon-color:
{%- set value = value | float(-1) -%}
{%- if value < base | float(-1) %} var(--entity-disabled-color)
{%- elif value == base | float or value < minor | float(-1) %} var(--state-icon-color)
{%- elif minor != base and value < warning | float(-1) %} var(--entity-minor-color)
{%- elif warning != base and value < severe | float(-1) %} var(--entity-warning-color)
{%- elif severe != base and value < critical | float(-1) %} var(--entity-severe-color)
{%- else %} var(--entity-critical-color)
{%- endif -%}
;
}
{%- endmacro -%}

{%- macro summary_status_sensor_style(entity) -%}
:host {
--paper-item-icon-color:
{% set value = states(entity) %}
{% if value == 'ok' %} var(--entity-ok-color)
{% elif value == 'minor' %} var(--entity-minor-color)
{% elif value == 'warning' %} var(--entity-warning-color)
{% elif value == 'severe' %} var(--entity-severe-color)
{% elif value == 'critical' %} var(--entity-critical-color)
{% else %} var(--entity-disabled-color)
{% endif %}
;
}
{%- endmacro -%}

{%- macro status_alert_color(value, base, minor, warning, severe, critical) -%}
:host {
--state-alert-on-color:
{%- set value = value | float(-1) -%}
{%- if value < base | float(-1) %} var(--entity-disabled-color)
{%- elif value == base | float or value < minor | float(-1) %} var(--state-icon-color)
{%- elif value != base and value < warning | float(-1) %} var(--entity-minor-color)
{%- elif value != base and value < severe | float(-1) %} var(--entity-warning-color)
{%- elif value != base and value < critical | float(-1) %} var(--entity-severe-color)
{%- else %} var(--entity-critical-color)
{%- endif -%}
;
}
{%- endmacro -%}
61 changes: 29 additions & 32 deletions packages/bluetooth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@ homeassistant:
icon: mdi:bluetooth-off
category: bluetooth

device_tracker.jason_phone_bt:
device_type: bluetooth
device_tracker.jason_tablet_bt:
device_type: bluetooth
device_tracker.jason_laptop_bt:
device_type: bluetooth
device_tracker.fugoo_speaker_bt:
device_type: bluetooth
device_tracker.jason_headphones_bt:
device_type: bluetooth
device_tracker.laundry_room_speaker_bt:
device_type: bluetooth
device_tracker.living_room_speaker_bt:
device_type: bluetooth
device_tracker.bathroom_speaker_bt:
device_type: bluetooth
device_tracker.kitchen_hub_bt:
device_type: bluetooth
device_tracker.dining_room_hub_bt:
device_type: bluetooth
device_tracker.bedroom_hub_bt:
device_type: bluetooth
device_tracker.office_speaker_bt:
device_type: bluetooth
device_tracker.living_room_tv_bt:
device_type: bluetooth
device_tracker.bedroom_tv_bt:
device_type: bluetooth
# device_tracker.jason_phone_bt: #DISABLED
# device_type: bluetooth
# device_tracker.jason_tablet_bt:
# device_type: bluetooth
# device_tracker.jason_laptop_bt:
# device_type: bluetooth
# device_tracker.fugoo_speaker_bt:
# device_type: bluetooth
# device_tracker.jason_headphones_bt:
# device_type: bluetooth
# device_tracker.laundry_room_speaker_bt:
# device_type: bluetooth
# device_tracker.living_room_speaker_bt:
# device_type: bluetooth
# device_tracker.bathroom_speaker_bt:
# device_type: bluetooth
# device_tracker.kitchen_hub_bt:
# device_type: bluetooth
# device_tracker.dining_room_hub_bt:
# device_type: bluetooth
# device_tracker.bedroom_hub_bt:
# device_type: bluetooth
# device_tracker.office_speaker_bt:
# device_type: bluetooth
# device_tracker.living_room_tv_bt:
# device_type: bluetooth
# device_tracker.bedroom_tv_bt:
# device_type: bluetooth

input_boolean:
bluetooth_alerts:
name: "Bluetooth Alerts"
icon: mdi:alert

# device_tracker:
# #DISABLED https://github.com/jazzyisj/home-assistant-config/issues/70
# # https://github.com/jazzyisj/home-assistant-config/issues/70 #DISABLED
# # - platform: bluetooth_tracker
# # track_new_devices: true
# # request_rssi: true
Expand All @@ -52,9 +52,6 @@ input_boolean:
# # track_battery: true
# # track_battery_interval: "4:00"

# #DISABLED bluetooth not stable
# # - platform: custom_bluetooth_tracker

alert:
bluetooth_offline:
name: "Bluetooth Offline"
Expand Down
2 changes: 1 addition & 1 deletion packages/hass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ alert:
message: |
{%- set entities = expand('group.low_batteries') -%}
{%- for item in entities -%}
{{- item.name | lower | replace(' battery level', '') | replace(': battery level', '') | title }} - {{ item.state_with_unit }}
{{- item.name | lower | replace(' battery level', '') | replace(': battery level', '') | replace(' battery', '') | title }} - {{ item.state_with_unit }}
{%- if not loop.last %}<br/>{% endif -%}
{%- endfor -%}
done_message: clear_notification
Expand Down
30 changes: 18 additions & 12 deletions templates/mobile/mobile_jason.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,15 @@
unique_id: jason_phone_connected
icon: "{{ iif(is_state(this.entity_id, 'on'), 'mdi:cellphone-wireless', 'mdi:cellphone-off') }}"
device_class: connectivity
state: >
{{ has_value('sensor.jason_phone_last_update')
and now() - as_datetime(states('sensor.jason_phone_last_update')) < timedelta(minutes=30) }}
state: "{{ state_attr(this.entity_id, 'update_time') != none }}"
attributes:
update_time: >
{% set updated = as_datetime(state_attr('binary_sensor.jason_phone_connected', 'update_time'), none) %}
{% if updated != none %}
Updated {{ updated.strftime('today at %-I:%M %p')
if now().day == updated.day else updated.strftime('%A, %-I:%M %p') }}
{% endif %}
- name: "Jason Phone Connected Alert"
unique_id: jason_phone_connected_alert
Expand Down Expand Up @@ -236,15 +242,15 @@
unique_id: jason_phone_bluetooth_disconnected_alert
device_class: problem
delay_on: 900
state: "off" #DISABLED until bluetooth working
# state: >
# {{ is_state('input_boolean.mobile_alerts', 'on')
# and is_state('binary_sensor.jason_phone_connected', 'on')
# and is_state('binary_sensor.jason_home', 'on')
# and is_state('input_boolean.home_override_jason', 'off')
# and is_state('alert.bluetooth_offline', 'idle')
# and is_state('alert.jason_phone_bluetooth_off', 'idle')
# and not is_state('device_tracker.jason_phone_bt', 'home') }}
state: > #TEMP include bluetooth alerts to disable until bt working
{{ is_state('input_boolean.bluetooth_alerts', 'on')
and is_state('input_boolean.mobile_alerts', 'on')
and is_state('binary_sensor.jason_phone_connected', 'on')
and is_state('binary_sensor.jason_home', 'on')
and is_state('input_boolean.home_override_jason', 'off')
and is_state('alert.bluetooth_offline', 'idle')
and is_state('alert.jason_phone_bluetooth_off', 'idle')
and not is_state('device_tracker.jason_phone_bt', 'home') }}
- name: "Jason Phone WIFI Disconnected Alert"
unique_id: jason_phone_wifi_disconnected_alert
Expand Down
16 changes: 8 additions & 8 deletions templates/system.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
icon: mdi:memory
state: >
{% set mem = states('sensor.memory_use_percent') | float(-1) | round %}
{% if mem > 94 %} critical
{% elif mem > 84 %} severe
{% elif mem > 74 %} warning
{% elif mem > 59 %} minor
{% if mem > 95 %} critical
{% elif mem > 90 %} severe
{% elif mem > 80 %} warning
{% elif mem > 70 %} minor
{% else %} ok
{% endif %}
Expand Down Expand Up @@ -83,10 +83,10 @@
icon: mdi:thermometer
state: >
{% set temp = states('sensor.processor_temperature') | float(-1) | round %}
{% if temp > 79 %} critical
{% elif temp > 69 %} severe
{% elif temp > 59 %} warning
{% elif temp > 49 %} minor
{% if temp > 80 %} critical
{% elif temp > 75 %} severe
{% elif temp > 70 %} warning
{% elif temp > 60 %} minor
{% else %} ok
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion ui/bar/hass_memory_use_entity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ card_mod:
class: bar_sub_card
style: |
{% from 'style.jinja' import status_sensor_style %}
{{ status_sensor_style(states('sensor.home_assistant_core_memory_percent'), 0, 60, 75, 85, 95) }}
{{ status_sensor_style(states('sensor.home_assistant_core_memory_percent'), 0, 71, 81, 91, 96) }}
Loading

0 comments on commit 078909d

Please sign in to comment.