Sean Blanchfield - page 3
-
Real-Time Picture-in-Picture Camera Feeds on your TV with Home Assistant
I’ve found a way to get a RTSP camera feed to display in a picture-in-picture popup on my TV, without interrupting any other viewing that might be going on. This all happens locally, without any cloud services, and should work with any IP camera that provides an RTSP stream. This is achieved using a modest IP camera, an Android TV (in my case an Nvidia Shield set top box), a side-loaded app called Pipup on the Android TV and Home Assistant. Read on to find out how.
-
Docker Swarm Lowers the Shields
Today I learned that Docker automatically does extremely wreckless and dangerous things to the firewall on every node in a docker swarm, which leaves various swarm services wide open to the internet, and that Docker provides no way to turn off this behavior. I spent a lot of time today trying to understand what the hell was happening, and then a lot more time trying to find a solution to fix it. I think I found a better solution than suggested anywhere else, so here it is for anyone who stumbles here via a search engine.
-
Virtual Energy Meters with PowerCalc
In my last post I described how I optimised my home heating with Home Assistant and then created virtual energy sensors to monitor my estimated gas usage from Home Assistant’s Energy Dashboard. In this post I’ll describe how I used the same strategy to monitor the real-time energy use of the majority of devices in my house without using any power meters. A big shout out to the amazing Powercalc integration for Home Assistant, which makes this a relatively simple process, with extremely powerful results.
-
Virtual Gas Meters in Home Assistant
Unfortunately, we do not have smart gas meters in Ireland. However, I realised that I could use Home Assistant to create virtual gas meters, which provide a good real-time estimate of natural gas usage.
The only appliance that uses gas in our house is our combi-boiler, which has the job of heating the radiators for central heating, and heating domestic hot water. In my previous post I discussed how I took direct control of my central heating by replacing Nest with a z-wave relay controlled by Home Assistant. This allowed Home Assistant to know exactly when the boiler was burning gas. So long as the radiators are balanced and the TRVs are properly set, then the boiler should only be switched on when heating is required, during which time it should use a steady amount of gas. This conclusion allowed me to create some virtual energy sensors based on boiler run time, and add these into the Home Assistant Energy dashboard.
Gas consumption chart from the Home Assistant Energy Dashboard
Tracking Central Heating Gas Usage
To start with, I needed to study gas consumption vs boiler activity.
sensor boiler_energy: - platform: history_stats name: 'Boiler Cumulative Time Today' entity_id: switch.combi_boiler_relay_switch state: "on" type: time start: "{{ now().replace(hour=0, minute=0, second=0) }}" end: "{{ now() }}"
I then started taking manual readings from my gas meter, and noted them down in a spreadsheet along with the value of the ‘Boiler Cumulative Time Today’ sensor. The meter readings were in cubic meters, which I could convert to kWh by multiplying them by the “conversion factor” given on my gas utility bills. My current conversion factor is 11.401kWh / cubic meter, but this can vary depending on the source of the gas supply. My comparing the meter readings to the number of hours the boiler ran between each reading, I could estimate that I was typically using about 14kWh of gas for every hour that the boiler was on.
I stored my estimate of 14000 Wh/hour in a new input helper called
input_number.combi_boiler_power_usage
, and then created a new template sensor that evaluates to the boiler’s current power consumption in Watts:template: - sensor: - name: combi_boiler_current_power_usage unique_id: combi_boiler_current_power_usage unit_of_measurement: W device_class: power state_class: measurement state: > {{ is_state('switch.combi_boiler_relay_switch', 'on') | iif(states('input_number.combi_boiler_power_usage'), 0) }}
The state of the above sensor will evaluate to zero if the boiler relay switch is off, or to the value of the
input_number.combi_boiler_power_usage
input helper if the boiler is on. Some note on the attributes defined above:unit_of_measurement: W
is important. According to the docs for the integration platform, a sensor that measures in units of “W” will be integrated into an energy sensor in units of kWh.device_class: power
is important. From my testing, this is necessary for the integration platform to produce an output sensor that has the attributedevice_class: energy
, which is necessary for it to work with the Energy Dashboard.state_class: measurement
. According to the sensor platform docs this describes the sensor as measuring a current value (vs a predicted value or an aggregate of some kind), and it is necessary to opt into long-term statistics. I haven’t tested if it is strictly necessary for our purposes, but it seems like good practice.
I then added a new sensor using the integration platform (i.e., the Home Assistant integration called “integration”, in the calculus sense of the word) to integrate (as in sum up) the boiler power over time to get total energy. I originally implemented this in yaml, but these days you can achieve the same thing by adding an Integration helper.
Here is the original yaml code that achieved the same thing:
sensor: - platform: integration name: boiler_energy_kwh source: sensor.combi_boiler_current_power_usage unit_prefix: k method: left
I could then go to the Energy Dashboard and add this new sensor
sensor.boiler_energy_kwh
as a “Gas Source”.Tracking Domestic Hot Water Gas Usage
My combi boiler also heats hot water for the shower and wash basins in the house. It is supplied with pumped tank water for this purpose. Whenever a hot water tap / faucet opens, the pump starts and the boiler heats the water on the fly. The pump only supplies the boiler, and nothing else. I could therefore apply a similar strategy to track the gas consumption for hot water heating. All I needed to do was figure out when the pump was running, and what the average gas used was per second.
I installed a Shelly 1PM to track the pump activity. Whenever the pump is using power, I know that the boiler is heating hot water.
To calculate gas energy used for domestic hot water heating, I studied gas usage during a period during the Summer, when central heating was completely turned off. I noted that during a period of about 80 days, the pump ran for 33.549 hours and that 40.78 cubic meters (464.995 kWh) of gas was used (according to manual readings taken from the physical gas meter). This means that my boiler has a gas power consumption of 13.86kW for domestic hot water heating.
I then used a similar strategy as outlined above for central heating to get this represented in Home Assistant.
If you made it this far…
A virtual energy sensor strategy exists, which allows you to use some prior knowledge about a device energy consumption and some current knowledge about device state to work out how much power the device is currently using. You can go wild and apply this strategy to most of the electrical devices in your house, and get a very detailed real-time and actionable picture of your energy consumption.
Bram Gerritsen has created the wonderful Powercalc integration to do just this. In my next post I describe how I used Powercalc to accurately track power for the majority of devices in my house without using any power meters.
-
Automating Heating with Home Assistant
I’ve been on a mission to use Home Assistant to optimize my home heating, with the dual goals of reducing gas usage and increasing comfort. It’s worked out very well - I’ve mostly eliminated wasteful overheating, and I now have much more consistent temperatures throughout the house. Thanks to the power of Home Assistant, I managed to do this without having to invest in new smart devices. In fact, I ended up selling my Google Nest thermostat! I thought I’d share some notes on the process.
-
Automating the HY367 / HY368 Smart Radiator Actuator in Home Assistant
The HY367 and HY368 Smart Radiator Actuators are relatively cheap smart thermostatic valves that you can attach to the radiators in your house, effectively turning each room into an individually-controlled heating zone. They seem to be on sale rebadged as Hysen, Blinli, Moeshouse and Tuya (I think Tuya is probably the real manufacturer). As of February 2020, you can get these for as little as $22 each on AliExpress. Unfortunately, the instruction leaflet that they come with is pretty cryptic and omits some important information. After hours of experimentation, here are some notes that may be useful for anyone else trying to integrate these into Home Assistant.
-
The road to native ES6 SPAs
TL;DR. In this post I go on a major rant against the Javascript/Babel/Webpack/Node development stack, and then talk about the problems I’m facing in my attempt to jettison that stack and instead make my javascript application run natively in web browsers. (Run javascript in a browser? Revolutionary, I know!)