Home Assistant controls microcontrollers over MQTT
Setting Up Tasmota
Before proceeding, you first need to connect the temperature sensor to one of the GPIOs used for flashing (RX/TX), which is now free. You can do this with a pull-up resistor and the 3.3V and GND connections [5]. After wiring the elements, it's time to configure the sensor; its name will have already appeared in the GUI (Figure 3).
You also need to assign a password for the web GUI and activate MQTT (Figure 4), which you will be using to deliver the data to Home Assistant. The broker and topic are configured in the corresponding entries in the web interface, where you will also find the Tasmota console, which lets you issue commands directly and set up the parameterization.
At this point at the latest, I recommend studying the very good documentation from Tasmota's GitHub repository. For this project, I used a command that makes the later integration with Home Assistant by autodiscovery very easy by telling Tasmota to announce all available topics (setoption19 on
). At the end of the day, Tasmota advertises itself in the GUI as a web switch with a temperature sensor (Figure 5). You can also view the MQTT publishing in the Console, if needed.
Integration
To make the components available in Home Assistant, you now need to set up MQTT integration in the GUI. To do so, all you need is the IP address and port of the broker you are using; by default, this is set to 1883. After the setup, the new MQTT devices should be displayed (Figure 6).
After clicking on the entities URL, both the switch and the temperature sensor are shown as available Home Assistant entities, and you can now use them in the usual way (Figure 7). In combination with the relay in the Sonoff module, the familiar automation features of Home Assistant can now be used to implement, say, a simple thermostat control.
Conclusions
The Tasmota option associated with Home Assistant's autodiscovery of MQTT integration easily makes this DIY solution as convenient as the commercial counterparts described in the previous article. Homebrewing turns out to be worthwhile – and great fun, too.
Infos
- "Z-Wave Home Assistant" by Gerhard Schauer, Linux Magazine, issue 248, July 2021, pg.56, https://www.linuxpromagazine.com/Issues/2021/248/Z-Wave-Home-Assistant/
- Sonoff Basic R2 Power: https://tasmota.github.io/docs/devices/Sonoff-Basic/#sonoff-basic-r2
- Getting Started: https://tasmota.github.io/docs/Getting-Started/
- Tasmota repository: https://tasmota.github.io
- Wiring Tasmota: https://tasmota.github.io/docs/DS18x20/
« Previous 1 2
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Halcyon Creates Anti-Ransomware Protection for Linux
As more Linux systems are targeted by ransomware, Halcyon is stepping up its protection.
-
Valve and Arch Linux Announce Collaboration
Valve and Arch have come together for two projects that will have a serious impact on the Linux distribution.
-
Hacker Successfully Runs Linux on a CPU from the Early ‘70s
From the office of "Look what I can do," Dmitry Grinberg was able to get Linux running on a processor that was created in 1971.
-
OSI and LPI Form Strategic Alliance
With a goal of strengthening Linux and open source communities, this new alliance aims to nurture the growth of more highly skilled professionals.
-
Fedora 41 Beta Available with Some Interesting Additions
If you're a Fedora fan, you'll be excited to hear the beta version of the latest release is now available for testing and includes plenty of updates.
-
AlmaLinux Unveils New Hardware Certification Process
The AlmaLinux Hardware Certification Program run by the Certification Special Interest Group (SIG) aims to ensure seamless compatibility between AlmaLinux and a wide range of hardware configurations.
-
Wind River Introduces eLxr Pro Linux Solution
eLxr Pro offers an end-to-end Linux solution backed by expert commercial support.
-
Juno Tab 3 Launches with Ubuntu 24.04
Anyone looking for a full-blown Linux tablet need look no further. Juno has released the Tab 3.
-
New KDE Slimbook Plasma Available for Preorder
Powered by an AMD Ryzen CPU, the latest KDE Slimbook laptop is powerful enough for local AI tasks.
-
Rhino Linux Announces Latest "Quick Update"
If you prefer your Linux distribution to be of the rolling type, Rhino Linux delivers a beautiful and reliable experience.