I have following HA GUI option to allow me to choose where I would like to receive notifications.
I have this code in my utils module which is used by other AD apps. Following code works but though multiple destinations were set in UI, I get a notification sent to only one destination (whichever is first is set true/on) and the code won’t check for other destinations
def send_notify(self, entity, attribute, old, new, kwargs):
self.log("Updated Sensor value : new : {} old : {}".format(new,old))
notifyphone = self.get_state("input_boolean.notifyphone")
announce = self.get_state("input_boolean.announce")
frontend = self.get_state("input_boolean.notifygui")
self.log("NEW Announcement Flags : notifyphone : {} - announce : {} - notifygui: {}".format(notifyphone, announce, frontend))
if notifyphone == "on":
self.log("Notify Phone : {}".format(notifyphone))
self.call_service('script/notify_myphone', event='My_Home', value1=new)
if announce == "on":
self.log("Announcements value : {}".format(announce))
self.call_service('tts/google_say', entity_id='media_player.living_room_home', message=new)
if frontend == "on":
self.log("Frontend Value : {}".format(frontend))
self.call_service('persistent_notification/create',
title="Attention", message=new + datetime.now().strftime('@ %-I:%M %p') )
Any Python experts here who can figure out how to rewrite this so that it would send notifications based on input booleans that were in HA UI?
Thank you