Teckin Smart Plug / Socket with HomeKit using homebridge

Context

I wanted to automate my outdoor lights to enable timers and motion detectors to trigger them to make the house a little safer and easier to navigate at night. I have not decided on an activation method yet, but the first step, will be to just get them on HomeKit. I considered smart bulbs, but that would mean i’d need to change the existing PIR fixtures and I do not need to dim them or anything, so this seemed overkill. I can disable the PIR on them all and set them to always on, so a smart socket will do the job great!

I started looking for HomeKit smart sockets in the UK and the choice is very limited and often pricey.  I decided to just try a Teckin £10 socket from Amazon, which was not HomeKit compatible, but I was certain I could work something out with homebridge.

Configuration

The Teckin Smart Plug is just a Tuya device and uses a cloud API for actuations, not controlled locally on your network like all other HomeKit devices. This may have some security implications, but all comunications seems to be encrypted and secure, so I am happy to use this for now.

The homebridge plugin that I ended up using to control the socket is homebridge-tuya. I struggled to get the tuya-cli link-wizard to work to identify the id and key of the device. The connection initial process seems very flaky. I do not know if it is due to my mesh network or what, but i spent hours on this bit. In the end I resorted to identifying the id and key for my switch using Charles on macOS and this method from an older version of the Tuya node API.

Result

It works great in HomeKit!

Now, to find a good way to trigger it from motion outside. 🤔