From a7c90b11beccded4b53206381ca9db671da0d724 Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Sat, 18 Mar 2023 20:54:29 -0400 Subject: [PATCH] Clean up template sensors and add UUIDs to presence template sensors #70 --- packages/custom_weather.yaml | 4 ---- packages/presence.yaml | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/custom_weather.yaml b/packages/custom_weather.yaml index 27bec5c..873eacf 100644 --- a/packages/custom_weather.yaml +++ b/packages/custom_weather.yaml @@ -32,7 +32,6 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.hot_day_threshold') | int }}" - - binary_sensor: - name: Heat Index Threshold state: > {% set feelslike = states('sensor.pirateweather_apparent_temperature') | int %} @@ -46,7 +45,6 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_apparent_temperature') | int }}" threshold: "{{ states('input_number.heat_index_threshold') | int }}" - - binary_sensor: - name: Cold Threshold state: > {% set temp = states('sensor.pirateweather_temperature') | int %} @@ -60,7 +58,6 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.cold_day_threshold') | int }}" - - binary_sensor: - name: Overnight Low Threshold state: > {% set temp = states('sensor.pirateweather_temperature') | int %} @@ -74,7 +71,6 @@ template: attributes: current_temp: "{{ states('sensor.pirateweather_temperature') | int }}" threshold: "{{ states('input_number.overnight_low_threshold') | int }}" - - binary_sensor: - name: Wind Chill Threshold state: > {% set feelslike = states('sensor.pirateweather_apparent_temperature') | int %} diff --git a/packages/presence.yaml b/packages/presence.yaml index 6a7275c..a0907e2 100644 --- a/packages/presence.yaml +++ b/packages/presence.yaml @@ -79,6 +79,7 @@ sensor: sensors: tony_location: friendly_name: "Tony" + unique_id: 2620a9d0-01f0-4af4-8438-a0c860735aab unit_of_measurement: "" value_template: >- {% set person = states.person.tony_stork.state %} @@ -104,6 +105,7 @@ sensor: {% endif %} tina_location: friendly_name: "Tina" + unique_id: 5439165c-f73e-4870-826a-d12c99e35487 unit_of_measurement: "" value_template: >- {% set person = states.person.christina_stork.state %} @@ -131,6 +133,7 @@ sensor: {% endif %} kallen_location: friendly_name: "Kallen" + unique_id: d4b4c324-52aa-41e4-b446-8ba0d6b45cd3 unit_of_measurement: "" value_template: >- {% set person = states.person.kallen_stork.state %} @@ -158,11 +161,13 @@ sensor: {% endif %} people_home: friendly_name: "People" + unique_id: 053d3a0a-f5b4-48e0-a8df-4d847d0fe9c3 unit_of_measurement: 'home' value_template: >- {{ states['person'] | selectattr('state','eq','home') | list | count }} people_away: friendly_name: "People" + unique_id: e46e51a6-3c57-4599-840b-fca6884f867e unit_of_measurement: 'away' value_template: >- {% set people = [ @@ -173,6 +178,7 @@ sensor: {{ people | selectattr('state','ne','home') | list | count }} front_door_opened_today: friendly_name: "Front Door Opened Today" + unique_id: 6a8bb32e-5f4e-4d1f-8e17-77f07e5b174a unit_of_measurement: 'times' value_template: >- {{ states('input_number.front_door_opened_today') | int }} @@ -184,6 +190,7 @@ sensor: {% endif %} back_door_opened_today: friendly_name: "Back Door Opened Today" + unique_id: 77786cc9-64de-4035-a635-e831a3b0ef63 unit_of_measurement: 'times' value_template: >- {{ states('input_number.back_door_opened_today') | int }} @@ -195,6 +202,7 @@ sensor: {% endif %} basement_studio_door_opened_today: friendly_name: "Basement Studio Door Opened Today" + unique_id: 3d74efd0-2df5-438e-a015-26ac1ce2c4ee unit_of_measurement: 'times' value_template: >- {{ states('input_number.basement_studio_door_opened_today') | int }} @@ -206,6 +214,7 @@ sensor: {% endif %} downstairs_bathroom_door_opened_today: friendly_name: "Downstairs Bathroom Door Opened Today" + unique_id: cdc850bc-3747-405d-8b16-3b79ba9fbc87 unit_of_measurement: 'times' value_template: >- {{ states('input_number.downstairs_bathroom_door_opened_today') | int }} @@ -219,18 +228,19 @@ sensor: template: - binary_sensor: - name: "Tony Home" + unique_id: 4f0d8c3d-dc49-4b7a-a1fc-5d286b4a954d state: "{{ is_state('device_tracker.tony_s_iphone', 'home') or is_state('device_tracker.life360_tony_stork','home') }}" device_class: presence - - binary_sensor: - name: "Tina Home" + unique_id: 3d90e515-b204-4510-af0c-6c784fda2bd4 state: "{{ is_state('device_tracker.tinas_iphone', 'home') or is_state('device_tracker.life360_christina_stork','home') }}" device_class: presence - - binary_sensor: - name: "Kallen Home" + unique_id: 2419e826-b276-434c-b5c6-e42c065a73ff state: "{{ is_state('device_tracker.kallen_iphone','home') or is_state('device_tracker.life360_kallen_stork','home') }}" device_class: presence - - binary_sensor: - name: "Nerds Home" + unique_id: 2672a6a2-4be4-495c-b479-ffc7c6df67d2 state: >- {% if is_state('group.family','home') %} {% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.kallen_home','on') %} @@ -242,8 +252,8 @@ template: false {% endif %} device_class: presence - - binary_sensor: - name: "Parents Home" + unique_id: 8de02d19-60a6-436d-9187-1cfc70d6c297 state: >- {% if is_state('group.adults','home') %} {% if is_state('binary_sensor.tony_home','on') or is_state('binary_sensor.tina_home','on') %}