This is still the header! Main site

Cloudless Lights

2025/03/22

So smart lights are a... thing. You buy smart outlets from Amazon.

You then use your phone to download the ZynkLite® InstanConnNect™ App (available on the Google Play Store and the iOS App Store!), going through an easy 10 step process involving

(further directions omitted for brevity)

... or... you could just go to your balcony with a soldering iron and flash these things into normalcy. They're yours, after all.

But then... what do you do with them?

There are many options! People more interested in a higher functionality-to-hacking-time ratio might like HomeAssistant and its fancy web interface. If, on the other hand, you do like minimalist solutions where you get to know what every part does... read on.

One of the kinds of firmware that you can flash onto your smart plugs is Tasmota. Once it's up, it will give you a web interface like this:

Among other options, it supports connecting to MQTT servers... which is how our system works.

MQTT is a pretty simple publish-subscribe protocol. You set up a server (e.g. mosquitto) on a computer you're running at home (if you ever need an excuse for keeping a computer up home, this is one). Then, you point your lights at it!

At the very core, MQTT allows updates that have certain paths, like tele/topgreener05/STATE, send around a blob that looks like this:


{
  "Time": "2025-03-23T04:33:52",
  "Uptime": "288T21:27:26",
  "UptimeSec": 24960446,
  "Vcc": 3.522,
  "Heap": 29,
  "SleepMode": "Dynamic",
  "Sleep": 50,
  "LoadAvg": 19,
  "MqttCount": 76,
  "POWER": "OFF",
  "Wifi": {
    "AP": 1,
    "SSId": "OurWifiNetwork",
    "BSSId": "A4:C3:F1:2D:87:9E",
    "Channel": 6,
    "RSSI": 100,
    "Signal": -50,
    "LinkCount": 14,
    "Downtime": "0T00:04:10"
  }
}
          

This is just one of the lights checking in. It says it's OFF, it's connected to the Wi-Fi network (well of course it is since it's reporting this via something) and it also reports some connection statistics.

MQTT itself doesn't really care about what's inside these messages; all it sees is a "topic" ("tele/topgreener05/STATE") and a content blob.

Now, if someone wants to listen to these updates, you can connect to the server & subscribe to some of these topics. Either by using command line tools like mosquitto_pub (which comes with the server), or by using client libraries. You can see all the messages going back and forth by just dumping everything:

~$ mosquitto_sub \
      -h your.server \
      -t '#' \    # the topic; "#" is a wildcard
      -v
(you can also be more specific than "everything" though.)

This will start printing lines like

tele/etekcity02/STATE {"Time":"2025-03-23T04:49:35","Uptime":"305T21:38:11"," (...)
tele/topgreener02/SENSOR {"Time":"2025-03-23T04:36:23","ENERGY":{"TotalStartTime":"2021-05-16T22:06:48", (...)
          

Meanwhile, you can also send messages like this. For example:

~ $ mosquitto_pub -h your.server -t test_topic -m "this is our message"
          
does just that. If you happen to be listening on another terminal, as described above, you'll see something like

test_topic this is our message
          
pop up. It's... rather uninspiring, given the lack of JSON fanciness, but... it's just this: a topic and a message.

But, back to subscriptions: in fact, the lights themselves are also subscribed to some topics! For example, there is cmd/lightname/POWER. If you send out

~ $ mosquitto_pub -h your.server -t cmnd/etekcity02/POWER -m "TOGGLE"
          

... the relevant light listens to it, and will toggle its "on" state. You can also send "ON" and "OFF". So... whenever you hit Enter on the command line:

If you the video, you can also hear how low latency it is. Try getting this jumpy with cloud stuff!


(up next: how do you do this without ssh'ing in each time. Hint: we might have mentioned one of the ways already)