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 https://gist.github.com/maxivak/18fcac476a2f4ea02e5f80b303811d5f
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.
eg
http://ipofyourrpi/folder/message.php?title=yourtitlehere&message=yourmessagehere&icon=youriconchoice
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
<?php
//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";
break;
default:
$fields["bkgcolor"] = "#607d8b";
break;
}
$fields["bkgcolor"] = "#ff0000";
*/
//change icon file
switch ($message_icon) {
case "warning":
$file = file_get_contents('http://servernameorip/notifications/warning.png');
break;
case "freezer":
$file = file_get_contents('http://servernameorip/notifications/freezer.png');
break;
case "fridge":
$file = file_get_contents('http://servernameorip/notifications/fridge.png');
break;
case "mail":
$file = file_get_contents('http://servernameorip/notifications/mail.png');
break;
default:
$file = file_get_contents('http://servernameorip/notifications/notification.png');
break;
}
//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_RETURNTRANSFER => 1,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
//CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $post_data,
CURLOPT_VERBOSE => true,
CURLOPT_HTTPHEADER => array(
//"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']}";
//print_r($info['request_header']);
//var_dump($response);
//$err = curl_error($curl);
//echo "error";
//var_dump($err);
curl_close($curl);
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";
?>