Resetting an Ikea Trådfri bulb can be quite frustrating. To solve this issue, I wrote this firmware for the Sonoff S20 I had lying around. It should also work for other sonoffs, but I have not tested that. Please let me know if you tried it on another device so that I can mention it here.
I wrote it first without any networking features to quickly prototype the reset procedure. After that, I added MQTT support, because that's how I communicate with the sonoff devices. Usually with TASMOTA, but the current implementation is all I use from it anyway.
Clone this repo and flash it to your S20 with your favourite programmer. E.g. I use VS-Code with the Arduino extension.
Plug it into your wall outlet, long-press the button on the front, and it will start the reset procedure.
You have to uncomment the first line in edit config.h to enable MQTT support. Edit also your wireless configuration and if you use no MQTT security change
#def USE_MQTT_AUTH
to
//#def USE_MQTT_AUTH
To set the relay state publish to your configured mqttTopic e.g. "sonoff/20/relay" with following payload:
{ "state": "ON" }
Available states:
- ON
- OFF
- TOGGLE
To run the reset procedure for the Ikea Tradfri Bulb you have to publish to mqttResetModeTopic e.g. "sonoff/s20/mode/reset" wih follow payload:
{
"lockDuration": 20000,
"cycles": 6,
"delayOn": 500,
"delayOff": 500,
}
You don't have to set all properties. All properties that are not set will be set to the default value described below. That means, if you are happy with the default values, you can also send an empty payload.
Time in milliseconds for how long the relay state is locked for changes after the reset procedure finished. Default: 20000
The number of ON-OFF cycles that will be performed during the reset procedure. Default: 6 (for Ikea Tradfri)
Time in milliseconds for the delay after the relay is turned ON in the reset procedure. Default: 500
Time in milliseconds for the delay after the relay is turned OFF in the reset procedure. Default: 500
When the relay toggles you will get a status message to your mqttTopic with the prefix /status. During the reset procedure, you will not get any status updates. Only when it finishes, you will get a message with status LOCKED. When the lock is removed, you will be notified again with the current relay state.