upb-cli
A CLI interface to the UPB library that generates decodes UPB (Universal Powerline Bus) commands. If you are looking for the NodeJS library version of this, then please see node-upb.
This has only been tested with Simply Automated switches! While probably won't harm your device (it is sending control commands, not core commands), I'm not sure what will happen when this is used with other branded switches (like PCS).
Installation
Install it globally:
$ npm install -g upb-cli
Or install it locally:
$ npm install upb-cli
Usage
If you plan on making your own serial implementation using this, remember to put the PIM in message mode first and to proceed each UPB command with the ASCII #20 character and to end it with the ASCII #13 character.
$ upb-cli [options]
Output of --help
:
$ upb-cli --help Usage: upb-cli [options] Options: -h, --help output usage information -V, --version output the version number -e, --generate Generates a UPB command and outputs the command or JSON. Use with all other arguments but --decode and --listCommands. This is on by default
Examples
-
Generate: Device #4 on network 21 go to 75% brightness in 3 seconds, send this command 2 times, and output full JSON:
$ upb-cli --generate --net 21 --id 4 --type device --cmd goto --level 75 --rate 3 --sendx 2 --json -
Generate: Activate link #5 on network 0 (all devices) and send to serial port COM1 (Windows serial port with PIM connected):
$ upb-cli -e -n 0 -i 5 -t link -c 20 --send -p COM187000005FF2055 -
Generate: Toggle (like blink but with a maximum amount of times to blink) device #3 on network 67 six times every 5 seconds and send to serial port with debug messages /dev/ttyS0 (Linux/Mac OSX serial port with PIM connected) and output stringified JSON:
$ upb-cli -e -n 67 -i 3 -t device -c toggle -g 6 -a 5 --json --jsonStringify --debug --send -p /dev/ttyS0{"source":255,"sendx":1,"ackPulse":false,"idPulse":false,"ackMsg":false,"powerlineRepeater":false,"action":"generate","sendTime":1,"network":"67","id":"3","type":"device","cmd":"toggle","toggleCount":"6","toggleRate":"5","ctrlWord":{"byte1":0,"byte2":9,"byte3":0,"byte4":0},"words":9,"hex":{"network":"43","id":"3","source":"ff","msg":"27","toggleCount":"6","toggleRate":"5","ctrlWord":{"byte1":"0","byte2":"9","byte3":"0","byte4":"0","fullByte1":"09","fullByte2":"00"}},"msg":27,"generated":"09004303FF27060580","checksum":"80"}Serial Port OpenedSerial write RAW: ↨70028ESerial write encoded: 70028ESerial results: 8Serial write RAW: ¶09004303FF27060580Serial write encoded: 09004303FF27060580Serial results: 20Serial Port Closed -
Decode: 08008708FF2264E
$ upb-cli -d 08008708FF2264E
More Information
I got most of the information the last three items listed on this Simply Automated page: Tech Specs. I also experimented with my serial terminal to see responses of other switches.
- UPB System Description - This PDF describes all parts of the UPB protocol.
- UPB Command Wizard - Software - This program lets you build commands with a wizard/GUI and see the result. It does not actually send the command, but it is very valuable for understanding the commands without reading too much of the above PDF.
- UPB Powerline Interface Module (PIM) - Description - This PDF contains information about the PIM. It shows serial specifications (4800 baud 8-n-1) and PIM responses. It look me a while to figure out that the PIM always responds with
PE
whenever a command is not prefixed by the #20 character.