Creating a plugin for Panasonic UB-820

I have a Panasonic UB-820 running modified firmware. One of the perks of the firmware is to allow unauthenticated control of the player via IP. I have a complete list of commands and testing them via curl from the command line works well. I’m new to JavaScript and Home Remote, so I’m hoping someone can provide a few tips to get started with creating a plugin for the device. The structure of the commands looks like this:

curl -A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWEROFF_CL.x=100 -d cCMD_RC_POWEROFF_CL.y=100 http://10.0.0.70/WAN/dvdr/dvdr_ctrl.cgi

How could I break this down into something Home Remote can use? Thanks so much!

Hi and welcome to the THR-Forum,

Plugins can be easily created with Copilot from Microsoft (you can find it in the Bing search engine). You only need a basic plugin (you can find it here in the forum or in the HR documentation) and enter the following question in Copilot:
I have a plugin for HomeRemote here: then the basic code.

Copilot analyzes the code and asks how it can help you.

Just describe what you would like to have. In your case I got the following result to this question:

I would like to create a new plugin for a Panasonic UB820 Blueray-Player, which can be controlled with curl. Here is an example command:
curl -A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWEROFF_CL.x=100 -d cCMD_RC_POWEROFF_CL.y=100 http://10.0.0.70/WAN/dvdr/dvdr_ctrl.cgi

and here the result:

plugin.Name = "Panasonic_UB820";
plugin.OnChangeRequest = onChangeRequest;
plugin.OnConnect = onConnect;
plugin.OnDisconnect = onDisconnect;
plugin.OnPoll = onPoll;
plugin.OnSynchronizeDevices = onSynchronizeDevices;
plugin.PollingInterval = -1;
plugin.DefaultSettings = { "Host": "10.0.0.70" };

var http = new HTTPClient();
var baseUrl;

var commands = {
    "PowerOff": "-A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWEROFF_CL.x=100 -d cCMD_RC_POWEROFF_CL.y=100",
    // Add more commands here
};

function onChangeRequest(device, attribute, value) {
    if (attribute != "MediaCommand")
        throw "Invalid attribute";

    var command = commands[value];
    if (!command)
        throw "Invalid command";

    console.log("sending=> " + baseUrl + command);

    http.post(baseUrl, command);
}

function onConnect() {
    baseUrl = "http://" + plugin.Settings["Host"] + "/WAN/dvdr/dvdr_ctrl.cgi";

    var mediaCenter = plugin.Devices["1"];
    if (mediaCenter != null) {
        mediaCenter.SupportedMediaCommands = Object.keys(commands);
    }
}

function onDisconnect() {
}

function onPoll() {
}

function onSynchronizeDevices() {
    var mediaCenter = new Device();
    mediaCenter.Id = "1";
    mediaCenter.DisplayName = "Panasonic UB820";
    mediaCenter.Capabilities = ["MediaControl"];
    mediaCenter.Attributes = [];
    plugin.Devices[mediaCenter.Id] = mediaCenter;
}

This plugin is designed to control a Panasonic UB820 Blu-ray player using curl commands.

  1. Plugin Name and Settings:
  • The plugin is named Panasonic_UB820.
  • It has a default setting for the host (10.0.0.70).
  1. HTTP Client:
  • An HTTP client is used to send requests to the host.
  1. Commands:
  • There are several commands that send different curl commands to control the device, such as turning it off.
  1. Functions:
  • onChangeRequest: This function sends the appropriate curl command based on the attribute and value.
  • onConnect: This function is called when the plugin is connected. It sets the base URL and initializes the supported commands.
  • onDisconnect: This function is called when the plugin is disconnected.
  • onPoll: This function is called to perform periodic tasks (currently empty).
  • onSynchronizeDevices: This function synchronizes the devices and adds a new device named “Panasonic UB820”.

Go to “Devices” in the HR-Designer (top left) and click on it with the right mouse button. Then select “Add Plugin → from code. Copy the plugin code into the window that opens.
Now you should have a new device with the name Panasonic UB820. Do a right mouse click at the Panasonic UB820 device and then a click on “Synchronize Device”.
You can add further commands to the plugin script.

2 Likes

Thank you so much! You’re response was exactly what I was hoping for. I look forward to getting this up and running.

You‘re welcome, it has taken only a few minutes to create your plugin.
Your question included all the needed information :wink:

Kalle

I finished adding the additional commands and setup the remote within the designer, but it looks like the commands aren’t working when they are sent via the remote. They do still work from the command prompt using curl though. The log window shows the command sending and the information looks correct for the respective buttons.

Panasonic_UB820.plugin (6.3 KB)
PanasonicUB820.xaml (63.2 KB)

Any idea what could be going wrong?

Running curl with the -vvv flag from terminal gives me:

C:\Users\Dana>curl -vvv -A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWEROFF_CL.x=100 -d cCMD_RC_POWEROFF_CL.y=100 http://10.0.0.70/WAN/dvdr/dvdr_ctrl.cgi
*   Trying 10.0.0.70:80...
* Connected to 10.0.0.70 (10.0.0.70) port 80
> POST /WAN/dvdr/dvdr_ctrl.cgi HTTP/1.1
> Host: 10.0.0.70
> User-Agent: MEI-LAN-REMOTE-CALL
> Accept: */*
> Content-Length: 51
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 51 bytes
< HTTP/1.1 200 OK
< Connection: close
< Server: Panasonic AVC Server/1.00
< X-MEI-RESULT: OK
< Content-Length: 70
< Content-Type: text/plain
<
00,"",1
F,,,00,00,,0,,,,0,000:00,,00:00,0,00:00,0000,0000,0000,0000
* Closing connection

With Wireshark, you can precisely see what kind of command is being sent over the network to the player. This allows you to analyze the differences between SSH and the app.

1 Like

Thank you. I’ll give this a try.

After looking at things in Wireshark, I’ve noticed the commands sent via Home Remote look like this:

        HTML Form URL Encoded: application/x-www-form-urlencoded
        Form item: "-A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWER_CL.x" = "100 -d cCMD_RC_POWER_CL.y=100"
        Key: -A MEI-LAN-REMOTE-CALL -d cCMD_RC_POWER_CL.x
        Value: 100 -d cCMD_RC_POWER_CL.y=100

While the commands sent via Windows look like this:

HTML Form URL Encoded: application/x-www-form-urlencoded
    Form item: "cCMD_RC_POWEROFF_CL.x" = "100"
        Key: cCMD_RC_POWEROFF_CL.x
        Value: 100
    Form item: "cCMD_RC_POWEROFF_CL.y" = "100"
        Key: cCMD_RC_POWEROFF_CL.y
        Value: 100

The Content-Type for Home Remote is set as application/x-www-form-urlencoded; charset=utf-8, while Windows is just application/x-www-form-urlencoded.

The “-A MEI…” part should be put in the Header and not in the Command part. So I added a variable to your plugin:

var httpOptions = {
    headers: {
    'User-Agent': "MEI-LAN-REMOTE-CALL",  // Equivalent to the -A curl flag
    'Content-Type': "application/x-www-form-urlencoded"  // Specifying the form type data
    }
};

Don’t know for sure if Content-Type is needed. Some documentation can also be found here: https://thehomeremote.com/docs/httpclient

Unfortunately I can’t test the plugin. I do have a Panasonic UB-820, but I don’t have the firmware modified.

Panasonic_UB820_v2.plugin (5.2 KB)

Thank you so much! Things are working as intended now. Thanks to you both. :slight_smile:

You’re welcome. Nice it works now. :slight_smile:

1 Like

thanks for take your time, good job :+1:

1 Like