Notifications flowchart

I’m going to start setting up some notifications for various things, and I want to send the notifications to different devices based on whether I’m at home or not, time of day etc. I was thinking about this and I realised that putting all those conditions in each automation seems a little inefficient.

So, what I was thinking was, if I came up with a flowchart for checking the conditions and then sending a notification to the correct media, could I do it all with one automation?

For example, instead of ending an automation with: “notify.pushbullet” could I end it with firing:

service: automation.notify 
  message: "..."

… and passing the notification text to that script as a parameter? Then the script could go through the flowchart, work out which notification to send, and send the text in the parameter?

The flowchart would be something like this (sorry for the crappy-ness!):

              Automation called with parameter $Notification
               -----------   Is anyone home?   ----------
              |                                        |
             Yes                                      No
             |                                         |
      ---Is Kodi on?                        send pushbullet with $Notification
     |             |
     |             |--------------------------------
     |                                             |
   Yes                                             No
     |                                             |
Send Kodi $Notification                            |
       -----------------Is it past 7pm?---------------
      |                                                     |
      |                                                     |
     Yes                                                    No
      |                                                     |
Is it 'bedtime'?                            Send TTS with $Notification to Whole house
|             |--------------------
|                                 |
Yes                            No------------------------------
|                                                              |
send pushbullet $notification                    Send TTS to Kitchen and bedroom only with $notification

Is this possible?  Has anybody done anything like this?


Thanks in advance for any input.

Have you considered app daemon? I know you can pass values with it. Also your flow chart might be easier to do in python.

1 Like

No, but I’ll take a look - cheers :thumbsup:

1 Like

This is possible with script and templating BUT I would too recommend AppDaemon for this.


1 Like

I personally use a custom python script for this and call the home assistant api to send the notification. You can use shell commands and pass it the message as a parameter for calling the python script.


Can you post/github/link the script and give a rough walk-through please?

Sorry wont be home for a while so cant give any code examples really.

But mine is a bit more basic. Just checks if my fire tv is on, if it is that will get a notification by default unless I specifically tell it not to. If my computer is on the same thing happens, and it will always send a notification to my phone by default.

I just pass the notification text and title to my script, the script uses the home assistant api to see what is on/off and then uses the api to send the notification(s) through a service call.

1 Like

The documentation on the python api actually is quite good. Take a look:


1 Like

I’ll have a look and give it a go! Thanks everyone :slight_smile: