Flashing a Kogan Smart Kettle with Tasmota
I bought a wifi-connected kettle and flashed it with a custom firmware.
This is a "Tuya" product which uses an ESP32 chip. Tuya provides hardware and software for a lot of white-labelled products, and it's a very open platform with a lot of documentation. This means that a lot of off-the-shelf devices can be flashed to run custom firmwares such as Tasmota and ESPHome.
We used to be able to use a tool called tuya-convert, which would hack devices wirelessly and flash a custom firmware over-the-air (OTA). I tried tuya-convert, but I got this error:
Your device's firmware is too new.
Tuya patched the PSK vulnerability that we use to establish a connection.
You might still be able to flash this device over serial.
So I had to open it up, connect some wires, and flash it via serial. I used the GPIO pins on a Raspberry Pi.
It worked! I flashed the kettle with Tasmota and saw data coming into MQTT.
I set up a flow in Node-RED to monitor and control the temperature setting on the kettle.
Hyper Text Coffee Pot Control Protocol
I was worried that I might accidentally ask the kettle to brew coffee, so I implemented support for the Hyper Text Coffee Pot Control Protocol. I did this by returning the HTTP status: 418 I'm a teapot
.
(I guess it's not a teapot, but it's certainly not a coffee machine.)
The kettle now responds to an API request at /bc
(which stands for "brew coffee"), and will respond with status 418.
~/code/Tasmota $ curl -v 192.168.1.113/bc
* Trying 192.168.1.113...
* TCP_NODELAY set
* Connected to 192.168.1.113 (192.168.1.113) port 80 (#0)
> GET /bc HTTP/1.1
> Host: 192.168.1.113
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/1.1 418
< Content-Type: text/plain
< Content-Length: 12
< Connection: close
<
* Closing connection 0
I'm a teapot
FAQ
- Q: Why would you want to flash your kettle with a custom firmware?
- A: The original Tuya app uses a cloud service, and I don't like relying on third-party services. Tasmota is fully local and doesn't make any requests to the public internet. This means that I don't need to worry about hacks, leaked data, or the company going out of business and shutting down the app.
- Q: Ok but why do you have a smart kettle anyway?
- A: Honestly, because I thought it would be funny. But my wife does like to have it turn it on automatically when she gets out of bed.