This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== B) Smart Heating ====== Your home, most probably, has some kind of heating system for those months of the year when the outside temperature is too low to be comfortable. At least, in most of the world, every home has some kind of heating system. Of course, then, why don't we make it smart? The goal of this **smart heating** is to warm up our home in a more efficient way, spend less money in doing so, and perhaps also help the environment along the way. Let me describe my heating approach and how my home heating system is structured, so the following will be easier to understand. Please consider that this is a complex matter, and many of the issues i have encountered over the years can be different from your experience, because every heating system is different, and mine is indeed a bit unique. ====== Key concepts ====== Here is a list of key concepts useful for the topic at hand. **eco temperature**: the temperature to use at night, or when nobody at home, or whenever you want to //save// on heating. **comfort temperature**: the temperature you want your room to have when you are in the room, or in general, you consider comfortable to stay in. **boiler**: with this word, i will indicate an heater generator. It could be a gar boiler, a wood pellet boiler, or whatever means you have to heat your home (heat pump...) **wood pellet boiler**: a specific heat generator that uses //wood pellets// as fuel, and it's directly connected to your radiators or radiating floors. This is usually like a wood/coal furnace, but more automated and can autofeed during the day. It comes with a few caveats, like needs a dedicated water circuit, has limitations on maximum water temperature, and must be refueled periodically (daily, weekly...) in order to keep working. ==== My heating system ==== I live in an 100 years old house, built mostly out of solid bricks and river stones, almost 1 meter thick walls. It's a multi-stories independent home, with four sides open to the winter wind and chill. During summer time my house stays cool even with 35+°C outside, and while we have installed A/C in the upper floors, it's not really needed. On the other side this means that in winter time heating is important. I usually turn on my heating by the start of October and i turn it off be the start of May. The house itself has radiators in every room, while floor heating is a trend now, i didn't installed it when i moved in for various reasons. My heating system is pretty complex because i have both a gas boiler and a wood pellet (=pellet) boiler. As it is customary in these cases, the gas boiler is directly installed on the radiators water circuit, while the pellet boiler has a dedicated water circuit and a copper heat exchange is in charge, coupled with a dedicated circulation pump, to heat the radiator water circuit and, well, circulate it when the gas boiler is off. This solution is pretty complex and requires a lot of logic to function properly, here is a very simple schema of it all: {{ :homeautomation:heating_system_rid.svg |}} * When the gas boiler is on, it's internal pump will circulate the water in the radiators, and that's pretty simple. * When the pellet boiler is on, it will heat the water in the pellet water circuit, the heat exchange will in turn heat the water in the radiators circuit, and the dedicated circulation pump will circulate the water in the radiators. In order for this to work, a water thermometer needs to be placed on the pipe coming out of the pellet boiler so that when the water is hot, the dedicated circulation pump can be turner on. This also requires relays to turn on and off power to the pump. As things cannot be that easy, it's mandatory that both boilers are never on at the same time, as this would cause an over-temperature in the pellet boiler water circuit which in turn will shut down the pellet boiler itself. And, lastly, the pellet boiler doesn't always turn on properly as for many reasons the startup phase might fail (bad pellet, burner filled up with sooth, defective ignition...) and in this case it's nice if after a reasonable timeout, if the pellet boiler fails to heat up the water, the gas boiler could be started automatically instead. That's pretty complicated, ah. Of course, there is yet a missing piece: unless you want to turn on and off the system yourself, it's nice to have some automation that can do that for us, and maybe be able to program it so it turns on early morning to warm up the house before you wake up. ==== First solution attempts ==== At first i went fully //traditional//. I placed an old fashioned thermostat (actually, two), run the wires from those to a nice set of switches that i manually switched to choose gas or pellet, plus a pretty complex approach with relays and such amenities to control the pump. I quickly moved to a //smarter// self-made approach using an [[http://www.orangepi.org/html/hardWare/computerAndMicrocontrollers/details/Orange-Pi-Zero.html|OrangePi Zero]] board with a few 12v relays, a 1wire igro-thermometer and wrote a custom dedicated software composed of a C++ back-end and a Javascript front-end to replace most of the original solution. I kept the 220v relay to start the pump, and that's it. This brought a very nice improvement, since i was able to control and check my heating system from the web. The //smarter// solution worked fine for a few years. I improved the software and the logic behind it a few times, until i discovered Home Assistant and ZigBee devices, now new amazing opportunities where available! ==== The smart solution ==== For a more efficient heating system, you need to be able to stop heating each room when it reaches the desired temperature. This will save you money on whatever fuel you are using (also solar, if you use heat pumps, more power for your accumulators or to resell), and will put less strain of your heat generators as well. To achieve this solution, unless your house has already been equipped with a thermostat in every room (mine wasn't) and unless your heating system has every room separated with electro-valves (mine wasn't), ZigBee and Home Assistant will come to the rescue. ZigBee is an amazing wireless system that can connect many //smart// objects that can then be controlled via automation in Home Assistant. I have replaced all (most, actually) of the valves of the radiators with ZigBee controlled valves (so called thermostat valves), and added in each room a dedicated ZigBee thermometer in a logical place to measure effective temperature. In fact, the all-in-one thermostat-valves suffer from a common issue of having the thermometer too close to the radiator itself. While you can control this by setting an offset to the measurement, it doesn't work well specially when there is not a good airflow nearby, like when the radiator is behind a curtain or near furniture. The solution is to add a separate thermometer, then use a Home Assistant blueprint to automatically adapt the thermostat-valve offset. Now i have Home Assistant, trough ZigBee thermostat-valves, which takes care of turning on and off the heating in each room independently. In addition, Home Assistant can also be used to define a schedule (under devices -> helpers) that can be used to define times of the day / week when you want the heating to be on, or off. By combining the schedule, and the overall status of ALL the thermostat-valves, Home Assistant is capable to generate a single output command: **heat** or **stop heating**. This signal can be used to control the gas and the pellet boilers. The high-level concept then can be summarized as: * The heating schedule in Home Assistant defines when the heating should be on * Each thermostat-valve has it's offset corrected automatically using a dedicated thermometer trough a blueprint * This information can be collected and sent to the OrangePi Zero to actually control the heat generators. * The OrangePi Zero controls the generators turning them on or off depending on the Home Assistant command. In theory, by using dry-contact ZigBee relays i could skip the OrangePi, but implementing the logic behind to properly manage both generators, including the dedicated pump and the various emergency conditions is something i have not yet moved to Home Assistant, so i am still using the OrangePi with it's relays, i just simplified and rewrote the custom software backend. Let's break down this approach step by step. === Selecting the ZigBee components === I am a big fan of [[https://sonoff.tech/|Sonoff]] ZigBee devices. I own many and they are of top quality. Their thermo-valves (the [[https://sonoff.tech/product/home-appliances/trvzb/|TRVZB]]) works fine. The only complaint i have is the size, which is a bit large. As thermometers, i have different models from different vendors. I tend to purchase the cheapest i find when i need them. The Sonoff one is nice and has a huge display, but they use a pretty strange battery, so i only purchased two then switched to a different vendor that uses the more common CR2032 battery. A single battery in geenral seems to last over one year. Go ahead, install the thermo-valves, connect them all to Home Assistant as well as the thermometers. Remember to give them meaningful names! === Creating the schedule & main temperature set === Create a schedule to control when during the day and the week you want your home to be in a **comfort** temperature, or al **eco** temperature. This schedule will be the base on which your heating will be activated or deactivated. This same schedule is also used to decide when to use the pellet boiler and when to use only the gas boiler in conjunction with two dedicated toggles, described below. Go to: * Settings -> Devices -> helpers -> create a new schedule You could create more than one schedule then use a selector connected to the blueprint below to choose between the scheduler. Now, also create two numeric helpers to define the **eco** and the **comfort** temperatures. Go to: * Settings -> Devices -> helpers -> create two new numeric values I called them **eco temperature** and **comform temperature**. === The heating control Blueprint === While it is indeed possible to write a custom automation script in Home Assistant, i did some research and found out an amazing Blueprint that already does what i need, and even so much more. It is the [[https://community.home-assistant.io/t/advanced-heating-control/469873|Advance Heating Control Blueprint]]. It is actually pretty complex and at first, it can be overwhelming. You need to create an automation for each thermostat-valve and thermometer, which means one for each room: * Create a new automation from the blueprint * Assign the thermostat entity and the thermometer entity for the room * Assign the schedule * Setup both an "eco" and a "comfort" temperature (here you can use the temperature set defined in the previous step) You can fine tune lots of details, i will not get too much specific, it's fun to explore by yourself. At the end of the customization, you will have one automation based on this blueprint for each room of your house. This automation will automatically adjust the thermostat-valve offset to match the thermometer value and change the thermostat-valve threshold value depending on the time of day / week and the schedule, automatically switching between //eco// (=heating off) or comfort (=heating on) values. You can specify an external helper (the temperature set above) so that all your rooms can share the same temperature, or use room-specific value at your liking. === Commanding the generators === The basic logic is simple: whenever at least ONE thermo-valve is open (heating), the generators should be operative. Only when ALL the thermo-valves are closed (idle), then the generators can be turned off (actually the pellet is not turned on or off, but switched between minimum to modulation...). The point now is how to connect Home Assistant with the OrangePi Zero... Well, using [[homeautomation:protocols:mqtt|MQTT]] of course! So, setup your Mosquitto broker as defined in the link on Home Assistant. I have rewritten the OrangePi Zero code to become an MQTT client and connect to the Home Assistant broker, this is pretty simple following the Mosquitto documentation and example code. The code to my dedicated control software is published [[https://github.com/gardiol/pithermo|here]] under the GPLv3 license. The choice between heating with the gas or the pellet boiler, or both, is controlled by two dedicated Home Assistant toggles (create them from settings -> devices -> helpers): * **use_pellet** toggle: if true, pellet boiler is used, if false, gas boiler is used * **quick heat** toggle: if true, gas boiler will be turner on together with the pellet boiler. This is important because the pellet boiler will take up to one hour before it's startup phase is over and the hot water start circulating. Activating the gas boiler too will speed up initial warming of the house (the safety measures inside the OrangePi will take care to turn the gass off once the pellet is hot) The key point here is that when in eco mode (at night, and such...) only the gas boiler will be used for heating. Instead, the bulk of the comfort heating will be done with the pellet boiler, or the gas boiler (for example, when away from home for a few days and the pellet tank will be empty). I choose to chain the toggles together with the thermostat-valves states to send the associated MQTT topic to the OrangePi so that all the topics will be published together. Better send the information twice, than forget about it once. So, let's assume we have the //MQTT topics// **heating/consensus**, **heating/usegas** and **heating/usepellet**. You can use the following automation script to automatically publish the topics when the termostat-valves and toggles state change: <code yaml> alias: Send topics to OrangePi description: Send heating topics triggers: - trigger: state entity_id: - sensor.termo_bathroom_hvac_action - trigger: state entity_id: - sensor.termo_kitchen_hvac_action - trigger: state entity_id: - sensor.termo_livingroom_hvac_action - trigger: state entity_id: - input_boolean.use_pellet - trigger: state entity_id: - input_boolean.quick_heat - trigger: state entity_id: - schedule.my_heating_schedule actions: - action: mqtt.publish data: payload: >- {{ is_state('sensor.termo_bathroom_hvac_action', 'heating') or is_state('sensor.termo_kitchen_hvac_action', 'heating') or is_state('sensor.termo_livingroom_hvac_action', 'heating') }} topic: heating/feedback retain: true - action: mqtt.publish metadata: {} data: evaluate_payload: false qos: 0 retain: true topic: heating/usegas payload: |- {{ is_state('input_boolean.use_pellet', 'off') or is_state('input_boolean.quick_heat', 'on') }} - action: mqtt.publish metadata: {} data: evaluate_payload: false qos: 0 retain: true topic: heating/usepellet payload: "{{ is_state('schedule.my_heating_schedule', 'on') }}" mode: single </code> Of course you need to specify all the thermo-valves here. You should check under //Developers -> states// exactly which states your thermostats use. Usually, it should be under the entity //hvac_action// of the thermostat, but you need to check as YMMV for different devices, maybe, i have no idea. === Feedbacks from the heating system to Home Assistant === Since i like to keep everything under control, the OrangePi custom software will publish a status MQTT topic reporting if the gas boiler, the pellet boiler are on or off, and if the pellet boiler water output is hot or cold. This can be achieved by adding the following custom YAML lines inside your **configuration.yaml** file: <code yaml> mqtt: binary_sensor: - name: "Pellet_status" state_topic: "heating/pellet_status" device_class: "power" value_template: "{{ value_json.on }}" payload_on: 1 payload_off: 0 unique_id: "pellet_on" - name: "Pellet_hot" state_topic: "heating/pellet_hot" device_class: "heat" value_template: "{{ value_json.hot }}" payload_on: 1 payload_off: 0 unique_id: "pellet_hot" - name: "Gas_status" state_topic: "heating/gas_status" device_class: "power" value_template: "{{ value_json.on }}" payload_on: 1 payload_off: 0 unique_id: "gas_on" </code> ==== Future steps ==== Maybe i could remove the OrangePi Zero altogether using some ZigBee relays, or maybe coupling ZigBee switches with the relays i have today. This would require to rewrite in Home Assistant the logic between switching the generators and the various protection logic.