Flash Tuya CB3S Switches with OpenBeken

I recently picked up a couple of no-name WiFi switch from AliExpress, they are sold under a variety of names, but the ones that look like mine all use the Tuya app. I was hoping to flash it with ESPHome, but unfortunately, it doesn’t contain an ESP8266 module, instaed using a Tuya CB3S module, which is not supported by ESPHome. These switches had been using ESP-12F modules for some time, but have since transitioned to CB3S. Fortunately, I was able to find a project called OpenBeken, which is a custom firmware for the Tuya CB3S module. It’s more basic than ESPHome, but it did actually do what it said it would, with very little effort.

Read More

Flash Etekcity Plugs (ESW01) with ESPHome

I’ve been slowly amassing a collection of various smart plugs and switches around my house for the purpose of setting up a home automation system. I picked up a single Etekcity ESW01 plug to test out, and was pleasantly surprised to find that it was based on the ESP8266, a very popular and well supported microcontroller. I hadn’t played with home automation in a while, and was excited to see how far it had come. Where previously, I would have had to roll my own firmware, and then write my own integration for Home Assistant, I found that there is now a project called ESPHome which allows you to easily flash ESP8266 and ESP32 devices with a custom firmware, and then integrate them into Home Assistant.

Read More

DIY Espresso Distribution Tool

I had been wondering why my home espresso machine pucks would sometimes turn out dry and sometimes turn out looking like mud. After several YouTube videos later, I’m now convinced that my grounds lack equal distribution prior to tamping, as my current process involves scooping in a dome of grounds and pressing it down. This causes a dense part in the middle (top of the dome), and loose grounds around the edge. The YouTube experts recommend distribution, either by practiced hand methods, or by using a tool, of which there are several to choose from. I liked the “Weiss Distribution Method” or “wire-stir” method, as it seemed straightforward and didn’t require a $30 precision made tool. I found several on Amazon, but I’m feeling equally lazy as I am impatient, so rather than spend $10 and wait two days, I’m going to make my own with items I already have.

Read More

Redis Lua benchmark and overhead

I’ve been wanting to make use of Redis Lua scripting for a long time for some projects at work. I’ve read Redis Lua scripting, and found that I can use it to solve a few common issues we’ve been dealing with, one being ensuring redis hashes have an expiry. We have a lot of services at my job which use Redis as a centralized state database, allowing services to share knowledge in a common place, without having to know if or what else may need the data. All information written to this DB requires an expiry value to be assigned. In our old data model, we had done this by using the SETEX [key] [ttl] [value] or SET [key] [value] EX [ttl] commands. This is great, as we can set the key and the expiry at the same time atomically and ensure that every key will expire. In our new data model, we are switching from keys to hashes, but unfortunately, there is not an HSETEX command built in. Instead, we have to rely on pairing HSET and EXPIRE commands manually, which of course doubles the “ops” per item being set, but also ads the possibility of something breaking and a hash lacking expiry.

I found Redis Lua scripting to be a big help here to ensure that every hash gets an expiry set while setting fields/values on the hash. I also added logic to conditionally skip setting EXPIRE. The response of HSET will tell us how many new fields have been created, which would only be 0 if the hash already existed and already had an expiry.

-- Set EXPIRE on hash after HSET if new fields added
-- OPs: usually 2, occasionally 1 (when hash and fields are reused)
local expire = table.remove(ARGV, 1)
local newCount = redis.call("HSET", KEYS[1], unpack(ARGV))
if tonumber(newCount) > 0 then
redis.call("EXPIRE", KEYS[1], expire)
return newCount

So, all of this sounds great, I can just make use of Lua scripts for anything that needs to do multiple actions, saving my code round trips to the DB. Obvious win, right? I wasn’t totally sure. When searching for Redis Lua performance, I kept finding articles where someone was mis-using Redis Lua, calling EVAL every time they want to call Redis Lua, or generating dynamically generated Lua script, both of which are entirely incorrect uses of Redis Lua.

I wanted to know was what is the actual cost was to use a Lua script compared to standard Redis commands? Literally, apples-to-(lua-scripted)-apples.

Read More

Peak Design Lens Kit RF mod

I recently purchased some used camera gear, and one of the included items was a “Lens Kit“ by Peak Design, which helps you carry up to two lenses using a strap or on the Peak Design Capture. I always find myself fumbling with a second lens when out, so this seemed like a useful addition to my kit. While I was lucky enough to receive the Canon EF/EF-S version, I have recently switched over to using a Canon EOS R, which uses the new RF mount, which is incompatible with EF.

I had previously noted that the EF and the RF mounts were very similar in dimensions, but not compatible by design. As the Lens Kit doesn’t have any electrical or optical reasons why it can’t work, I wondered if it could be slightly modified to accept EF and RF.

Read More

TourBox Teardown

Months after pledging on KickStarter, I finally received my TourBox! This device is meant to be used in your left hand while you work with a mouse or stylus with your right, hopefully speeding up your productivity in Adobe Photoshop, Lightroom, or any other app that accepts mouse and keyboard based shortcuts. After the initial setup, and about an hour of testing it out, I decided to disassemble it, as I do with most things I buy. Part of me wanted to inspect the workmanship of the innards of this device, as I’m sure there have been plenty of KickStarters with sloppy, quickly thrown together innards, where most people wouldn’t have a reason to look.

Read More

Removing WiFi from a Pinebook

A friend of mine came to me with an interesting hardware mod request recently. He is very serious about security when it comes to cryptocurrency, and wanted to set up a totally air-gapped machine for doing key signing, among other things. For his hardware, he chose a Pinebook 64, as the hardware and OS are fully open sourced, therefore subject to more scrunchy by security-minded people. Because he wanted it to be air-gapped, he had initially gone the route of disabling the network adapters, but the fact that they were still physically only a few clicks away from being re-enabled, and internet-ready bothered him. So, we decided to physically disable the WiFi and Bluetooth completely, in order to be 100% sure that it stays offline.

Read More

WiFi Rubber Ducky

The good folks over at Hak5 have created some really cool penetration testing hardware, my favorite being the USB Rubber Ducky. “The USB Rubber Ducky is a keystroke injection tool disguised as a generic flash drive.” It’s a very flexible, awesome tool in a small, unsuspecting package. I don’t actually own one of these devices, but to me, it fell under the category of “I bet it would be fun to build something like that for myself”.

Read More

Installing Dell Laser Printer 1110 in Linux CUPS

Among other things, I run a Raspberry Pi as a print server. While clean install upgrading from Debian wheezy to squeeze, I found I was unable to get my Dell Laser Printer 1110 to work in CUPS. I had remembered it was a massive hassle last time, but I could not for the life of me remember what I did to make it work. Luckily, I backed up the whole SD card prior to wiping and reinstalling, so I was able to reference configuration and files. I’m sure there is a way to install these files using apt or by grabbing the sources somewhere… but I HATE dealing with peripherals drivers, so I cheated, copying the files from the old Pi the new Pi. Hopefully this helps someone else as as much as it will help my future-self.

Here are the three files required to get the printer working:

Update 2022-05-30: Fixed the dead links