jcallaghan / home-assistant-config

My Home Assistant configuration & documentation.
https://www.jcallaghan.com/
MIT License
175 stars 8 forks source link

Smoke alarm batteries changed chore tracker 🔥🔋📅 #220

Closed jcallaghan closed 4 years ago

jcallaghan commented 4 years ago

Create two new input_datetime entities to record when I last changed my Nest smoke alarm batteries. This evening my cast iron pan got the better of me and triggered my Nest smoke alarms. I caught the warning but apparently the smoke was too much and the siren went off. Shortly after silencing the alarms, they both started beeping periodically to indicate their batteries were low.

I'll create an automation to remind me to check the batteries every three months and to change them each year. I think I haven't changed them in two years.

jcallaghan commented 4 years ago

HomeAssistant input_datetime integration documentation - https://www.home-assistant.io/integrations/input_datetime/

Home Assistant
Input Datetime
Instructions on how to integrate the Input Datetime integration into Home Assistant.
adonno commented 4 years ago

I guess them beeping at you isn't enough to remind you to change the battery ? :-)

jcallaghan commented 4 years ago

I guess them beeping at you isn't enough to remind you to change the battery ? :-)

This time around it was fine. But I'd rather not have low batteries in them when I actually need them.

Until Nest becomes available there is no harm in a subtle reminder to check them. I've been positioned once before by carbon dioxide and let's just say it wasn't very nice at all. Home Assistant always has my back so what are a couple more basic chores.

It will be great when we can integrate with devices again and I will be able to leverage my low battery automation #60.

jcallaghan commented 4 years ago

input_datetime fields created #221, just the notification reminder automation now.

image

jcallaghan commented 4 years ago

Templating.

Date time: {{ as_timestamp(states.sensor.date_time.last_changed) }}
Now: {{ as_timestamp(now()) }}

Chore timestamp attribute: {{ state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') }}
vs state: {{ as_timestamp(states('input_datetime.chore_nest_upstairs_batteries_last_changed')) }}

Seconds in 90 days (3 months): {{ (60*60*24)*90 }}
Seconds in a minute x by minutes in an hour x by hours in a day x by 90 days.

90 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*90) }}
180 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*180) }}
270 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*270) }}
360 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*360) }}
450 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*450) }}
540 days have passed: {{ as_timestamp(states.sensor.date_time.last_changed) >= (state_attr('input_datetime.chore_nest_upstairs_batteries_last_changed','timestamp') + (60*60*24)*540) }}
Date time: 1594594981.055409
Now: 1594594985.088987

Chore timestamp attribute: 1594508400.0
vs state: 1594508400.0

Seconds in 90 days (3 months): 7776000
Seconds in a minute x by minutes in an hour x by hours in a day x by 90 days.

90 days have passed: False
180 days have passed: False
270 days have passed: False
360 days have passed: False
450 days have passed: False
540 days have passed: False

image

jcallaghan commented 4 years ago

HomeAssistant binary_sensor integration documentation - https://www.home-assistant.io/integrations/binary_sensor/ and https://www.home-assistant.io/integrations/binary_sensor.template/

Home Assistant
Binary Sensor
Instructions on how-to setup binary sensors with Home Assistant.
Home Assistant
Template Binary Sensor
Instructions on how to integrate Template Binary Sensors into Home Assistant.
jcallaghan commented 4 years ago

In the end, I created a template binary_sensor which is 'on' if the time elapsed since the batteries were changed falls into one of the days passed as shown above. This binary_sensor triggers an automation the reminds me to test/check the smoke alarms.

jcallaghan commented 4 years ago

Persisting alerts

I could create an input_boolean and use an automation to turn this on when the template binary_sensor is turned on. Then these notifications/alerts could persist until the input_boolean is turned off through an actionable alert for example.