Controlling a Wifi Plug over the network using TCP Messages

We recently purchased some TP-Link HS100 Kasa Smart Wi-Fi Plugs to allow us to remotely turn on speaker amps to support our outdoor speaker systems. Turning the amps on each time by going to the physical amp location in the racks located all across the campus was very inconvenient, so this was a great upgrade.

HS100(US)2.0-package_1508143441338j.jpg
This is what the plug looks like.

It pairs with an app called Kasa to allow you to turn the outlets on and off pretty easily, however in our testing, we couldn’t get it to work with more than one smartphone. Plus, we didn’t want volunteers to have to install this app on their phone, or provide a phone just to run this app.

The TP-Link protocol has been reverse engineered pretty well, so I had hopes that this would be a quick and easy project, and it was! The core protocol uses JSON to communicate, however it is obfuscated heavily to the user and you have to send a hexadecimal payload to it in the end in order to trigger an action.

Once we set up the devices as recommended through the app to use our internal network WiFi, I had our IT department create IP address reservations based on the MAC addresses of the outlets, so that they would always have the same IP address. If you use these plugs, I recommend doing that in your setup as well.

Then, I researched the protocol and figured out what the hexadecimal payloads needed to be to power it on and off. I didn’t really care about any of the other status settings. Just a simple on and off.

Here is the function needed to do that, written in ogScript for Ross Dashboard:

function tellOutlet(address, port, protocol, command)
{
    var enabled = ogscript.getObject('outletEnabled');

    if (enabled)
    {
        switch(protocol)
        {
            case "TPLINK-HS100":
                var payload_on_hex = "0000002AD0F281F88BFF9AF7D5EF94B6C5A0D48BF99CF091E8B7C4B0D1A5C0E2D8A381F286E793F6D4EEDFA2DFA2";
                var payload_off_hex = "0000002AD0F281F88BFF9AF7D5EF94B6C5A0D48BF99CF091E8B7C4B0D1A5C0E2D8A381F286E793F6D4EEDEA3DEA3";
                  
                var sendCommand = "";
                  
                if (command == "on")
                {
                    sendCommand = payload_on_hex;
                }
                else if (command == "off")
                {
                    sendCommand = payload_off_hex;
                }
                                 
                rosstalk.sendAsBytes(address, port, sendCommand, callback);
                ogscript.debug("Outlet turned " + command + ".");
                break;
            default:
                break;
        }
    }
}

The key function here is the RossTalk SendAsBytes command which sends the TCP message as hexadecimal data.

Once I did a test and was satisfied it was working properly, I built out custom panels that use our master production control system, so now volunteers can easily turn the amps on or off by just clicking a button!

I also built a stand-alone version in case anyone else could benefit from it.

Screen Shot 2018-07-25 at 4.06.54 PM.png
The buttons are first disabled when you open the panel until you’ve configured the outlet in the setup tab.
Screen Shot 2018-07-25 at 4.07.00 PM.png
In the setup tab, you can configure the outlet IP address, the port (the default is 9999), and choose the protocol. Currently, the panel only supports the TP-Link HS100/101 models.
Screen Shot 2018-07-25 at 4.06.42 PM.png
Just click On or Off to toggle the outlet!

The panel is up on my Github repository, if you’d like to download it.

Adding Footswitch Control to Clearcom

As I said in a previous post, we rely heavily on our Clearcom intercom system to have good lines of communication between all of the tech team and the band as well.

In each control room, we have a “director’s station” which has a 4-channel intercom where he/she can talk to all four channels of the intercom system: the tech team in Auditorium 1, the band in Auditorium 1, the band in Auditorium 2, and the tech team in Auditorium 2. All other intercom stations are single channel and that person can only talk on the particular channel they are wired for.

For the most part, this works great and does well to keep intercom chatter down and keeps the director as the funnel of communication. However, I have found that quite often, when we are doing smaller events in our smaller auditorium, that I am sitting at the video switcher with no way to talk to the band without having to get up and go sit at the director’s station behind me.

When our integrators built out the AVL for our new auditorium, they installed a Clearcom RM-702 2-channel rack mounted intercom into the rack room for Auditorium 2. I found that after a year and a half, we never use it there, so I decided to move it to Control Room 2, which is the video control room that drives operation for Auditorium 2.

Photo Jul 17, 2 52 42 PM
This is the RM-702, installed now into the control room.

As I operate the video switcher, I like to keep my hands on the switcher (and my streamdeck!). Reaching over to press an intercom talk button is an interruption to my workflow. The nice thing about the RM-702 is that it has an accessory port, which allows you to connect a footswitch to activate the talk channels!

photo-jul-17-2-50-21-pm.jpg
Here is a view of the accessory port with the cable connected that I purchased.

The accessory port is a DB-15 connector, so I bought an extension cable, along with a DB-15 plug. I bought these from Amazon:

I also bought two Yamama FC5 foot pedals.

photo-jul-17-2-52-59-pm.jpgTo wire everything up, I had to cut off the plug at the end of the pedals to expose the wires. The wiring is pretty simple. Clearcom has it well documented what the pinout is.

  • Pin 1: Ground
  • Pin 2: Talk Channel A
  • Pin 9: Talk Channel B

 

photo-jul-17-4-24-10-pm.jpg
Here is everything wired up.

The Yamaha pedal is a contact/no-contact switch, so it doesn’t matter which color wire goes to which pin.

 

Once I connected everything up, I realized that the Yamaha pedal works the opposite of what I needed: it was making contact when the pedal wasn’t pressed down (shorting the connection in the Clearcom, keeping the talk channel turned on) and then when I would press the pedal down, it would break the connection, turning the talk channel off.

I opened up the pedal and modified the two leads so that it would make a connection when pressed down. I basically just swapped the position of the two copper bands.

Photo Jul 19, 8 29 25 AM

 

Photo Jul 19, 8 29 46 AM
This is how the pedal looks like by default. It is connecting the two wires until you press down, which breaks the connection. The opposite of what I needed.
Photo Jul 19, 8 50 31 AM
By swapping the two leads, now I have a pedal that only makes connection when pressed down. I had to bend them a little bit to sit properly.

Voila! Now I have two footpedals that I can use to talk on either channel, hands-free! The next step will be labeling them and then taping them down to the floor.

 

Photo Jul 19, 9 20 06 AM

All in all, this was a very inexpensive improvement. The pedals were about $15 each and the cable/adapter was about $10, and the project was simple.

 

On-Screen Tally Light for ProPresenter using software

I wrote a new piece of software recently that I’m really excited about. It’s called ProTally and it is designed to display video tally markers directly on the screen.

icon_512x512@2x

What’s tally? In broadcast setups, it is often helpful to be able to tell camera operators, computer graphics workers, etc. when their shot is being used on-air or visible on screens. Most broadcast equipment comes with some sort of tally light that, when connected to the right system, lights up to let the operator know.

With today’s broadcast equipment, a lot of this tally information can be communicated directly over the network, in real time using a variety of protocols. One particular protocol is TSL UMD, from Television Systems Limited for Under Monitor Displays. It is supported by a wide variety of broadcast industry equipment and allows the devices to know the tally state of one another.

In church environments where we use computer software like ProPresenter to send CG content to a video switcher, it can be very helpful to have a tally light that the user can see so they don’t accidentally change a graphic while it is live or on the screen. While there are a variety of external tally lights available for this purpose, I wanted to design something that would allow for a green (in preview) or red (in program/on-air) box directly on the screen that the user can easily see while operating the software, without having to purchase additional hardware.

For this project, I used Node JS and the Electron libraries, along with an existing Node JS module that acts as a TSL 3.1 Protocol server. I was able to whip up a demo in just a few short hours. Then it was just a matter of finessing and adding features.

Using ProTally, you can monitor up to 4 Tally Addresses using TSL UMD 3.1 and keep track of their Preview, Program, and Preview+Program states. You can even customize the colors as needed! The boxes can be resized and moved around on the screen and those positions will be saved and recalled the next time the software launches.

Screen Shot 2018-07-11 at 10.31.00 PM

Screen Shot 2018-07-11 at 10.32.26 PM

I decided to add options to allow the user to choose whether they wanted a filled-in box or a transparent box with a color border. It also reads the label data and stores that as it comes in, to give names to the tally addresses. And, because we use two Carbonite switchers at my church, I also wrote in an object array that uses the TSL UMD protocol implementation described by Ross here: http://help.rossvideo.com/carbonite-device/Topics/Devices/UMD/TSL.html

Screen Shot 2018-07-11 at 10.31.31 PM
The software stores the label names of the devices as they are read in the tally data over time, so as the software runs longer, this drop down list becomes mnemonicly helpful.

Due to some limitations of the Electron framework, I had to make the windows appear “always on top” of other windows, to ensure they would be visible while clicking around in ProPresenter (or ProVideoServer or whatever software being used). This can be a little annoying if you’re using the computer for another task and don’t want to see the tally boxes, so to help with that, I added a “Hide All Boxes” option that can be used rather than quitting the software.

Screen Shot 2018-07-11 at 10.30.45 PM

Here is ProTally in action:

 

Screen Shot 2018-07-11 at 10.35.13 PM
This is a transparent window with a border sitting on the output window of ProPresenter.

 

 

Screen Shot 2018-07-11 at 10.33.51 PM
This is a filled-in box.

 

This solves a problem for a lot of people who want on-screen tally for ProPresenter, ProVideoServer, or whatever software they may be using. You can even use it to monitor general inputs like cameras, etc. Just assign the tally address, position the box, and you’re set!

I will have this available in my GitHub repository soon. Feel free to check it out and if you use it, let me know how you like it! I plan to add more features to it as I have time.

Two Quick Updates

Just two quick updates, if you are using my software.

First, I’ve added a couple more features to the Countdowns/Clock system. You can now have a custom name for each countdown, which is pretty helpful. And, the page now displays a progress bar/meter that shows how long until the next page refresh, which has been increased to 15 seconds.

Screen Shot 2018-07-02 at 3.05.06 PM

Second, my VideoHub custom panel for Dashboard will now auto detect how many inputs/outputs you have on your router, which is mainly used for building out the drop down lists of inputs and outputs to choose a route.

Hope this helps! You can get the latest versions on my Github repository.