Via Kristian came a link to two MQTT-capable and HTTP-enabled power socket switches by Delock: one goes by the model number 11826, and the second is called 11827 and includes energy monitoring. I ordered one of each as it’s been a while since I toyed with stuff, and after all it is almost christmas…

the Delock devices

The taller but slimmer plug on the left is the 11827, and the squatter square one on the right the 11826. They look rather nice, and both have a button inset next to a minuscule LED. A touch of the button flicks the switch itself and, depending on how long and how often it is pressed, can trigger Over The Air (OTA) updates of the firmware and reset the device to factory settings, and all manner of other things.

The included leaflet is sufficient to get started. Plugging the device into mains has it create a WiFi access point I connect to, and I can then configure it to connect to my home network. The Tasmota firmware spoke German to me all the time, and the only reason I can think of, as my browsers are all set to English, is that it was built that way for delivery here. Ronald confirms that and explains I can flash the device with an en firmware from here (I pasted the link to tasmota.bin into the firmware update page).

initial Wifi configuration

Once I enter the information for my WiFi router, the device reboots. This is the moment I switch the phone back to my environment and access the device again via its new IP address.

From the device’s Web UI I can switch the power on or off.

main screen including on/off

I can also switch the load via HTTP (I think it’s the first time I see the word “command” abbreviated to “cmnd”, and this could have been a PUT or at least a POST request, but I suppose it doesn’t matter.)

$ curl "http://192.168.1.167/cm?cmnd=Power%20toggle"
{"POWER":"ON"}

$ curl -d POWER=TOGGLE "http://192.168.1.167/cm"
{"WARNING":"Befehl eingeben cmnd="}

The documented “Extra feature” of using cmnd=Strom in the German language, doesn’t work.

other configuration

The next was setting up MQTT, pretty easy if you’ve done this before, which I have. :-) I configured host, port, username, and password, as well as clientID and topic branch, which ended up being lamp/11826/%prefix%/%topic%/; the device fills %prefix% and by default %topic% with the word “delock”. I found that bit of UI to be a bit confusing, but clarity ensued when I booted the device:

$ mosquitto_sub -v -t 'lamp/#'
lamp/11826/tele/delock/LWT Online
lamp/11826/cmnd/delock/POWER (null)
lamp/11826/tele/delock/INFO1 {"Module":"Delock 11826v1","Version":"6.7.1(basic)","FallbackTopic":"cmnd/DVES_D8E724_fb/","GroupTopic":"donoffs"}
lamp/11826/tele/delock/INFO2 {"WebServerMode":"Admin","Hostname":"delock-1828","IPAddress":"192.168.1.167"}
lamp/11826/tele/delock/INFO3 {"RestartReason":"Software/System restart"}
lamp/11826/stat/delock/RESULT {"POWER":"ON"}
lamp/11826/stat/delock/POWER ON

The LWT topic is retained and indicates whether the device is online; the actual last will and testament payload is the string Offline value when the device goes offline.

If I had actually read those messages I might have seen “GroupTopic”, but I’m not sure I would have actually understood what it does. Instead I resorted to setting the device to do syslog and found out which topic the device subscribes to (“abonniere” is “I’m subscribing” in German). I could also have seen the subscribes in the MQTT broker logs:

delock-1828 ESP-HTP: Web-Server aktiv bei delock-1828.local mit IP-Adresse 192.168.1.167
delock-1828 ESP-UPP: Multicast (wieder-)verbunden
delock-1828 ESP-NTP: Drift 0, (UTC) Sun Nov 22 13:10:55 2020, (DST) Sun Mar 29 02:00:00 2020, (STD) Sun Oct 25 03:00:00 2020
delock-1828 ESP-UPP: Multicast deaktiviert
delock-1828 ESP-MQT: Verbindungsversuch...
delock-1828 ESP-MQT: verbunden
delock-1828 ESP-MQT: lamp/11826/tele/delock/LWT = Online (beibehalten)
delock-1828 ESP-MQT: lamp/11826/cmnd/delock/POWER =
delock-1828 ESP-MQT: abonniere lamp/11826/cmnd/delock/#
delock-1828 ESP-MQT: abonniere lamp/11826/cmnd/donoffs/#
delock-1828 ESP-MQT: abonniere cmnd/DVES_D8E724_fb/#
delock-1828 ESP-MQT: lamp/11826/tele/delock/INFO1 = {"Module":"Delock 11826v1","Version":"6.7.1(basic)","FallbackTopic":"cmnd/DVES_D8E724_fb/","GroupTopic":"donoffs"}
delock-1828 ESP-MQT: lamp/11826/tele/delock/INFO2 = {"WebServerMode":"Admin","Hostname":"delock-1828","IPAddress":"192.168.1.167"}
delock-1828 ESP-MQT: lamp/11826/tele/delock/INFO3 = {"RestartReason":"Fatal exception:9 flag:2 (EXCEPTION) epc1:0x40105590 epc2:0x00000000 epc3:0x00000000 excvaddr:0x000

See that crash report in the last line? The device keep crashing and rebooting until I reconfigured its syslog report to “info” down from “debug”.

So, with the topics available, I can now switch the lamps on, off, or toggle their status. I’m indicating this here with pub for publish and sub for what I get when subscribed to the specific topic:

pub lamp/11826/cmnd/donoffs/POWER -m TOGGLE

sub lamp/11826/stat/delock/RESULT {"POWER":"ON"}
sub lamp/11826/stat/delock/POWER ON

Every five minutes, the device reports state at lamp/11826/tele/delock/STATE:

{
  "Time": "2020-11-22T14:21:45",
  "Uptime": "0T00:10:16",
  "UptimeSec": 616,
  "Vcc": 3.466,
  "Heap": 26,
  "SleepMode": "Dynamic",
  "Sleep": 50,
  "LoadAvg": 19,
  "MqttCount": 1,
  "POWER": "ON",
  "Wifi": {
    "AP": 1,
    "SSId": "my-wifi",
    "BSSId": "01:01:01:01:AB:CD",
    "Channel": 6,
    "RSSI": 88,
    "LinkCount": 1,
    "Downtime": "0T00:00:05"
  }
}

Let’s plug in the 11827 with energy monitor and do the same setup. Immediately on its Web-based home page I see the energy consumption of the small test lamp I’ve plugged into it:

11827 with energy monitor

After a short time the device publishes to lamp/11827/tele/delock/SENSOR:

{
  "Time": "2020-11-22T15:20:42",
  "ENERGY": {
    "TotalStartTime": "2020-11-22T15:12:39",
    "Total": 0.003,
    "Yesterday": 0,
    "Today": 0.003,
    "Power": 28,
    "ApparentPower": 28,
    "ReactivePower": 0,
    "Factor": 1,
    "Voltage": 233,
    "Current": 0.12
  }
}

Last, but possibly not least, is a scheduler (think cron(8)) with up to sixteen timers. Each timer can switch the load on or off, or toggle it’s state and blink it (we might not want to do that with most loads). I can specify days of the week at which this should occur, a particular time or let it do its thing at sunrise or sundown, and even set a random fudge factor of up to +- 15 minutes to pretend the schedule is not a schedule.

scheduler

When the schedule fires, I get a POWER ON/OFF published to MQTT, but I’m not told it’s due to the schedule, which could be a nice thing to have.

I can type commands into the Web UI to set, e.g. dark mode, and there’s a list of valid MQTT commands on the Tasmota pages.

All in all, apart from the documentation which is very minimal, these little devices are quite nice and do what they’re supposed to do. Once again, I don’t believe WiFi is the correct carrier for doing this kind of thing (what do I do if I have to or want to change the WiFi password, eh?), but at this price, no complaints.

Oh, the price? I paid EUR 17.14 for the 11826 and EUR 19.90 for the 11827 with energy monitoring, about a third of what the nice Fibaro switches cost me back then.

Further reading

Updates

  • Thanks to @J3Gr_ who teaches me how to configure the device’s template after reflashing it OTA with the stock (9.1.0) tasmota.bin:

    Did the following: took the bin from official tasmota OTA, flashed, after flashing the template seemed resetted, go to https://templates.blakadder.com/delock_11827.html and took the template string, inserted into UI, save and done.

    For posterity, the template string is {"NAME":"Delock 11827","GPIO":[0,0,0,17,133,132,0,0,131,158,21,0,0],"FLAG":0,"BASE":53}

  • I discover I can publish a command Webserver with parameter 1 (user mode) or 2 (admin mode) which hides/shows the full UI. In user mode I see the Toggle button on the UI only. The Webserver mode is persistent. (Warning: 0 disables the Web server entirely.)

MQTT, HTTP, DIY, and home automation :: 22 Nov 2020 :: e-mail