Simple The Pill by Shelly integration

I have been working for some time to build a completely local simple The Pill by Shelly integration.

The Pill by Shelly integration is execute completely locally (SmartThings Hub is needed) - not requiring additional software running on a different machine (like Raspberry Pi)

Driver is using Websockets communication.

The Pill by Shelly introduction

The Pill by Shelly integration (current prototype) is supporting following Pill’s I/O modes:

  • Temperature (DS18B20) - Supporting 1 Temperature probe (18B20) + optional 2 x Digital Inputs/Outputs
  • Digital Input/Output - configurable for up to 3 x Inputs/Outputs

In addition to these, the device supports connecting virtual components (Boolean type)

  • 2 outputs (SmartThings switch) to control The Pill by Shelly virtual components (Boolean type)
  • 3 inputs (SmartThings switch) to read from The Pill by Shelly virtual components (Boolean type)

The Pill by Shelly Configuration IO

The Pill by Shelly Virtual Component example

My intention is to release the driver in August - September if there is interest in using it.
For now I will just make this presentation and I hope comments.

Let’s see if there is interest in this kind of integration.

@TAustin mentioned somewhere that Shelly Gen3 supports Websocket communication.

This Shelly WebSocket driver uses this driver as a model:

The selection criteria was that this implementation seemed the simplest of all.

I have also used as a model for driver implementation @lmullineux driver:

I’m looking for tips on finding good instructions for creating a Websocket driver in Lua.

If you are interested, I can share with you the websocket library I used in my Shelly driver. I can’t even remember exactly where I picked it up - the source doesn’t have any attribution. But I was steered to it by a post here back a few years ago. But I remember having to make just a couple tweaks to the code to get it to work.

Of course, I could check out your library. You can DM to me.

I now have the driver ready enough for communication to work in both directions. I’m unlikely to replace the WebSocket library completely.

The driver based on these (hl_websocket.lua & lustre) works well.
The main missing parts are the functions in special situations (connection failure, reconnection, …). Maybe I removed these things when I modified the model driver to use communication with Shellys. Without good comments it is difficult to understand from Lua code what is basic websocket communication and what is manufacturer-specific.

My problem is that I don’t have enough basic knowledge about socket programming.


I would also be interested in the mDNS Lua code for searching for Shellys.

It took a lot of fussing to get come up with a reliable communication link, and one that could reset and restart if errors occurred. I won’t bother you with the websocket library since you already have that. Regarding the discovery, there’s not much to it, once I converted over to the edge mdns library. I’ll DM you that module.