esp8266 clock using Tasmota

November 19, 2023

I was looking for something else, and stumbled across an interesting post:

Tasmota is general purpose open source firmware for cheap Wifi capable microcomputer boards. A few bucks and a little software magic later you have something useful… like a clock.

Features:

  • Has NTP built in so it will automatically get the correct time
  • Changes when daylight savings time does
  • Adjustable brightness

The author used a D1 mini board, which I don’t have. I do have a hand full of extra esp8266 boards though. I looked up the documentation for the tasmota module:

https://github.com/tasmota/docs/blob/development/docs/TM163x.md

It documents the setup, wiring, and the commands needed to send the time to the board. It worked pretty much on the first try. I did have to hunt around for a USB cable that had the data wiring. A lot of the cheapo cables just carry power and dispensed with the other two wires.

You’ll also need the timezone table so you can set it up correctly:

https://tasmota.github.io/docs/Timezone-Table/

I need to print a case for it too, but there are quite a few free on the 3D models sites.

———— Update! —————

Finished it up with a case: 

———— Update! —————

One of the important tenets of Edge Computing is to push as much behavior off the server as possible. If the connection to the server is down the system should continue to work in a reasonable manner. I.E. if the internet is down you should still be able to turn the lights on and off.

I’d like to change the brightness down at night to save power and make it easier to sleep. So I’ll push that feature to the clock itself using Tasmota rules and timers.

Here’s the script to setup timers to change the brightness based on time of day:

(The ‘#’ denotes a comment. Don’t paste that into the tasmota console.)

# become a clock on boot up
Rule1 ON System#Boot DO DisplayClock 1 ENDON
Rule1 1

# setup timers. Normal sunrise is fine, enable timers
Sunrise 1
Timers 1

# set Timer2 to 10 minutes after sunset every day of the week, run a rule
Timer2 {"Enable":1,"Mode":2,"Time":"0:10","Window":0,"Days":"SMTWTFS","Repeat":1,"Output":1,"Action":3}

# set Timer3 to 10 minutes after sunrise every day of the week, run a rule
Timer3 {"Enable":1,"Mode":1,"Time":"0:10","Window":0,"Days":"SMTWTFS","Repeat":1,"Output":1,"Action":3}

# concatenate all the events into one rule
# turn brightness up 10 minutes after sunrise
# down 10 minutes after sunset
# down even more after 11pm ( 23 hours after midnight, 23 * 60 = 660 minutes after midnight)
Rule2
 ON Clock#Timer=2 DO DisplayDimmer 26 ENDON
 ON Clock#Timer=3 DO DisplayDimmer 44 ENDON
 ON Time#Minute=660 DO DisplayDimmer 13 ENDON

Rule2 1



Flashing Sonoff S31 lite switches with Tasmota

October 1, 2023

Works pretty well!


Presence detection, saving money, and control with IoT bulbs

September 17, 2023

Last month Shelly ran a sale on four packs of IoT light bulbs. The Duo version has both warm white and bright white LEDs that can mix and match to get the color and brightness you like. They advertise the devices are compatible with MQTT and even provide documentation for it on the web. It also offers brightness control.

I don’t really care about RGB for day to day lighting so the lack of the ability to turn my home into a disco wasn’t an issue.

I did want brightness control even though I don’t run them on dimmers. When LEDs were first manufactured (yes, I am that old) they had a rated lifetime to half brightness of 50,000 hours. That’s over five years when “burning” twenty four hours per day. They should fade away gradually and shouldn’t “burn out” unless hit by lightning. They do though.

So what’s the deal? If you look at the data sheet you see the lifetime and efficiency of the devices declines rapidly when pushed beyond the recommended current. If you tear down the bulbs you buy today you see they are almost all of identical design and all are over driven. They don’t last because the manufacturers don’t want them to. Here are two fun videos that talk about the issue. Big Clive tears down the special bulbs commissioned by the Sheik of Dubai: https://youtu.be/klaJqofCsu4?feature=shared, and here’s the history by Veritasim: https://youtu.be/j5v8D-alAKE?feature=shared. I was willing to pay extra for bulbs that I could permanently run at 80-90% brightness so I didn’t have to keep replacing them.

After receiving the Shelly devices I wasn’t terribly impressed. I was able to turn the bulbs on an off via MQTT with no issue. I read the documentation on setting the brightness and was completely confused. I decided to learn by experimentation and sent the JSON packet I thought was correct. It crashed the light bulb so hard I had to factory reset the bulb to control it again. The firmware was the latest version (last updated in December of 2019?). The support department copied and emailed me worthless advice without reading my email. The forums are full of horror stories.

The good news is doing a firmware update doesn’t require tearing the bulb apart. I could replace the buggy code by Shelly by something better tested and more feature rich. I just finished flashing them all with Tasmota.

With Tasmota I get telemetry from the bulbs so my Node-Red setup knows if they’re on or off. This also doubles as presence detection. If the bulb is powered on when the wall light switch is flipped that’s a pretty good indication a human is present (and you know which room they’re in).

Tasmota includes a group control function so I can easily control the devices in a room as a group. It includes encryption for the MQTT transport as well. All really good features.

A much more time consuming project than I wanted, but it was ultimately successful. I’m reserving judgement on the Matter standard. I remember the claims that internet browsers would follow standards and the same code would work on any browser (yeah, right…)


Shelly doesn’t impress so far…

August 29, 2023

Bought some Shelly duo bulbs since they claim MQTT works without a cloud connection. So far the bulbs won’t stay connected even just a few feet from the router. I confirmed the signal strength was 10db higher than the perfectly reliable Tasmota devices I’m using.

My suspicion is the latest revision of software is buggy. They’re probably going back unless their support can fix it.


Getting IoT notifications on the Linux Desktop

August 12, 2023

If something important should happen with the IoT setup I’d like to know. I don’t want to spend my time on Earth checking up on machines though. I know, it’s less reliable, but I’d prefer to have the machines tell me when there’s a problem. I don’t want to be notified when things are going well.

I settled on using MQTT for device to device communications in my setup. It’s lightweight and I like the messaging model. So using it for notifications seems perfect.

Luckily the code for it was already written by David Lor. All I needed to do was create a service to run it in the background on my Linux Desktop. Here’s the script: mqtt2notifysend.sh

Linux Mint uses systemd so I used the instructions here: https://www.baeldung.com/linux/bash-daemon-script

I added a flow to my node-red setup to catch errors and send them via MQTT.

Thanks David! It works like a champ.


Why I didn’t want to use Home Assistant for IoT

July 23, 2023

A post on facebook:

“Hi, my HA (Home Assistant running on Vmware Virtual Machine) looked too big, cca 59 GB according to the Vmware. I have deleted the backups i dont need. The db is 5,9 GB. Now the system monitor show 21 GB total size, but the vmdk is still 59 GB. How do i shrink the disk and/or reclaim the unused space? The “compact disk” in disk settings not working.”

Gigabytes? Dang.


Won’t buy from Wyze…

July 11, 2023

I drank the kool-aid and bought a couple of power plugs and color changing bulbs. They seemed so nice… 😉

They won’t share any information about using the devices to developers. That’s not great, but I see the author of esp2ino spent a lot of time creating software to do an OTA flash of Tasmota! Now we’re cooking!

Wyze found out and spent considerable time and effort to nerf the project. Sorry guys, if I’m not allowed to do what I like with my purchase I’m not using it. I’m sorry I gave them any money now.