<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Home Assistant on Codewrite Dev Doc</title><link>https://dev.codewrite.co.uk/categories/home-assistant/</link><description>Recent content in Home Assistant on Codewrite Dev Doc</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Tue, 17 Nov 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://dev.codewrite.co.uk/categories/home-assistant/index.xml" rel="self" type="application/rss+xml"/><item><title>Home Assistant Fridge / Freezer Notifications</title><link>https://dev.codewrite.co.uk/posts/2026-11-17-ha-fridge-notifications1/</link><pubDate>Tue, 17 Nov 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-11-17-ha-fridge-notifications1/</guid><description>&lt;p&gt;In the house there is a fridge, freezer and fridge freezer with smart plugs that show how much power they are using.
One of my dashboards shows the power used (among other things). They all switch on and off periodically as can be seen here:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/HA-Fridge-Notifications1/FridgePowerChart.png" alt="Fridge Power Chart" /&gt;&lt;/p&gt;
&lt;p&gt;It occurred to me that if they stop switching on or off, there is a problem. If an appliance doesn&amp;rsquo;t switch on, it means that there is a problem with the power - maybe the plug has been pulled out, or it has stopped working. If however it doesn&amp;rsquo;t turn off, that indicates another problem - maybe the door has been left open. So I thought about how to detect both situations. You could just have automations that trigger when an appliance has been on (or off) for a certain time, but I decided it would be nice to see what was going on graphically. So I created some template sensors that showed the power integral:&lt;/p&gt;</description></item><item><title>Home Assistant UPS Mk2 Software Part 1</title><link>https://dev.codewrite.co.uk/posts/2026-11-11-ha-ups-mk2-software1/</link><pubDate>Wed, 11 Nov 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-11-11-ha-ups-mk2-software1/</guid><description>&lt;h2 id="determining-the-battery-state-of-charge-soc"&gt;Determining the Battery State of Charge (SOC)&lt;a class="anchor" href="#determining-the-battery-state-of-charge-soc"&gt;#&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/HA-UPS-mk2/LeadAcidBatteryVoltageVsSOC.png" alt="Lead Acid Battery Voltage vs SOC" /&gt;&lt;/p&gt;
&lt;p&gt;The voltage of a lead acid battery vs the SOC can be approximated to a straight line. This isn&amp;rsquo;t completely accurate especially at the extremes (0% and 100%) but it&amp;rsquo;s close enough. Especially given that batteries vary, the voltage can&amp;rsquo;t be measured 100% accurately and it&amp;rsquo;s a really bad idea to run a lead-acid battery down to 0% (which is about 10.5V). So the following equation gives quite a good approximation of the battery voltage (at rest):&lt;/p&gt;</description></item><item><title>Home Assistant UPS Mk2 Testing Part 2</title><link>https://dev.codewrite.co.uk/posts/2026-11-07-ha-ups-mk2-testing2/</link><pubDate>Sat, 07 Nov 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-11-07-ha-ups-mk2-testing2/</guid><description>&lt;p&gt;When testing the charge circuit, something didn&amp;rsquo;t seem quite right&amp;hellip;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/HA-UPS-mk2/ha-ups2-charging.png" alt="HA UPS Mk2 Charging" /&gt;&lt;/p&gt;
&lt;p&gt;The battery current was about 40mA even though the charging duty cycle was set to 3 (with a maximum of 255). A duty cycle of 3 should mean that the battery is charging for about 12us and not charging for the other 988us (the PWM should be running at 1kHz). If this was correct, it would mean that the current in the on phase was 3.4A (40mA * 255 / 3). Since the charging was via a 13Ω resistor, this seemed unlikely.&lt;/p&gt;</description></item><item><title>Home Assistant UPS Mk2 Testing Part 1a</title><link>https://dev.codewrite.co.uk/posts/2026-11-06-ha-ups-mk2-testing1a/</link><pubDate>Fri, 06 Nov 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-11-06-ha-ups-mk2-testing1a/</guid><description>&lt;p&gt;Something I noticed when I connected and disconnected the USB serial port on the Arduino Nano was that the Nano would reset. After a bit of googling it turned out that this was caused by DTR on the CH340 serial chip being connected to the RESET pin (via a capacitor). So although I was powering the Nano from the UPS, when I shut down Home Assistant on the Raspberry Pi, HA would toggle DTR causing the Nano to reset.&lt;/p&gt;</description></item><item><title>Home Assistant UPS Mk2 Testing Part 1</title><link>https://dev.codewrite.co.uk/posts/2026-10-23-ha-ups-mk2-testing1/</link><pubDate>Fri, 23 Oct 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-10-23-ha-ups-mk2-testing1/</guid><description>&lt;p&gt;This was my test setup:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/HA-UPS-mk2/HA-UPS-Test-Setup-1.jpg" alt="HA UPS Mk2 Test Setup 1" /&gt;&lt;/p&gt;
&lt;p&gt;The only thing I wasn&amp;rsquo;t testing was the Raspberry Pi voltage. This left input voltage and current and battery voltage and current, from which I could work out things like efficiency and estimated run time.&lt;/p&gt;
&lt;p&gt;I had 4 lead acid batteries that I got from a radio club junk sale. Three were 4Ah and one was 800mAh. I tried that first. Under load the voltage dropped considerably. It was clear that the battery had degraded, so I decided not to use it.&lt;/p&gt;</description></item><item><title>Home Assistant UPS Mk II</title><link>https://dev.codewrite.co.uk/posts/2026-09-27-ha-ups-mk2/</link><pubDate>Sun, 27 Sep 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-09-27-ha-ups-mk2/</guid><description>&lt;p&gt;I decided to have an uninterruptible power supply (UPS) for my Home Assistant (running on a Raspberry Pi).
The design I came up with is shown below:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/HA-UPS-mk2/PCB-Block-Diagram.png" alt="HA UPS Mk2 Block Diagram" /&gt;&lt;/p&gt;
&lt;p&gt;The input from the mains is supplied by a 15V AC to DC adapter (wall wart). This is shown as Vcc/Vss on the diagram above. There are two DC to DC converters, one that powers the Raspberry Pi and one that powers an Arduino Nano. The rPi converter is a LM2596 and the Nano converter is a smaller device (which says it can deliver 3A but it only needs to deliver about 20mA).&lt;/p&gt;</description></item><item><title>Mouse Trap Mk II</title><link>https://dev.codewrite.co.uk/posts/2026-03-24-mousetrap-mk2/</link><pubDate>Tue, 24 Mar 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-03-24-mousetrap-mk2/</guid><description>&lt;p&gt;It turned out that the original
&lt;a href="https://dev.codewrite.co.uk/posts/2026-03-11-mousetrap/"&gt;mouse trap&lt;/a&gt;
wasn&amp;rsquo;t sensitive enough. Very small mice just didn&amp;rsquo;t trigger it. So I decided to improve the design.&lt;/p&gt;
&lt;p&gt;The case of the trap is clear, so I thought I could have a beam of light going from one side to the other. When the mouse broke the beam, it would trigger a solenoid that would close the door. After some thought, I decided to use a white LED and LDR (so no lasers or signal modulation). The LED was quite bright (even though it was only driven by 5mA) but bright lights don&amp;rsquo;t seem to put the mice off. The LED illuminated the LDR much more than ambient light (except in bright sunlight - but that&amp;rsquo;s not the best conditions to catch mice, and even if it did need to work in sunlight the case could be covered to reduce the ambient light falling on the LDR).&lt;/p&gt;</description></item><item><title>Mouse Trap Mk I</title><link>https://dev.codewrite.co.uk/posts/2026-03-11-mousetrap/</link><pubDate>Wed, 11 Mar 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-03-11-mousetrap/</guid><description>&lt;p&gt;So we thought we might have a mouse under the kitchen units&amp;hellip;&lt;/p&gt;
&lt;p&gt;This isn&amp;rsquo;t the first time we&amp;rsquo;ve had mice. And if you don&amp;rsquo;t think there are any in your house, well maybe it&amp;rsquo;s because you haven&amp;rsquo;t noticed them. They are very elusive, generally coming out in the middle of the night, and they are &lt;strong&gt;very&lt;/strong&gt; shy!&lt;/p&gt;
&lt;p&gt;I already had all the bits I needed to catch and re-home the mouse (you have to take it quite a long way - a mile or two - otherwise it will find it&amp;rsquo;s way back!). The central component is a humane mouse trap, which has a pressure sensitive pad and door that stops the mouse escaping. They typically cost about £10 (e.g. on Amazon). My advice - do a bit of research - don&amp;rsquo;t just get the cheapest one. They are very sensitive, but mice are very light, so the one I have had to be adjusted by putting a couple of coins on the pressure pad so that even the lightest mouse would trigger it.&lt;/p&gt;</description></item><item><title>Home Assistant Serial Link to an Arduino</title><link>https://dev.codewrite.co.uk/posts/2026-02-27-homeassistantwithserialarduino/</link><pubDate>Fri, 27 Feb 2026 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2026-02-27-homeassistantwithserialarduino/</guid><description>&lt;p&gt;The purpose of this project was to connect an Arduino Nano to the USB port that Home Assistant was running on. For me that is a Raspberry Pi 4 but this solution should work with any Home Assistant hardware. And the reason for using a serial connection over USB (rather than wirelessly with WiFi or similar) could be for many reasons:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Wifi may not be available (e.g. if the network is down)&lt;/li&gt;
&lt;li&gt;It is more secure&lt;/li&gt;
&lt;li&gt;It is un-jammable&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The ultimate plan for me was to create an uninterruptable power supply for Home Assistant from bits that I had:&lt;/p&gt;</description></item><item><title>Home Assistant REST Devices and Sensors</title><link>https://dev.codewrite.co.uk/posts/2022-12-22-hassconfigfiles/</link><pubDate>Thu, 22 Dec 2022 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2022-12-22-hassconfigfiles/</guid><description>&lt;p&gt;A while back (before I was using Home Assistant) I built a COB light controller board. The idea was to have lights under the eaves all round the outside of our house (bungalow). They look like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://dev.codewrite.co.uk/images/COBLightsInHASS/LightsUnderEaves.jpg" alt="COB Lights under Eaves" /&gt;&lt;/p&gt;
&lt;p&gt;In this picture there are three lights, but around the rest of the house there are about 15 in total on 4 different circuits. I won&amp;rsquo;t go into the detail here other than to say that there is a controller board up in the loft that uses a Wemos D1 mini which serves up a REST interface to turn the lights on and off. I did a presentation for the London Raspberry Pi group. The link to my GitHub page is here:&lt;/p&gt;</description></item><item><title>Home Assistant on the Raspberry Pi</title><link>https://dev.codewrite.co.uk/posts/2022-03-28-raspberrypihomeassistant/</link><pubDate>Mon, 28 Mar 2022 00:00:00 +0000</pubDate><guid>https://dev.codewrite.co.uk/posts/2022-03-28-raspberrypihomeassistant/</guid><description>&lt;p&gt;I use Home Assistant (HASS) around the house to switch some of the lights on and off automatically and to monitor the temperature. I plan to use HASS for other automation tasks, maybe controlling things in the garden (e.g. watering plants in the greenhouse) and inside to turn the heating on and off. In this post will describe what I currently have and some ideas for the future.&lt;/p&gt;
&lt;p&gt;The main reason that I like HASS is that it separates functionality, specifically keeping the configuration and control logic away from the sensors and devices. This makes everything much more scalable and maintainable. I could write the software to control everything, but like most software engineers I would rather not reinvent the wheel, especially when you have something like HASS that does such a good job with much less effort.&lt;/p&gt;</description></item></channel></rss>