post home assistant update

This commit is contained in:
2024-05-22 08:48:51 -04:00
parent 5940c16d91
commit eb934c32e2
37 changed files with 1077 additions and 731 deletions

12
hass_trackers/README.md Normal file
View File

@@ -0,0 +1,12 @@
# HASS Trackers Ansible
## Installation
You'll need to ssh into home assistant and run `apk add python3`
Check vars.yaml to edit your trackers.
```bash
ansible-playbook -i ansible/inventory.yaml hass_trackers/install_trackers.yaml
ansible-playbook -i ansible/inventory.yaml hass_trackers/create_dashboards.yaml
```

View File

@@ -0,0 +1,300 @@
type: grid
square: false
columns: 1
cards:
- type: markdown
content: >
{% set trackers = [
{
"counter": states("counter.days_since_fridge_water_filter") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_fridge_water_filter", "upper"),
"percent": (int(states("counter.days_since_fridge_water_filter")) / state_attr("binary_sensor.threshold_for_days_since_fridge_water_filter", "upper")),
"name": "Fridge Water Filter Replaced"
},
{
"counter": states("counter.days_since_litter_boxes_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_litter_boxes_cleaned", "upper"),
"percent": (int(states("counter.days_since_litter_boxes_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_litter_boxes_cleaned", "upper")),
"name": "Litter Boxes Cleaned"
},
{
"counter": states("counter.days_since_cat_water_fountain_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_cat_water_fountain_cleaned", "upper"),
"percent": (int(states("counter.days_since_cat_water_fountain_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_cat_water_fountain_cleaned", "upper")),
"name": "Cat Water Fountain Cleaned"
},
{
"counter": states("counter.days_since_kitchen_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_kitchen_cleaned", "upper"),
"percent": (int(states("counter.days_since_kitchen_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_kitchen_cleaned", "upper")),
"name": "Kitchen Cleaned"
},
{
"counter": states("counter.days_since_kitchen_counters_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_kitchen_counters_cleaned", "upper"),
"percent": (int(states("counter.days_since_kitchen_counters_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_kitchen_counters_cleaned", "upper")),
"name": "Kitchen Counters Cleaned"
},
{
"counter": states("counter.days_since_living_room_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_living_room_cleaned", "upper"),
"percent": (int(states("counter.days_since_living_room_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_living_room_cleaned", "upper")),
"name": "Living Room Cleaned"
},
{
"counter": states("counter.days_since_upstairs_vacuumed") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_upstairs_vacuumed", "upper"),
"percent": (int(states("counter.days_since_upstairs_vacuumed")) / state_attr("binary_sensor.threshold_for_days_since_upstairs_vacuumed", "upper")),
"name": "Upstairs Vacuumed"
},
{
"counter": states("counter.days_since_bathroom_counters_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_bathroom_counters_cleaned", "upper"),
"percent": (int(states("counter.days_since_bathroom_counters_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_bathroom_counters_cleaned", "upper")),
"name": "Bathroom Counters Cleaned"
},
{
"counter": states("counter.days_since_bedroom_vacuumed") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_bedroom_vacuumed", "upper"),
"percent": (int(states("counter.days_since_bedroom_vacuumed")) / state_attr("binary_sensor.threshold_for_days_since_bedroom_vacuumed", "upper")),
"name": "Bedroom Vacuumed"
},
{
"counter": states("counter.days_since_toilets_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_toilets_cleaned", "upper"),
"percent": (int(states("counter.days_since_toilets_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_toilets_cleaned", "upper")),
"name": "Toilets Cleaned"
},
]%}
{% for tracker in (trackers | sort(reverse=true, attribute='percent')) %}
{% set days_left = ((tracker.threshold - tracker.counter) | int | string) %}
{% set message = tracker.name + " completed " + tracker.counter | string + " days ago. Due again in " + days_left + " days." %}
{% if tracker.percent > 1 %}
<ha-alert alert-type="error">{{ message }}</ha-alert>
{% elif tracker.percent > 0.8 %}
<ha-alert alert-type="warning">{{ message }}</ha-alert>
{% else %}
<ha-alert alert-type="success">{{ message }}</ha-alert>
{% endif %}
{% endfor %}
- type: grid
square: false
columns: 2
title: Days Since Fridge Water Filter Replaced
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_fridge_water_filter
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_fridge_water_filter
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_fridge_water_filter
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_fridge_water_filter
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Litter Boxes Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_litter_boxes_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_litter_boxes_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_litter_boxes_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_litter_boxes_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Cat Water Fountain Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_cat_water_fountain_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_cat_water_fountain_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_cat_water_fountain_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_cat_water_fountain_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Kitchen Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_kitchen_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_kitchen_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_kitchen_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_kitchen_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Kitchen Counters Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_kitchen_counters_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_kitchen_counters_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_kitchen_counters_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_kitchen_counters_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Living Room Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_living_room_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_living_room_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_living_room_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_living_room_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Upstairs Vacuumed
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_upstairs_vacuumed
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_upstairs_vacuumed
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_upstairs_vacuumed
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_upstairs_vacuumed
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Bathroom Counters Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_bathroom_counters_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_bathroom_counters_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_bathroom_counters_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_bathroom_counters_cleaned
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Bedroom Vacuumed
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_bedroom_vacuumed
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_bedroom_vacuumed
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_bedroom_vacuumed
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_bedroom_vacuumed
name: Last Non-Zero
- type: grid
square: false
columns: 2
title: Days Since Toilets Cleaned
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_toilets_cleaned
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_toilets_cleaned
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_toilets_cleaned
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_toilets_cleaned
name: Last Non-Zero

View File

@@ -1,167 +0,0 @@
Counters:
```yaml
days_since_fridge_filter_replaced:
name: days_since_fridge_filter_replaced
restore: true
initial: 0
step: 1
icon: mdi:fridge
last_non_zero_days_since_fridge_filter_replaced:
name: last_non_zero_days_since_fridge_filter_replaced
restore: true
initial: 0
step: 1
icon: mdi:fridge
```
Input Buttons:
```yaml
reset_days_since_fridge_filter_replaced:
name: reset_days_since_fridge_filter_replaced
icon: mdi:fridge
undo_reset_days_since_fridge_filter_replaced:
name: undo_reset_days_since_fridge_filter_replaced
icon: mdi:undo
```
Automations:
```yaml
- alias: 'Counter: Increment days_since_fridge_filter_replaced'
description: ''
trigger:
- platform: time
at: 00:00:00
condition: []
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.days_since_fridge_filter_replaced
mode: single
- alias: 'Counter: Reset days_since_fridge_filter_replaced'
description: ''
trigger:
- platform: state
entity_id:
- input_button.reset_days_since_fridge_filter_replaced
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.days_since_fridge_filter_replaced
mode: single
- alias: 'Counter: Update last_non_zero_days_since_fridge_filter_replaced'
description: ''
trigger:
- platform: state
entity_id:
- counter.days_since_fridge_filter_replaced
condition:
- condition: numeric_state
entity_id: counter.days_since_fridge_filter_replaced
above: 0
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_fridge_filter_replaced
mode: single
- alias: 'Counter: Reset last_non_zero_days_since_fridge_filter_replaced'
description: ''
trigger:
- platform: numeric_state
entity_id:
- counter.days_since_fridge_filter_replaced
above: 0
below: 2
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_fridge_filter_replaced
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_fridge_filter_replaced
mode: single
- alias: 'Counter: Undo Reset days_since_fridge_filter_replaced'
description: ''
trigger:
- platform: state
entity_id:
- input_button.undo_reset_days_since_fridge_filter_replaced
condition:
- condition: numeric_state
entity_id: counter.days_since_fridge_filter_replaced
below: 1
action:
- service: counter.set_value
metadata: {}
data:
value: "{{ int(states('counter.last_non_zero_days_since_fridge_filter_replaced'))}}"
target:
entity_id: counter.days_since_fridge_filter_replaced
- service: counter.decrement
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_fridge_filter_replaced
mode: single
```
Dashboard:
```yaml
title: Days Since Fridge Filter Replaced
type: grid
square: false
columns: 1
cards:
- type: grid
square: false
columns: 2
cards:
- name: Reset
show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.reset_days_since_fridge_filter_replaced
show_state: true
- name: Undo
show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.undo_reset_days_since_fridge_filter_replaced
show_state: true
- type: grid
square: false
columns: 2
cards:
- type: entity
entity: counter.days_since_fridge_filter_replaced
state_color: false
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_fridge_filter_replaced
state_color: false
name: Last Value
- type: history-graph
hours_to_show: 72
entities:
- counter.days_since_fridge_filter_replaced
```

View File

@@ -0,0 +1,68 @@
- name: Install HASS Trackers
hosts: hass
vars_files:
- vars.yaml
tasks:
- name: Create counters dir
ansible.builtin.file:
path: /root/config/counters
state: directory
mode: '0755'
- name: Create binary sensors dir
ansible.builtin.file:
path: /root/config/binary_sensors
state: directory
mode: '0755'
- name: Create input buttons dir
ansible.builtin.file:
path: /root/config/input_buttons
state: directory
mode: '0755'
- name: Create automations dir
ansible.builtin.file:
path: /root/config/automations
state: directory
mode: '0755'
- name: Template all counters
template:
src: templates/counter.yaml
dest: /root/config/counters/{{ item.id }}.yaml
owner: root
group: root
mode: '0644'
with_items: "{{ trackers }}"
- name: Template all thresholds
template:
src: templates/threshold.yaml
dest: /root/config/binary_sensors/{{ item.id }}.yaml
owner: root
group: root
mode: '0644'
with_items: "{{ trackers }}"
- name: Template all input buttons
template:
src: templates/input_button.yaml
dest: /root/config/input_buttons/{{ item.id }}.yaml
owner: root
group: root
mode: '0644'
with_items: "{{ trackers }}"
- name: Template all automations
template:
src: templates/automation.yaml
dest: /root/config/automations/{{ item.id }}.yaml
owner: root
group: root
mode: '0644'
with_items: "{{ trackers }}"
- name: Install HASS Trackers
hosts: localhost
vars_files:
- vars.yaml
tasks:
- name: Template Dashboard
template:
src: templates/dashboard.yaml
dest: "dashboard.yaml"

View File

@@ -1,167 +0,0 @@
Counters:
```yaml
days_since_litter_box_changed:
name: days_since_litter_box_changed
restore: true
initial: 0
step: 1
icon: mdi:cat
last_non_zero_days_since_litter_box_changed:
name: last_non_zero_days_since_litter_box_changed
restore: true
initial: 0
step: 1
icon: mdi:undo
```
Input Buttons:
```yaml
reset_days_since_litter_box_changed:
name: reset_days_since_litter_box_changed
icon: mdi:cat
undo_reset_days_since_litter_box_changed:
name: undo_reset_days_since_litter_box_changed
icon: mdi:undo
```
Automations:
```yaml
- alias: 'Counter: Increment days_since_litter_box_changed'
description: ''
trigger:
- platform: time
at: 00:00:00
condition: []
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.days_since_litter_box_changed
mode: single
- alias: 'Counter: Reset days_since_litter_box_changed'
description: ''
trigger:
- platform: state
entity_id:
- input_button.reset_days_since_litter_box_changed
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.days_since_litter_box_changed
mode: single
- alias: 'Counter: Update last_non_zero_days_since_litter_box_changed'
description: ''
trigger:
- platform: state
entity_id:
- counter.days_since_litter_box_changed
condition:
- condition: numeric_state
entity_id: counter.days_since_litter_box_changed
above: 0
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_litter_box_changed
mode: single
- alias: 'Counter: Reset last_non_zero_days_since_litter_box_changed'
description: ''
trigger:
- platform: numeric_state
entity_id:
- counter.days_since_litter_box_changed
above: 0
below: 2
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_litter_box_changed
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_litter_box_changed
mode: single
- alias: 'Counter: Undo Reset days_since_litter_box_changed'
description: ''
trigger:
- platform: state
entity_id:
- input_button.undo_reset_days_since_litter_box_changed
condition:
- condition: numeric_state
entity_id: counter.days_since_litter_box_changed
below: 1
action:
- service: counter.set_value
metadata: {}
data:
value: "{{ int(states('counter.last_non_zero_days_since_litter_box_changed'))}}"
target:
entity_id: counter.days_since_litter_box_changed
- service: counter.decrement
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_litter_box_changed
mode: single
```
Dashboard:
```yaml
title: REPLACE ME
type: grid
square: false
columns: 1
cards:
- type: grid
square: false
columns: 2
cards:
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.reset_days_since_litter_box_changed
show_state: true
name: Reset
- show_name: true
show_icon: true
type: button
tap_action:
action: toggle
entity: input_button.undo_reset_days_since_litter_box_changed
show_state: true
name: Undo
- type: grid
square: false
columns: 2
cards:
- type: entity
entity: counter.days_since_litter_box_changed
state_color: false
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_litter_box_changed
state_color: false
name: Last Value
- type: history-graph
hours_to_show: 72
entities:
- counter.days_since_litter_box_changed
```

View File

@@ -0,0 +1,39 @@
{% set trackers = [
{
"counter": states("counter.days_since_fridge_water_filter") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_fridge_water_filter", "upper"),
"percent": (int(states("counter.days_since_fridge_water_filter")) / state_attr("binary_sensor.threshold_for_days_since_fridge_water_filter", "upper")),
"name": "Fridge Water Filter Replaced"
},
{
"counter": states("counter.days_since_litter_boxes_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_litter_boxes_cleaned", "upper"),
"percent": (int(states("counter.days_since_litter_boxes_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_litter_boxes_cleaned", "upper")),
"name": "Litter Boxes Cleaned"
},
{
"counter": states("counter.days_since_cat_water_fountain_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_cat_water_fountain_cleaned", "upper"),
"percent": (int(states("counter.days_since_cat_water_fountain_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_cat_water_fountain_cleaned", "upper")),
"name": "Cat Water Fountain Cleaned"
},
{
"counter": states("counter.days_since_kitchen_cleaned") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_kitchen_cleaned", "upper"),
"percent": (int(states("counter.days_since_kitchen_cleaned")) / state_attr("binary_sensor.threshold_for_days_since_kitchen_cleaned", "upper")),
"name": "Kitchen Cleaned"
},
]%}
{% for tracker in (trackers | sort(reverse=true, attribute='percent')) %}
{% set days_left = ((tracker.threshold - tracker.counter) | int | string) %}
{% set message = tracker.name + " completed " + tracker.counter | string + " days ago. Due again in " + days_left + " days." %}
{% if tracker.percent > 1 %}
<ha-alert alert-type="error">{{ message }}</ha-alert>
{% elif tracker.percent > 0.8 %}
<ha-alert alert-type="warning">{{ message }}</ha-alert>
{% else %}
<ha-alert alert-type="success">{{ message }}</ha-alert>
{% endif %}
{% endfor %}

View File

@@ -0,0 +1,88 @@
- alias: 'Counter: Increment {{ item.id }}'
description: ''
trigger:
- platform: time
at: 00:00:00
condition: []
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.days_since_{{ item.id }}
mode: single
- alias: 'Counter: Reset {{ item.id }}'
description: ''
trigger:
- platform: state
entity_id:
- input_button.reset_days_since_{{ item.id }}
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.days_since_{{ item.id }}
mode: single
- alias: 'Counter: Update last_non_zero_days_since_{{ item.id }}'
description: ''
trigger:
- platform: state
entity_id:
- counter.days_since_{{ item.id }}
condition:
- condition: numeric_state
entity_id: counter.days_since_{{ item.id }}
above: 0
action:
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_{{ item.id }}
mode: single
- alias: 'Counter: Reset last_non_zero_days_since_{{ item.id }}'
description: ''
trigger:
- platform: numeric_state
entity_id:
- counter.days_since_{{ item.id }}
above: 0
below: 2
condition: []
action:
- service: counter.reset
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_{{ item.id }}
- service: counter.increment
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_{{ item.id }}
mode: single
- alias: 'Counter: Undo Reset {{ item.id }}'
description: ''
trigger:
- platform: state
entity_id:
- input_button.undo_reset_days_since_{{ item.id }}
condition:
- condition: numeric_state
entity_id: counter.days_since_{{ item.id }}
below: 1
action:
- service: counter.set_value
metadata: {}
data:
value: "{{ '{{' }} int(states('counter.last_non_zero_days_since_{{ item.id }}')) {{ '}}' }}"
target:
entity_id: counter.days_since_{{ item.id }}
- service: counter.decrement
metadata: {}
data: {}
target:
entity_id: counter.last_non_zero_days_since_{{ item.id }}
mode: single

View File

@@ -0,0 +1,12 @@
days_since_{{ item.id }}:
name: Days Since {{ item.name }}
restore: true
initial: 0
step: 1
icon: {{ item.icon }}
last_non_zero_days_since_{{ item.id }}:
name: Last Non-Zero Days Since {{ item.name }}
restore: true
initial: 0
step: 1
icon: mdi:undo

View File

@@ -0,0 +1,54 @@
type: grid
square: false
columns: 1
cards:
- type: markdown
content: >
{{ '{%' }} set trackers = [
{% for item in trackers -%}
{
"counter": states("counter.days_since_{{ item.id }}") | int,
"threshold": state_attr("binary_sensor.threshold_for_days_since_{{ item.id }}", "upper"),
"percent": (int(states("counter.days_since_{{ item.id }}")) / state_attr("binary_sensor.threshold_for_days_since_{{ item.id }}", "upper")),
"name": "{{ item.name }}"
},
{% endfor -%}
]{{ '%} ' }}
{% raw %}
{% for tracker in (trackers | sort(reverse=true, attribute='percent')) %}
{% set days_left = ((tracker.threshold - tracker.counter) | int | string) %}
{% set message = tracker.name + " completed " + tracker.counter | string + " days ago. Due again in " + days_left + " days." %}
{% if tracker.percent > 1 %}
<ha-alert alert-type="error">{{ message }}</ha-alert>
{% elif tracker.percent > 0.8 %}
<ha-alert alert-type="warning">{{ message }}</ha-alert>
{% else %}
<ha-alert alert-type="success">{{ message }}</ha-alert>
{% endif %}
{% endfor %}
{%- endraw %}
{% for item in trackers %}
- type: grid
square: false
columns: 2
title: Days Since {{ item.name }}
cards:
- type: button
name: Reset
entity: input_button.reset_days_since_{{ item.id }}
tap_action:
action: toggle
- type: button
entity: input_button.undo_reset_days_since_{{ item.id }}
name: Undo
tap_action:
action: toggle
- type: entity
entity: counter.days_since_{{ item.id }}
name: Days Since
- type: entity
entity: counter.last_non_zero_days_since_{{ item.id }}
name: Last Non-Zero
{% endfor %}

View File

@@ -0,0 +1,6 @@
reset_days_since_{{ item.id }}:
name: Reset {{ item.name }}
icon: {{ item.icon }}
undo_reset_days_since_{{ item.id }}:
name: Undo Reset {{ item.name }}
icon: mdi:undo

View File

@@ -0,0 +1,4 @@
- platform: threshold
entity_id: counter.days_since_{{ item.id }}
upper: {{ item.check_every }}
name: threshold_for_days_since_{{ item.id }}

41
hass_trackers/vars.yaml Normal file
View File

@@ -0,0 +1,41 @@
trackers:
- id: fridge_water_filter
name: Fridge Water Filter Replaced
check_every: 180
icon: mdi:fridge
- id: litter_boxes_cleaned
name: Litter Boxes Cleaned
check_every: 15
icon: mdi:cat
- id: cat_water_fountain_cleaned
name: Cat Water Fountain Cleaned
check_every: 7
icon: mdi:fountain
- id: kitchen_cleaned
name: Kitchen Cleaned
check_every: 7
icon: mdi:fridge
- id: kitchen_counters_cleaned
name: Kitchen Counters Cleaned
check_every: 7
icon: mdi:countertop
- id: living_room_cleaned
name: Living Room Cleaned
check_every: 7
icon: mdi:sofa
- id: upstairs_vacuumed
name: Upstairs Vacuumed
check_every: 14
icon: mdi:vacuum
- id: bathroom_counters_cleaned
name: Bathroom Counters Cleaned
check_every: 14
icon: mdi:bathtub
- id: bedroom_vacuumed
name: Bedroom Vacuumed
check_every: 14
icon: mdi:vacuum
- id: toilets_cleaned
name: Toilets Cleaned
check_every: 14
icon: mdi:toilet