The MyURemote solution consists of
First we need to clarify some of the terms we will be using.
A device is what you want to control : a TV, blu-ray player. It can also be more complex : a home cinema system, or even a complete domotics system.
An extender is used to extend your smartphone's capabilities. A smartphone can normally only use network traffic. An extender allows you to translate this network traffic into other types of signal, such as infrared, serial, … GlobalCaché is one such type, but there exist other types as well, such as iTrans. MyURemote can currently only communicate with a GlobalCaché extender.
A protocol defines how we need to communicate with a device to send commands. Examples of protocols are
Some devices support multiple protocols, e.g. the Philips line of devices support both ir and rest protocols.
It is important to know the protocol, because the commands you need to send will be totally different !
The front end is a web page, containing buttons, input fields, and whatever kind of widgets you like. The web page is displayed inside a browser (on PC) or a web view component (on Android and iOS devices). You interact with the web page through clicks or by touching the screen. These events are handled by javascript functions.
In our view, these javascript functions still belong to the presentation layer. However, they make calls to the underlying MyURemote javascript library.
Different devices have different needs, although these needs are sometimes comparable. For example, most of the devices will need a keypad, a navigation component, a play component (play, pause, stop, …), a power button, menu items, info buttons, color buttons, …
But often, there will be slight differences, e.g. the ok button in a navigation component may be missing, or 2 additional buttons can be used next to the “0” of a keypad, …
This lends itself well to a widget like approach. For each device: specify which widgets need to be shown. This approach is used (in a perhaps poor way), in the demo site.
In the demo site, almost all devices use the same standard.html pagelet. This pagelet contains multiple versions of the same component (e.g. a keypad with 10 buttons, a keypad with 12 buttons, …). Lets call these widgets or components. Each widget gets a unique name.
In the configuration, we can specify which widgets or component need to be displayed. All non-specified widgets are hidden.
The components to show are defined as an array of component names in the client_config javascript object. See Client Configuration.
Different devices may have different command names for the same or a comparable action. If you want to use the same layout (e.g. using widgets), the event handler should not rely too much on the name of the commands. Thereto I have defined aliases. The web page defines event handlers, and these event handlers use generic command names. By using aliases in the client configuration, these generic commands can be linked to specific commands for a device.
The aliases are defined as a parameter for a device in the client_config javascript object. See Client Configuration. As an example, the same power button (or the same widget) may be used for the following devices. Between parentheses the corresponding command name
In the widget, the command fired when the event is triggered, is OO_1. In the client_config, this OO_1 is defined as alias for SLEEP, STANDBY, ONOFF respectively.
The MyURemote Javascript consists of a number of classes that know how to communicate with the MyURemote app on your smartphone or PC. The type of communication depends on the protocol that is supported by your devices (TV, blu-ray player, home cinema system).
The Javascript library consists of
The object devices (in file devices.js) contains the command definitions for all known devices. The devices object is a map of objects, in the format :
var devices = { "deviceName" : { // a list of technologies, either "ir", "serial", "rest" // each technology is optional. In some cases, only one technology will be available "ir" : { // a list of command names and command strings for ir communication // the commandString is the String that needs to be sent to the device "command1":"commandString1", "command2":"commandString2", ... }, "serial" : { // a list of command names and command strings for serial communication // the commandString is the String that needs to be sent to the device ... }, "rest" : { "methods" : { "method_name" : { "type" : "<http type>", // POST or GET "path" : "<the request path>", "parameters" : <array of parameter names> }, ... } // a list of command names and command parameters for rest communication using the post method "method" : { "method" : "<method_name>", "parameters" : <array of parameter values>}, ... } } }
Note that the structure for rest commands is slightly different than the structure for ir or serial commands.
Here are some examples (the complete file can be downloaded from ../js/devices.js
var devices = { "Panasonic BDT-DMP110" : { "ir" : { "ONOFF":"1,36000,1,1,127,62,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,48,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,48,16,48,16,48,16,48,16,16,16,16,16,48,16,16,16,48,16,48,16,16,16,16,16,16,16,48,16,720", "1":"1,37000,1,1,127,63,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,48,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,48,16,16,16,48,16,740", ... } } }
var devices = { "BOSE Main" : { "serial" : { "ONOFF":"\x0B\x00\x01\x04\x4C\x01\x64\x00\x00\x00\x27", "ON":"\x0B\x00\x01\x04\x8C\x01\x64\x00\x00\x00\xE7", "OFF":"\x0B\x00\x01\x04\xCC\x01\x64\x00\x00\x00\xA7", "ALLOFF":"\x0B\x00\x01\x04\xF7\x01\x64\x00\x00\x00\x9C", "MUTE":"\x0B\x00\x01\x04\x01\x01\x64\x00\x00\x00\x6A", ... } } }
var devices = { "Philips 2k11" : { "rest" : { "methods" : { "input" : { "type" : "POST", "path" : "/1/input/key", "parameters" : ["key"] } }, "STANDBY" : { "method" : "input", "parameters" : ["Standby"] }, "BACK" : { "method" : "input", "parameters" : ["Back"] }, "FIND" : { "method" : "input", "parameters" : ["Find"] }, ... } }
The devices contain the commands for a particular device. These commands are generic, independent of the configuration. In practice, a configuration must be defined. This configuration lists the devices for a particular client (or end-user), and the parameters for each device in this configuration, i.e.
The client configuration is available in the file client_config.js, and defines the following variables and objects :
var gatewayUrl = "http://localhost:9090/myuremote";
/* * The extenders object is a map of extender names and the corresponding extender instances * Syntax : * var extenders = { * "name" : extender * } * * where extender is an instance of a specific extender type * extender = new extenderConstructor({parameters}) */ var extenders = { "gc1" : new gc({ ip : "192.168.0.20", port : 4998 }), "rest1" : new rest({ "ip" : "192.168.0.21", "port" : 1925 }), "own1" : new own({ "ip" : "192.168.0.103", "port" : "20000" }) };
This is an object containing the parameters of the devices as found in your real setup. For each device (meaninglessly named as device_i), we define
Below is an example.
/* * The definition of the devices in the user's configuration. * For each device, we specify * label : a name to display in the web page * type : the device type as defined in the devices object * extender : the name of the extender (in the extenders object) that is used to communicate with the device * extenderParams : specific parameters to pass to the extender when executing a command * components : visual components that should be displayed in the web page. Corresponds to the name of a widget in a widget based web page * aliases : map of aliases for the different commands. This means that the command can be triggered through its name or through its alias. This is used because different devices may have different names for the same action. */ var client_devices = {
device_1 : { label : "Tv", type : "Philips 2k11", extender : "rest1", extenderParams : { callback: false }, components : [ "onoff_1", ... ], aliases : { "OO_1" : "STANDBY", "N_HOME" : "HOME", ... } }, device_2 : { label : "Blu-Ray", type : "Panasonic BDT-DMP110", extender : "gc1", extenderParams : { module : "ir2", callback: true }, components : [ "onoff_2", ... ], aliases : { "OO_1" : "OPENCLOSE", "OO_2" : "ONOFF", ... } },
The MyURemote App is used for two purposes :
The app allows to set the following parameters :
A http request to the MyURemote local server is formed as follows :
http://localhost:<local server port>/myuremote?ip=<extender ip address>&port=<extender port>&command=<command>&callback=<callbackName>
The syntax is taken care of by the corresponding base class. Note the port : normally, the local http server is running on port 9090. If your local http server is running on a different port, the url must be adjusted.
The command parameter is mandatory, the other parameters are optional.
The Global Caché Ethernet Gateway is a device that allows you to send commands over ip, and translate them into serial, infrared or relay signals.
See http://www.globalcache.com/.
Global Caché is manufacturer of several types of devices
We support Philips Televisions through the Jointspace protocol, version 2k11. The list of supported devices is available at the Jointspace website. See Sample 4 to test your television.
Supported Panasonic Devices
There are 2 protocols. One is for older systems (like Lifestyle 48,38,28,V30,V20). The other is for newer systems. Communication uses the serial port of a GlobalCaché GC-100 or iTach device.
See bTicino Configuration for details.
Other devices can be controlled through infrared, if used together with a GlobalCaché ethernet gateway (GC-100 or iTach with ir ports). Native protocols will be added in the future.