December 11, 2024 in projects by Al Bennett3 minutes
Milesight Portable Sockets and Scene Control Buttons work together to bring light to Christmas!
Milesight makes a variety of useful LoRaWAN devices useful LoRaWAN devices. We’re particular fans of some of their automation-focused devices, like their Smart Portable Socket and Smart Scene Panel buttons .
We’ve been using the Smart Scene Panel as a LoRaWAN device to run our office coffee machine for a couple of years now. There are six configurable buttons, which we have configured to send uplinks to trigger the grinder to grind the coffee beans for a set time (27 seconds), and switch the machine on and off.
Fast forward to December and Al is standing in his garage messing about with extension leads to turn his house Christmas lights on. There has to be a better way, one that doesn’t involved going out in the cold and dark…
Step forward Smart Portable Sockets! They look just like WiFi smart plugs, but with the range of LoRa - which is handy as the WiFi in this house doesn’t quite reach the garage. I registered a couple of Milesight Portable Sockets on our Things Stack LoRaWAN Network Server, they easily reach the gateway that is running in the loft - a low cost Things Indoor Gateway . The sockets all joined happily, and now run at SF7.
It’s similarly easy to register a Smart Scene Panel, pull out the battery tab and see it join. Within a minute I could press a button and receive a corresponding uplink. Easy so far, so now to glue the two together.
While pondering the software required, I remembered that both devices support Milesight D2D . This enables Milesight devices to talk directly to each other, while still operating as standard LoRaWAN devices. This diagram from Milesight shows a high-level overview.
D2D has a concept of controller
and agent
. A controller sends out a message when something happens - a button is pressed, or a PIR triggered - and an agent takes some action based on that event. Agents include the Portable Sockets, light switches and other interface devices. I’m using D2D in the simplest arrangement of a one-to-one mapping of buttons to sockets, but it’s possible to trigger multiple agents at once, or have mulitple controllers with different logic. Some industrial devices like the UC300 can be both an agent and controller at the same time - this gives lots of flexibility.
Being lazy and in a hurry, I decided to connect them up with D2D, and deal with the software later. Milesight has documented D2D , listing the supported devices and functions they have.
Configuring is straight forwarding using Milesight’s Toolbox NFC app. Simply set a unique D2D key for your pool of devices, and allocate a control command
identifier to each button and socket action. I was creative and called the commands 1
, 2
and 3
. Ensure the key and control commands are the same at both ends and then everything should just work!
Yes!
Helpfully, the D2D controllers and agents can be configured to work in D2D and LoRaWAN modes at the same time, the two protocols coexist happily. The devices will join on your LNS as usual, and by enabling the LoRa Uplink
option in the Toolbox app the controller will send uplinks as usual.
The sockets will also work as a normal Class C LoRaWAN device, and as I’m a Linux nerd the lights are triggered to switch on via a downlink from cron
.
Tune in next year to see if I actually get around to installing Home Assistant to run my house!