Home Automation


This is my first foray into Home Automation (if you exclude fitting PIR sensors to stairwells, toilets etc), so I've attempted to explain the terms and protocols I've encountered and sometimes found confusing. It's an opinionated sort of blog too, there are two broad approaches to HA, one of these is the Right Way and the other is the Wrong Way, if you don't like my approach, there are plenty of other articles detailing how to do it the Wrong Way.

The Wrong Way

  • Buy Chinese (or other) light bulbs, switches or other devices which can be controlled from anywhere by an app on your phone. The way these work is that your device will talk to an externally controlled server which in turn can communicate to your phone app. What's wrong here is that your data is entirely under the control of someone else who almost certainly does not share your goals, yours is to control your device, theirs is to create profit, and your information has a monetary value. It relies on your internet connection too, so any line faults can stop you controlling your lightbulbs for example. Also, if the company goes out of business or “updates” it's products, your device may no longer be supported and just stop working even though it is still perfectly functional. This creates more electronic waste which the planet frankly does not need.
  • Allow your devices to be controlled by Alexa or Google etc. Whilst being very convenient, if your smart speaker cannot talk back to Amazon's or Google's servers if your internet goes down for example, you cannot control your light bulbs in the same room as yourself. Google and Amazon (and others) want to know what you are doing, they collect just about everything they can about you, knowledge is power as the saying goes. This alone should be enough to persuade you not to fall in to their walled garden with the fragrant and pretty flowers to entice you.
  • Data security and privacy - even if the anonymous company servers are well intentioned, they still stand the chance of being hacked. If they go offline, all the people who have bought their products will be unable to operate their devices. Whilst the company may have the servers back online quickly, there is a more insidious threat, most of these devices support “Over the Air Updates”, if a hacked server was to be instructed to initiate and update for all devices with deliberately infected or faulty firmware, your devices may become part of a botnet and spy on you, or just get bricked with no possibility of working again.

The Right Way

Your devices should do what you tell them to do, no one else should have any part in this. They should carry on working even if there is an internet outage, and they should carry on working for as long as you want them to, not be limited by support from the vendor.

How to achieve this (I've listed some software which helps me do this in the next section):-

  1. Central to almost all HA setups is an MQTT broker service, more of this below. It can run on a Raspberry Pi single board computer along with other software, or it can run in a Docker container.
  2. Sensors, your system needs data to work on, this could include temperature sensors for each room and either an external sensor or API feed for the external weather, it could include motion sensors (PIR) to detect movement to control lighting, or presence detectors to inform the control system when someone who should be in the house, actually is.
  3. Control software - your system needs logic to understand the sensor readings and convert the raw data to actionable data, eg. if it is colder than X degrees in a room and there is someone in it, tell the radiator controls to turn the heat up. But even if the room is unoccupied, maintain at least Y deg during certain hours but also at all times, ensure that the temperature is greater then Z deg for frost protection. If the temperature falls below the set limits, fire off an alert email etc.
  4. Actuators, these could be remote controlled radiator valves, or lights or sockets which have a device plugged in to them.


  1. MQTT - the most widely used broker (or server) seems to be Mosquitto (https://mosquitto.org/)
  2. Sensors, see Tuya / Tasmota section below
  3. Control Software - Node Red (https://nodered.org/) (Node Red info)
  4. Actuators - see Tuya below

Tuya / Tasmota

On my initial reading up on HA, I found some confusion between Tasmota / Tuya and took a little while to work it out. Quite simple really, Tuya is a Chinese company who produce a vast array of HA related devices and many of these are rebadged by resellers, eg. Lidl. These devices run Tuya's firmware which wants to talk out to their servers. As these devices all seem to ha have serial port solder pads (Jtag or similar) it has been possible to reflash these with custom firmware which talks mqtt locally. The leading project who have written such open source code is Tasmota.

Although most of the time you will have to reflash items yourself, some companies such as “athom” (on Ali Express) ship devices which is already running Tasmota firmware, so no flashing is required.


Jottings - Tasmota crib sheet

SR-201 - Ethernet controlled relay module interface:- SR201 network controlled module



This page has been accessed for:-
Today: 1
Yesterday: 0
Until now: 60

ha/start.txt · Last modified: 15/06/2022 17:11 by andrew