There is no need to introduce the great home automation software Domoticz and I wrote already some blog posts about it. Today I pushed a pull request to the Domoticz GitHub to add two features I was missing :

Panasonic remote buttons

It adds customizable buttons to the default remote for Panasonic TVs:

The buttons are customizable in the Panasonic hardware settings:

To be able to use codes that are not known by the plugin there is an option to allow sending unknown commands. There is basic sanitization but as it may cause a security issue there is also a setting to allow or not this behavior.

URL in Custom menu

It adds the possibility to include URLs in the custom template menu:

To do so, just create a file per URL in the www/templates folder with:

  • ‘url’ extension
  • the title of the link as filename
  • the URL as file contents

The easiest way to benefit from these two functions is to way for integration in the next version. But if you are impatient, you can build it on your own following the Domoticz documentation about building from source

The PR is here: https://github.com/domoticz/domoticz/pull/4531
My forked repo with the PR already available: https://github.com/rpeyron/domoticz/ (branch rp-dev-bk20201223)

Basic UPnP protocol and PHP scripts

And if like me, you are struggling for making clean PRs, the article that saved me: (stackoverflow) cleanup git master branch and move some commit to new branch

I lost a lot of time fighting with Panasonic UPnP protocol and finding new applications product id. I first tried to spy with Wireshark the messages from the Panasonic TV Remote 2 android application, but I only saw TLS messages with an outside server. While writing this post I realize that even on LAN the application may use my Panasonic TV Anywhere account and I should try again with disabling the account. Then I tried to send UPnP with cURL and RESTed chrome extension but it seems that all these tools add unwanted headers and Panasonic’s implementation of UPnP protocol seems to be very badly sensitive about that. I finally found that PHP script that I customized to explore the UPnP API, and after a bit of reverse engineering I finally found the X_GetAppList command. Below is a PHP script to get the product_id of the applications available on your Panasonic SmartTV :

<?php
$operation = "X_GetAppList";

$input = "\n";
$input .= "\n";
$input .= "\n";
$input .= "<u: xmlns:u="\"urn:panasonic-com:service:p00NetworkControl:1\"">\n";
$input .= "\n";
$input .= "</u:>$operation>\n";
$input .= "\n";
$input .= "\n\n";

$header = array(
"Content-type: text/xml;charset=\"utf-8\"",
"Accept: text/xml",
"Cache-Control: no-cache",
"Pragma: no-cache",
"SOAPACTION: \"urn:panasonic-com:service:p00NetworkControl:1#$operation\"",
"Content-Length: ".strlen($input),
);
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://192.168.0.43:55000/nrc/control_0');
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $input);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  if(($result = curl_exec($curl)) === false) {
    $err = 'Curl error: ' . curl_error($curl);
    curl_close($curl);
    print $err;
  } else {
    curl_close($curl);
    print 'Operation completed without any errors';
	print $result;
  }
?>

If you want more information about how I “reverse-engineered” this code (and some other UPnP scripts), I wrote another post on it (in french, but there is a “Google translate” button on the right 🙂 )