Self Aware On Air Neon Sign

Hang out enough time in the media industry, and you will understand that it is a standard for every decent newsroom or studio to have an On Air sign shining its mighty red light when a show is live or recording.

(This is not my light but I like the retro style of it)

From legendary props I had witnessed in TV shows and movies, it became my daily life for the past 7 years: at the top of the news studio doors at ABC in the US, also seen around the giant novelas recording studios in Globo and discreetly at every entrance of Record’s production rooms in Brazil, it has been a constant landmark.

Then, I started working from home and I started to miss the excitement to see this red light. So I decided to make my own.

I found a decent neon sign (it was not easy), and since I had been playing for a while with smart wifi plugs, API, Bash, and Python, I decided to bring everything together and create an automation for my daily work life with the following idea:

When I turn on my camera for meetings, I want the On Air sign to turn on automatically. And when the camera turns off, well, the On Air sign also turns off. I also want to be able to turn this sign from the command line, from my two Mac machines.

The sign

Now, it’s a bright idea to use an On Air sign, but where do you buy those things? I didn’t know any shops in Portugal, so I turned to Amazon. I chose this sign: red, friendly font, not too big, with a USB connector, and a manual switch which I won’t be using. The background isn’t transparent like in the picture, but on a white wall, it doesn’t make any difference.

It looks quite nice, but judging from the state of the packaging, it had been sitting on the warehouse shelf for some time.

(This is my own On Air neon sign)(Yeah, it’s so cool!)

Given the smart plug I am using, I also needed a small adapter AC to USB, which I salvaged from I don’t know where, and that I’ll probably replace in the future for something smaller.

The plug

Again, I did all my shopping on Amazon, as I didn’t know where to turn to find these items locally in Lisbon. I had taken a look at Leroy Merlin, but besides really big plugs and kind of expensive, there is not much choice. Bricomarché just doesn’t have anything in this area, it seems.

But online, there are a lot of sellers on the market. I chose a GoSund plug, sold as OHMAX on Amazon in Europe. These plugs are a bit bulky, and if I had to redo this project I would choose something slimmer, probably with a USB port directly.

The Smart Plug framework

Believe it or not, after weeks of researching APIs for this plug, I understood that most plugs on the market rely on the Tuya protocol and even hardware, and even the “custom” apps, like the GoSund mobile app, are just clones of the Tuya app with added restrictions.

I decided to use the Python library called TinyTuya. It has the benefit of allowing local network communication: I didn’t need to pilot this light from the cloud.

But unfortunately, I needed a local_key to send commands to the plug. And how to get this local key was where I lost so much time on this project. I had to uninstall the GoSund app, which I had for a while already and which I thought, should give me this local key, as all these apps are part of a big family… But no.

What should be done instead:

  • Install the Tuya Smart app on mobile
  • Create a regular user account, set up a home, get cozy, add the smart plug, configure some names, and so on.
  • Create a developer account:
  • Create a cloud project
  • Link the app account and developer account via a QR code
  • On the Tuya dev portal, once the correct data center is selected, the device is visible
  • Finally, using the “Get device details” in the API Explorer, grab the local_key for the device.

At this stage, I was already able to write some Python to turn on and off the plug via the command line. Fun began!

Check the YouTube video in the thanks part at the bottom for a step-by-step description of the Tuya dev portal.

The code

There are 2 parts of the code: a Python script to control the plug and a bash script to detect that the camera turns on/off.

Control the plug

It is as simple as:

import tinytuya
d = tinytuya.OutletDevice(config["PLUG_ID"], config["PLUG_IP"], config["PLUG_PW"])

Where the local key goes into config[“PLUG_PW”]. After making it pretty, I was able to control the plug from the command line with:

python on
python off

Monitor the camera

Using MacOS log stream and its filters, I’m looking at the events when the camera turns on and off. Unfortunately, the log structure is quite different between MacOS versions, so I had to do two scripts for this one.

Here is where the magic happens on MacOS Sonoma:

log stream --predicate 'process == "kernel" && (eventMessage contains "AppleH13CamIn::power_off_hardware" || eventMessage contains "AppleH13CamIn::power_on_hardware")'

The full code is available in this repository:


Local key reset

For some reason, I needed to reset the plug. And when I did this, I realized that the local_key was changing: I could not control my smart plug anymore. So I needed to go through the Tuya Dev portal once again to search for the new local_key. Painful.

For fun, I tried to brute force the local key, but after making quick calculations, 16 random characters would take some billion years with my machines. I gave up.

Unexpected blinks?

I have been using this setup for the past month or so and I have noticed unexpected flashing of my On Air light. I started to realize how many times the camera would turn on and off without me noticing it before or not taking any action for it. It’s quite spooky, I felt like my laptop was spying on me. So times, it even lasts for a few seconds.

  • Opening and closing the lid of the laptop. I got used to it. The camera is probably confirming the lid has been opened or closed with the luminosity of the camera.
  • Opening Google Chrome. Yeah, that’s the most frightening one. I’m guessing Google Chrome tries to see if the camera is in use for
  • Switching on/off a Bluetooth headset. Where is the camera involved in there????

Inspiration and thanks

I followed several tutorials to get my light working. Some people are crazy and taking this kind of project way too seriously.

This one has provided some ideas:

And this YouTube video has been the key to unlocking the power of Tuya:

Latest posts by Fab (see all)

About Fab

Solutions Architect, I build great workflows for the news and media production industries. I play with data too.

Leave a comment

Your email address will not be published. Required fields are marked *