How to use Home Assistant for heating and cooling

I have made several posts regarding temperaturein some way, and now I'm back with a post using Home Assistant(HA) and controlling temperature.

The primary purpose of this post is to address an upcoming issue with our floor heating system. However, it may also provide some assistance for other temperature control problems using HA "Generic Thermostat"


As said before I'm more comfortable with Node-RED then YAML, in HA, so .....😎

Intro
I really want to start with simple hardware so I'm using
  • Shelly 1, relay
  • SONOFF SNZB-02D, temperature
  • LK floor heating system(Installed 2009)
Prerequisites
HA installed
Shelly, HA integration with hardware
Zigbee, HA integration with a coordinator
Generic Thermostat, HA integration

and if using Node-red

Node-RED, HA add-on
Node-RED Companion, HA HACS integration
Node-RED HA web socket, NodeRED module

Setup
Setup the Thermostat with a name, in my case "pigrum", and select "Temp sensor" and "Switch" and continue according to your preferences.
A entity with "climate.your_name" will be created and then check the function in "Overview" dashboard 

Remarks
  • Since underfloor heating is very slow the "Minimum cycle duration" is set to 30 minutes.
  • The valves in our under floor heating are "Normally open" !! This means that when power disappears, or something breaks, the valves will go fully open. Since the Thermostat don't have an inverted output you have to set it to "Cooling mode".
Change thermostat mode
HA way
To change the thermostat mode between "home" and "away" create a toggling switch via "Settings => Devices & services => Helpers => Create helper => Toggle". With the name "Climate Mode Home/Away" an entity with name "input_boolean.climate_mode_home_away" will be created.

Continue with creating an automation via " Settings => Automations & Scenes => Create Automation => Create new automation". Then using the 3 dots upper right you will reach "Edit in YAML" and paste the code below.

alias: Climate Mode
description: ""
triggers:
  - entity_id: input_boolean.climate_mode_home_away
    trigger: state
actions:
  - target:
      entity_id: climate.pigrum
    data:
      preset_mode: |
        {% if is_state('input_boolean.climate_mode_home_away', 'off') %}
          home
        {% else %}
          away
        {% endif %}
    action: climate.set_preset_mode
mode: single

And then test the switch in the "Overview" dashboard !

Node-RED way
The flow below is just a very rough start for those who are willing to test. The "current state" node is a nice way to get info about the thermostat entity  "climate.pigrum". The other node in the flow is an "action" node with action "climate.set_preset_mode" with data "{"preset_mode": "home"}" so the thermostat will be set to "home".

I think this is more straight forward than the above HA way, or ?

NR flow
[{"id":"cbeb6c60cefe2830","type":"tab","label":"Export","disabled":false,"info":"","env":[]},{"id":"4a907c0d23fac558","type":"api-current-state","z":"cbeb6c60cefe2830","name":"","server":"5c2bcbd9.6b08e4","version":3,"outputs":1,"halt_if":"","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.pigrum","state_type":"str","blockInputOverrides":true,"outputProperties":[{"property":"payload","propertyType":"msg","value":"string","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"0","forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":360,"y":60,"wires":[["cc1a01c0d6eddbc3"]]},{"id":"447ff94bc802ca84","type":"inject","z":"cbeb6c60cefe2830","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":60,"wires":[["4a907c0d23fac558"]]},{"id":"cc1a01c0d6eddbc3","type":"debug","z":"cbeb6c60cefe2830","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":100,"wires":[]},{"id":"6d06d1a207d1b51d","type":"api-call-service","z":"cbeb6c60cefe2830","name":"","server":"5c2bcbd9.6b08e4","version":7,"debugenabled":false,"action":"climate.set_preset_mode","floorId":[],"areaId":[],"deviceId":[],"entityId":["climate.pigrum"],"labelId":[],"data":"{\"preset_mode\": \"home\"}","dataType":"jsonata","mergeContext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","blockInputOverrides":true,"domain":"climate","service":"set_preset_mode","x":350,"y":120,"wires":[["cc1a01c0d6eddbc3"]]},{"id":"b3587c834b392cb6","type":"inject","z":"cbeb6c60cefe2830","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":120,"wires":[["6d06d1a207d1b51d"]]},{"id":"5c2bcbd9.6b08e4","type":"server","name":"Home Assistant","addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"","connectionDelay":false,"cacheJson":false,"heartbeat":false,"heartbeatInterval":"","statusSeparator":"","enableGlobalContextStore":false},{"id":"a70f4a87925f3fa6","type":"global-config","env":[],"modules":{"node-red-contrib-home-assistant-websocket":"0.80.3"}}]

Comments

Popular posts, last 30 days

iCloud drive sync, or mount, with a Linux, Ubuntu, device

Raspberry Pi OS Lite with GUI, RDP, VNC, Chromium

Installing Ubuntu 24.04 or 24.10/25.04 on an old MacBook Air(2011)

Home Assistant with VirtualBox or Proxmox or Linux KVM ???

Waveshare CAN hat with Signal K & OpenPlotter

IKEA Bäve dimmer hack II

Clone the Raspberry boot disk

IVT, Bosch heat pump easy integration, Home Assistant

Raspberry Pi 2, 3, 4, 5 USB SSD or USB drive boot

SeaTalk1 to NMEA 0183 converter, DIY