I have a simple appdaemon app that will notify on a Tuesday to take out the trash.
Something simple to get started.
import hassapi as hass
import datetime
#App to send notification on day trash is to be taken outside
#Args:
#input_select: input select to identify trash day --not implemented
class TrashNotification(hass.Hass):
def initialize(self):
self.trashday = 'Tuesday'
self.currentday = datetime.datetime.today().strftime('%A')
runtime = datetime.time(7, 30,0)
self.run_daily(self.notifytrash,runtime)
def notifytrash(self, kwargs):
if self.trashday == self.currentday:
self.notify("🗑️️Dont forget to clean out all the bins.", title = "Trash day today!")
I havent implemented any arguments yet, just want to get the basics straight.
My questions are as follows:
1)Where is the correct place to define and assign my comparison variable currentday
?
As i understand is once initialized
is run once, until a callback is returned, the variables will remain with their values unchanged. So the currentday
variable will not be updated daily?
2)is self.run_daily
the best way to trigger a callback that will only run once a week?
Im only executing the notify if the day condition is correct, but maybe i could register the callback differently?
Looking through the documentation i cant see any better methods.
I hope ive explained my questions properly.
Thanks