For a while I’ve been trying to find a way to send notifications to my Fire TV devices. Kodi is not always open, so that is not a good option. The best I found is an app, Notifications for Fire TV/Notifications for Android TV. It’s primary purpose is to mirror notifications received on an Android phone. I thought this was out as well since it would be a kludgy solution requiring extra hardware. Then I stumbled upon this Go command line app made to do exactly what I wanted.
This was tested with on Ubuntu 16.04 with a 1st and 2nd gen Fire TV box.
Install Go. I used this guide with the latest stable version of Go. Only complete the first step at this point. We will set up the paths a little different.
Rather than setting the Go path in my local ~/.profile, I set them in a new file at /etc/profile.d/nfa.sh so they would be available for all users. This is probably not necessary because OpenHAB still does not pick up the path and we will have to use the full path to the executable. We will need to use a different path for the workspace, however, due to where the nfa app expects the workspace to be.
Set the paths as follows. You will need to log out and back in to pick up the changes.
You can also parameterize more of the flags if you wish, but you will need to be careful since shell scripts take parameters based on position rather than name.
#!/bin/bash
# default message time if none is specified
time=5s
# if a time is specified, override the default
if [ ! -z "$2" ]
then
time="$2"
fi
~/go/bin/nfa notify -a 10.0.0.90 -t "OpenHAB" -m "$1" -d $time -o top-right
~/go/bin/nfa notify -a 10.0.0.91 -t "OpenHAB" -m "$1" -d $time -o top-right
Just wanted to say thanks a bunch for your detailed write up. I spent a good few hours tonight getting this to work on nub synology NAS with a Nvidia Shield, but wouldn’t have been that quick without this article.
thanks for this great tutorial. I’ve set it up quite easily with that. It also works quite well if I execute the notification via terminal but not in openhab.
my script at /etc/openhab2/scripts/sh/notifyAndroitTV_2.sh:
Everything works as expected. But if I want to run it via openhab, the second word seems to be passed as a second argument and i also see the ". I just see this on the Shield TV:
"Word1
This is my rules file:
rule "Test"
when
Item CC_JBL_Mute changed from OFF to ON
then
executeCommandLine("/etc/openhab2/scripts/sh/notifyAndroitTV_2.sh 'Word1 Word2' ")
end
The issue reported here where people can make the notifications work from the command line but not from their rule has to do with how the the “executeCommandline” command needs to separate the command from its arguments. If you see here, you need to place @@ in place of spaces:
So when passing the command as originally in this tutorial, it will never work because OH is trying to execute the whole thing as a command.
#!/bin/bash
# default message time if none is specified
time=10s
# if a time is specified, override the default
if [ ! -z "$2" ]
then
time="$2"
fi
/home/openhabian//work/bin/nfa notify -a 192.168.1.x -i /etc/openhab2/icons/classic/oh.jpg -o top-right -t "OpenHAB" -m "$1" -d "$time"
Really - if you look on this forum - there are tons of times where people can execute from command line and not from the rule. It is almost always either a permission issue or this @@ nomenclature. I’ve known this for a long time and I still get it wrong all the time. It always takes some playing with it to get it right.
Thanks for your input. Sadly this still doesn’t work for me.
my rules file
rule "notify"
when
Item notify changed from OFF to ON
then
executeCommandLine("/etc/openhab2/scripts/sh/notifyAndroitTV.sh@@Your message.@@10s")
end
My sh file:
#!/bin/bash
# default message time if none is specified
time=10s
# if a time is specified, override the default
if [ ! -z "$2" ]
then
time="$2"
fi
~/go/bin/nfa notify -a 192.168.0.24 -o top-right -t "OpenHAB" -m "$1" -d "$time"
With openHab 2.5 notifications work fine for me. My rules file:
rule "notify"
when
Item notify changed from OFF to ON
then
val tel01 = "Part1" + " " + "Part2" + " " + "Part3"
executeCommandLine("/etc/openhab2/scripts/sh/notifyAndroitTV.sh@@" + tel01 + "@@10s")
end
notifyAndroitTV.sh script file:
#!/bin/bash
# default message time if none is specified
time=10s
# if a time is specified, override the default
if [ ! -z "$2" ]
then
time="$2"
fi
/var/lib/openhab2/go/bin/nfa notify -a 192.168.0.24 -o top-right -t "OpenHAB" -m "$1" -d "$time"
I installed openhab 4.1 on raspbian bullseye 11 on a new sd card and now I want to configure nfa but for some reason I can’t see notifications on android TV.
for testing, in ssh i enter the command: ~/go/bin/nfa notify -a 192.168.0.129 -t “OpenHAB” -m “$1” -d 5s -o top-right
I do get a message back:
notification sent to 192.168.0.129
What could it be?
There is a binding for doing this in the marketplace now, see here:
In case anyone is interested, the go command line app appears to no longer work with the latest versions of go. I hit a number of hurdles when trying to get this going and after fixing a number of them it still would not install with the latest GO, so my guess is that installing an old go version probably would still work or this method needs updating. The go app was last updated 7 years ago!! So no surprise. The good news is that the binding makes it so much more simple to do and supports more then 1 way so that if 1 way gets neglected by a dev, another way should still work.