Custom Notifications for Fire TV via HTTP


1) Give a description of the problem
I’m trying to send custom notifications to Amazon Fire TV. I install the App Notifications for Fire TV on the Fire Tv stick. I’m basing the piston using the solution for Homeseer and Home Assistant, but I having difficulties to arrange the variables with the correct Webcore syntax for curl.
This is the code section form Homeseer, Hope you can help me. Tnx

2) What is the expected behaviour?
Using HHTP Post to send the custom message to the Fire TV port 7676.

3) What is happening/not happening?
I can confirm that the APP “Notifications for Fire TV” is reciving the POST form Webcore but only showing a empty Toast Notification.

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full


It looks like you are sending JSON but the example is FORM encoded. I’d imagine it is intended that you define variables like ‘force’ and ‘filename’ and add those to ‘Send Variables’ with the content set to FORM.


Thanks @orangebucket for notice that.
I change the request type with FORM, Im using PUT and the information still is missing.
I’m still trying. Tnx

P.S. I’m using PUT because when try with POST doesn’t Show the blank notification.


I have had good luck testing with

Hit that with your curl statement for a known template then adjust your piston configuration until it is the same. Then go back to your private IPv4 address.


Thanks @Bloodtick_Jones for the link, awesome tool!

I inspect the traffic from my android APP , and I notice that App uses a custom html boundary “SwA1592325033828SwA” maybe here is the problem.
It’s posible to send custom boundary in webcore?

Here the header an part of the Form:

Authorization: Basic Og==
Connection: Keep-Alive
Content-Type: ; boundary=SwA1592325033828SwA
User-Agent: Dalvik/2.1.0 (Linux; U; Android 6.0; xxxxx Build/MRA58K)
Accept-Encoding: gzip
Content-Length: 2946

Content-Type: text/plain
Content-Disposition: form-data; name=“type”



I know this is an old topic but I’m posting this in case it’s useful for someone else - this thread shows up when trying to get Notifications for FireTV to work with custom messages.

There is a Home Assistant module for this, I don’t use home assistant, but have instead written a php script based on the code found here

My php script sits on a RPi and receives input parameters via GET for the message title, message body and icon - I can do this manually, or via a node-red flow.

The rpi then sends the request to my firestick to get the message to display on the TV - the icons I use sit in the same webfolder as the php script

As I say, this may be of use to someone else trying the same thing without HA

Regards RSP


//get the input data

if (isset($_GET["title"])) {
    $message_title = filter_var(urldecode($_GET["title"]), FILTER_SANITIZE_STRING);
} else {
    $message_title = "Notification";
if (isset($_GET["message"])) {
    $message_body = filter_var(urldecode($_GET["message"]), FILTER_SANITIZE_STRING);
} else {
    $message_body = "Hello World";
if (isset($_GET["icon"])) {
    $message_icon = filter_var(urldecode($_GET["icon"]), FILTER_SANITIZE_STRING);
} else {
    $message_icon = "default";

//title     = notification title
//msg       = message body text
//duration  = time in seconds for message to be shown
//transparency = 0 transparent/ 1 solid

// default data fields for POST request
$fields = array("title" => "Notification", "msg" => "Hello World", "duration" => "10", "fontsize" => 0,     "position" => 0, "width" => 0, "bkgcolor" => "#607d8b", "transparency" => 1, "offset" => 0, "offsety" => 0,     "app" => "Notifications for Fire TV", "force" => true);

//populate with our message
$fields["title"] = $message_title;
$fields["msg"] = $message_body;

//change background depending on message type
switch ($message_type) {
    case "Warning":
        $fields["bkgcolor"] = "#ff0000";
        $fields["bkgcolor"] = "#607d8b";
$fields["bkgcolor"] = "#ff0000";

//change icon file
switch ($message_icon) {
case "warning":
        $file = file_get_contents('http://servernameorip/notifications/warning.png');
case "freezer":
        $file = file_get_contents('http://servernameorip/notifications/freezer.png');
case "fridge":
        $file = file_get_contents('http://servernameorip/notifications/fridge.png');
case "mail":
        $file = file_get_contents('http://servernameorip/notifications/mail.png');
        $file = file_get_contents('http://servernameorip/notifications/notification.png');

//firestick IP
$url = "http://ipoffirestickgoeshere:7676";

// curl
$curl = curl_init();

$url_data = http_build_query($fields);

$boundary = 'SwA1592325033828SwA';
$delimiter = '' . $boundary;

$post_data = build_data_files($boundary, $fields, $file);

curl_setopt_array($curl, array(
    CURLOPT_URL => $url,
    CURLOPT_POST => 1,
    CURLOPT_POSTFIELDS => $post_data,
    CURLOPT_VERBOSE => true,
//"Authorization: Bearer $TOKEN",
//    "Authorization: Basic 0g==",
        "Connection: Keep-Alive",
        "Content-Type: multipart/form-data; boundary=" . $delimiter,
//    "Accept-Encoding: gzip",
        "Content-Length: " . strlen($post_data)

$response = curl_exec($curl);

$info = curl_getinfo($curl);
//echo "code: ${info['http_code']}";
//$err = curl_error($curl);
//echo "error";

function build_data_files($boundary, $fields, $file) {
    $data = '';
    $eol = "\r\n";

    $delimiter = '' . $boundary;

    //add the fields
    foreach ($fields as $name => $content) {
        $data .= "--" . $delimiter . $eol
                . 'Content-Type: text/plain' . $eol
                . 'Content-Disposition: form-data; name="' . $name . "\"" . $eol . $eol
                . $content . $eol;

    //add the image
    $data .= "--" . $delimiter . $eol
            . 'Content-Disposition: form-data; name="filename"; filename="icon.png"' . $eol
            . 'Content-Type: application/octet-stream' . $eol
            . 'Content-Transfer-Encoding: binary' . $eol

    $data .= $eol;
    $data .= $file . $eol;

    $data .= "--" . $delimiter . "--" . $eol;

    return $data;

echo "Done";