Making a mechanical thermostat a bit less dumb

This is one of my first home assistant projects so I would appreciate feedback on it. I need to learn from my mistakes and can only do that if someone is willing to give me some tips. Thanks in advance

We already have “dumb” mechanical thermostats in each room. You turn a wheel to set the temperature you want the underfloor heating to maintain. Behind the thermostat in the living room I have installed a Shelly 1PM switch and wired the output from the thermostat to the input of the switch.

The aim of this automation is as follows.
If there is some one at home, then they should control the heating in the living room using the existing thermostat. If there is no one at home, then the Shelly Switch takes over the control keeping the room above 14°C If the Home Assistant decides to stop working, the thermostat should still work.

This is the flow diagram I developed while thinking about this.

I have a helper that is set “on” when someone is home but “off” when no one is there. That is what decides who does the controlling. If it is “on”, then the automation doesn’t need to do anything as the Shelly deals with things. If it is “off” then the Home Automation needs to keep the temperature at about 14.5°C.

Here is my code:

alias: Wohnzimmer Heizung
description: >-
  Wenn jemand zu Hause ist, sollte er die Heizung im Wohnzimmer mit dem
  vorhandenen Thermostat regeln. Wenn niemand zu Hause ist, übernimmt der Shelly
  Switch die Steuerung und hält die Raumtemperatur über 14 °C.
triggers:
  - trigger: state
    entity_id:
      - switch.thermostat
    from: null
    to: null
  - trigger: numeric_state
    entity_id:
      - sensor.wetter_wohnzimmer_temperatur
    above: 15
  - trigger: numeric_state
    entity_id:
      - sensor.wetter_wohnzimmer_temperatur
    below: 14
conditions:
  - condition: state
    entity_id: input_boolean.someoneathome
    state:
      - "off"
actions:
  - choose:
      - conditions:
          - condition: numeric_state
            entity_id: sensor.wetter_schlafzimmer_temperatur
            above: 14.5
        sequence:
          - action: switch.turn_off
            metadata: {}
            data: {}
            target:
              entity_id: switch.thermostat
      - conditions:
          - condition: numeric_state
            entity_id: sensor.wetter_wohnzimmer_temperatur
            below: 14.5
        sequence:
          - action: switch.turn_on
            metadata: {}
            data: {}
            target:
              entity_id: switch.thermostat
mode: single

The automation appears to work as expected but I am very interested to hear what I have forgotten / done wrong.

Thanks - and greetings from the frozen Alps

Hi Neill, I am interested to read about your project. I have been thinking of doing something related and delayed for 2 years now. Let me explain, and I have one suggestion. I have an UFH system in the UK, and it works fine except in very cold weather, when from a lower ‘during the day’ set point, the system never gets to temperature in the evening - see image with internal temperature - I want the system to be stable at around 20C between 18:00 and 22:00 at least. The house I live in also has an older radiator system, with high water flow temperature and smaller radiators - we don’t use it. I wanted to put the Shelly 1 on this thermostat line to be a ‘booster’ on cold days that the system can’t cope with. I realised this would mean setting the ‘booster’ thermostat to something like 21C and feared if HA crashed or something, that the heating would be permanently on. I used Gemini to find a solution to this. I run my automations in Node Red through the add-on, you might not know it, but I think you will be able to follow the logic. Below is the output from Gemini explaining how to create a firmware (Shelly) kill switch.

1. The Hardware Safety (You already have this)

As you noted, wiring the Shelly in series with the existing mechanical thermostat is your last line of defense.

  • Set Mechanical Thermostat to ~21°C.
  • Benefit: Even if the Shelly jams ON and the internet explodes, the room will never physically exceed 21°C. It prevents a sauna, but it doesn’t prevent waste.

2. The Firmware Safety (The “Dead Man’s Switch”)

This is the magic bullet. You can configure the Shelly device internally to never stay on for more than a set time.

  1. Log into the Shelly’s web interface (by typing its IP address into a browser).
  2. Go to Timer settings.
  3. Enable “Auto Off” and set it to 1800 seconds (30 minutes).

What this changes: Now, the Shelly is incapable of staying ON for more than 30 minutes at a time. It requires a fresh command from Home Assistant to stay active.

3. The New Node-RED Logic: “The Heartbeat”

Because the Shelly now turns itself off automatically, your Node-RED logic changes slightly. You don’t just send “ON” once; you send a “Keep-Alive” pulse.

  • Old Logic: “It’s cold → Send ON.”
  • New Logic: “It’s cold → Send ON. Wait 20 minutes. Is it still cold? Send ON again.”

The Failure Scenario:

  1. 18:00: Room is cold. Node-RED sends ON.
  2. 18:01: Shelly turns ON (starts internal 30-min countdown).
  3. 18:15: CRASH! Home Assistant dies completely.
  4. 18:20: Node-RED should have sent the “Keep-Alive” pulse, but it’s dead.
  5. 18:30: The Shelly’s internal timer hits zero. It cuts the power.

Result: The worst-case scenario is that your radiators run for 30 minutes and then stop. The system defaults to “Safe & Off” rather than “Stuck & On.”


I have not done this yet, but I am confident it will work. I can post details of the logic for the control loop if you’re interested