====== Home Automation ====== ===== Background ===== 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 (Checkout how much info RING doorbells send to Amazon and what Kindle logs about your usage), 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):- - Central to almost all HA setups is an MQTT broker service, more of this below. It can run on a [[ha:raspberrypi|Raspberry Pi]] single board computer along with other software, or it can run in a Docker container. - 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. - 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. - Actuators, these could be remote controlled radiator valves, or lights or sockets which have a device plugged in to them. ===== References ===== - MQTT ([[ha:mqtt|MQTT broker service]] ) - the most widely used broker (or server) seems to be Mosquitto ([[https://mosquitto.org/]]) - Sensors, see Tuya / Tasmota section below - External API (eg https://lornajane.net/posts/2012/building-on-datapoint-weather-with-icons) - Control Software - Node Red ([[https://nodered.org/]]) ([[ha:nodered|Node Red info]]) - Actuators - see Tuya below ===== Tuya / Tasmota ===== {{ :ha:pre-flashed-tasmota-smart-bulb-esp8285-works-with-home-assistant.jpg_220x220xz.png?150|}} 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. [[https://siytek.com/how-to-flash-tasmota-the-easy-way/]] Jottings - [[ha:tasmota|Tasmota crib sheet]] SR-201 - Ethernet controlled relay module interface:- [[ha:sr201|SR201 network controlled module]] ===== Links ===== This article sums up all my concerns about buying in to someone elses whatever and not controlling it. [[https://gizmodo.com/in-2030-you-wont-own-any-gadgets-1847176540]] This page has been accessed:- \\ Today: {{counter|today}} \\ Yesterday: {{counter|yesterday}} \\ Until now: {{counter|total}} \\