Monoprice Projector Screen Plugin

Attached is a Plugin for a Monoprice Motorized Projector Screen. It’s compatible with part numbers 7337, 7338, 7951, 30451, 30452, 30453
https://www.monoprice.com/product?p_id=30453

This setup also requires an IP to Serial converter so it can be controlled over a standard network connection. You can use a product like the Global Cache IP2SL.
https://www.globalcache.com/products/itach/ip2slspecs/

To install the plugin, use the Plugin Import utility in the Designer. The import process will ask you for the IP Address & Port of the IP to Serial converter. The default port for Global Cache serial converters is port 4999.

Here is the plugin code:
MonopriceProjectorScreen.plugin (1.4 KB)

plugin.Name = "MonopriceProjectorScreen";
plugin.OnChangeRequest = onChangeRequest;
plugin.OnConnect = onConnect;
plugin.OnDisconnect = onDisconnect;
plugin.OnPoll = onPoll;
plugin.OnSynchronizeDevices = onSynchronizeDevices;
plugin.PollingInterval = -1;
plugin.DefaultSettings = { "Host": "192.168.1.100", "Port": 4999 };

var deviceId = "1";
var socket = new TCPClient();

var commands = {
    "ScreenUp": [0xFF, 0xEE, 0xEE, 0xEE, 0xDD],
    "ScreenStop": [0xFF, 0xEE, 0xEE, 0xEE, 0xCC],
    "ScreenDown": [0xFF, 0xEE, 0xEE, 0xEE, 0xEE],
}

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

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

    socket.send(command);
}

function onConnect() {
    socket.connect(plugin.Settings["Host"], parseInt(plugin.Settings["Port"]));

    var device = plugin.Devices[deviceId];
    if (device != null) {
        device.SupportedMediaCommands = Object.keys(commands);
    }
}

function onDisconnect() {
    socket.close();
}

function onPoll() {
}

function onSynchronizeDevices() {
    var device = new Device();
    device.Id = deviceId;
    device.DisplayName = "Projector Screen";
    device.Capabilities = ["MediaControl"];
    device.Attributes = [];
    plugin.Devices[deviceId] = device;
}