Reminder Custom Component

I made a custom component to help me remember to change my AC filter and thought I’d share it. This component’s state will be True when the specified number of days have passed, otherwise False.

https://github.com/aneisch/home-assistant-config/blob/master/custom_components/sensor/date_reminder.py

sensor.yaml:

- platform: date_reminder
  name: AC Filter Change
  #Date last done/changed
  date: "02-06-2017 00:00"
  #When to remind me in days
  day_reminder: 60

automation.yaml:

- alias: "Change AC Filter Notification"
  initial_state: on
  trigger:
    platform: state
    entity_id: sensor.ac_filter_change
    to: 'True'
  action:
    service: persistent_notification.create
    data_template:
      message: "It's been {{ states.sensor.ac_filter_change.attributes.days }} days since the AC filter was last changed"
      title: "Time To Change AC Filter!"
14 Likes

I appdaemonized these notification automations:

countdown_notify.py:

import appdaemon.appapi as appapi

"""
Notifies the specified notifier on
the days you specify.
"""

class Notify(appapi.AppDaemon):
  def initialize(self):
    if "countdown_entity" in self.args:
      self.listen_state(self.evaluate_notice, self.args["countdown_entity"])

  def evaluate_notice(self, entity, attribute, old, new, kwargs):
    days_remaining = self.get_state(entity, "days_remaining")
    entity_friendly_name = self.get_state(entity, "friendly_name")

    if type(self.args["notification_days"]) == int:
      notification_days = [self.args["notification_days"]]
    else:
      notification_days = [int(day) for day in self.args["notification_days"].split(",")]

    if days_remaining in notification_days:
      self.send_notice()
    elif self.args["notify_overdue"] and days_remaining < 0:
      self.send_notice()

  def send_notice(self):
    self.log("Sending notification")
    self.call_service("notify/" + self.args["notify"], message = self.args["message"])
    self.call_service("persistent_notification/create", message = self.args["message"])

appdaemon.yaml:

Brita Notification:
  module: countdown_notify
  class: Notify
  countdown_entity: sensor.brita_filter_change 
  notification_days: 0 #A mandatory list of when to notify, can be 1 or more value, eg: 1,2,7,30
  notify_overdue: True #An optional argument, if true we will continue to notify after 0
  notify: home_assistant #The name of the notify service
  message: "It's time to change the Brita filter!"
2 Likes

Is it somehow possible to have input text for this reminder ? don’t wanna write in appdaemon the dates and times … or how does it work there?

1 Like

Sorry for the delayed reply. The dates are input to the sensor in home assistant. The reminders are the only thing Appdaemon handles.