if you are using appdaemon you maybe also want to send some notifies sometimes.
and for that we normally have 2 options:
- self.notify(“blabla”,name=“a_notifier”)
- self.call_service(“notify/a_notifier”,message=“blabla”)
they are both easy to use, and you can even create a general function in a general app to do more then that.
but then you need to import that general function or use self.get_app(“general_functions”)
so you can probably call that the 3th option.
i thought of a 4th option to use.
i created a sensor for notifies. and an app to go with that.
import appdaemon.appapi as appapi
class notify(appapi.AppDaemon):
def initialize(self):
self.set_state("sensor.notify_message",state=" ")
self.listen_state(self.send_notify,"sensor.notify_message")
def send_notify(self, entity, attribute, old, new, kwargs):
self.call_service("notify/pushetta",message=new)
self.log(new)
... do any action you like when a meassage is send, send messages to several notifiers
... use tts to hear the message, translate the message, anything you can think off
you probably think: “hmm, why use that?” or maybe “how would i use that?”
very simple in every app you can now use:
self.set_state("sensor.notify_message", state="blabla")
just 1 line and if you are gonna use another notifier? just edit the notify app and not all the app you created.
extra bonus: in your HA frontend you can always see your last notify.
want in in a dashboard? just put the sensor in the dashboard and you always directly can see what the last notify was.
is 1 type not enough?
create as many notify functions as you like by just changing the sensor name.
do you find it confusing that its a sensor? call it my_notify.message
i hope this gets your brain going.