Failure to turn off greenhouse heater

I use HA and several Shelly devices to control the ventilation and heating in my greenhouse. Unfortunately I don’t have any alarms (yet), so I frequently check the status. I live in New England, USA, and now the sun goes down at 4:30 pm, plus it is cloudy, so I don’t get much solar gain. Last night I checked my GH on HA and the temp was 80F. I have a Sensor Push HT-1 that all of my automations use for the temp reference and a Shelly plus uni to switch the heating thermostat (24 VAC). The Sensor Push read 80F and the Shelly plus uni heater switch displayed ‘ON’. There are 2 automations for the heater, on and off. Somehow the ‘off’ automation was not executed. I turned the heater off through HA and it then worked properly through the night. Can anyone suggest why the off automation either didn’t get executed or failed? Is there logging that I can enable to help me track down this issue if it ever happens again? Are there improvements that I could make in the automations? It has been 100% reliable since I hooked it up about 2 months ago. Here are the automations.

alias: Heater On
description: Turn on the heater.
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.greenhouse_temp_humidity_temperature
    for:
      hours: 0
      minutes: 2
      seconds: 0
    below: 60
conditions: []
actions:
  - action: switch.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: switch.shellyplusuni_c4d8d54f408c_switch_0
mode: single

alias: Heater Off
description: Turn heater off.
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.greenhouse_temp_humidity_temperature
    above: 63
conditions: []
actions:
  - action: switch.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: switch.shellyplusuni_c4d8d54f408c_switch_0
mode: single

Can you provide traces of the off action?
Sharing a Debug Trace.

A trace of the failure isn’t available now. However, you did spur me to learn about traces so now I can debug future issues myself. I am not very knowledgeable about HA, still trying to learn. Thank you for the link to sharing traces! Just generating the json file for review is a huge help. Here are the contents of the json trace file. I have wondered how to access this debug level trace info. That gives all of the details about what was done. If I had gotten this after the failure it would have been really helpful!

{
  "trace": {
    "last_step": "action/0",
    "run_id": "ab67e9fc74378f732ec214c31830a0e0",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-11-11T15:19:17.434692+00:00",
      "finish": "2025-11-11T15:19:17.473530+00:00"
    },
    "domain": "automation",
    "item_id": "1757860655875",
    "trigger": "numeric state of sensor.greenhouse_temp_humidity_temperature",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2025-11-11T15:19:17.434767+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.heater_off",
              "state": "on",
              "attributes": {
                "id": "1757860655875",
                "last_triggered": "2025-11-11T14:36:19.115566+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Heater Off"
              },
              "last_changed": "2025-10-30T18:01:59.678235+00:00",
              "last_reported": "2025-11-11T14:36:19.138631+00:00",
              "last_updated": "2025-11-11T14:36:19.138631+00:00",
              "context": {
                "id": "01K9SNH7SBPK68P686XZ2RNRKC",
                "parent_id": "01K9SNH7SA9SCGA80QFVNH5BN8",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "numeric_state",
              "entity_id": "sensor.greenhouse_temp_humidity_temperature",
              "below": null,
              "above": 63,
              "from_state": {
                "entity_id": "sensor.greenhouse_temp_humidity_temperature",
                "state": "62.87",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°F",
                  "device_class": "temperature",
                  "friendly_name": "Greenhouse Temp/Humidity Temperature"
                },
                "last_changed": "2025-11-11T15:18:18.738873+00:00",
                "last_reported": "2025-11-11T15:18:18.738873+00:00",
                "last_updated": "2025-11-11T15:18:18.738873+00:00",
                "context": {
                  "id": "01K9SQY4BJP80RWY9DTP6A417Y",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.greenhouse_temp_humidity_temperature",
                "state": "63.39",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°F",
                  "device_class": "temperature",
                  "friendly_name": "Greenhouse Temp/Humidity Temperature"
                },
                "last_changed": "2025-11-11T15:19:17.433958+00:00",
                "last_reported": "2025-11-11T15:19:17.433958+00:00",
                "last_updated": "2025-11-11T15:19:17.433958+00:00",
                "context": {
                  "id": "01K9SQZXNSVTERPXGNQGKWYNFK",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": null,
              "description": "numeric state of sensor.greenhouse_temp_humidity_temperature"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-11-11T15:19:17.435127+00:00",
          "changed_variables": {
            "context": {
              "id": "01K9SQZXNTGD56YRSHB7BT4M64",
              "parent_id": "01K9SQZXNSVTERPXGNQGKWYNFK",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "switch",
              "service": "turn_off",
              "service_data": {},
              "target": {
                "entity_id": [
                  "switch.shellyplusuni_c4d8d54f408c_switch_0"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1757860655875",
      "alias": "Heater Off",
      "description": "Turn heater off.",
      "triggers": [
        {
          "trigger": "numeric_state",
          "entity_id": [
            "sensor.greenhouse_temp_humidity_temperature"
          ],
          "above": 63
        }
      ],
      "conditions": [],
      "actions": [
        {
          "action": "switch.turn_off",
          "metadata": {},
          "data": {},
          "target": {
            "entity_id": "switch.shellyplusuni_c4d8d54f408c_switch_0"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01K9SQZXNTGD56YRSHB7BT4M64",
      "parent_id": "01K9SQZXNSVTERPXGNQGKWYNFK",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Heater Off",
      "message": "triggered by numeric state of sensor.greenhouse_temp_humidity_temperature",
      "source": "numeric state of sensor.greenhouse_temp_humidity_temperature",
      "entity_id": "automation.heater_off",
      "context_id": "01K9SQZXNTGD56YRSHB7BT4M64",
      "domain": "automation",
      "when": 1762874357.434858
    },
    {
      "state": "off",
      "entity_id": "switch.shellyplusuni_c4d8d54f408c_switch_0",
      "when": 1762874357.4943488,
      "context_event_type": "automation_triggered",
      "context_domain": "automation",
      "context_name": "Heater Off",
      "context_message": "triggered by numeric state of sensor.greenhouse_temp_humidity_temperature",
      "context_source": "numeric state of sensor.greenhouse_temp_humidity_temperature",
      "context_entity_id": "automation.heater_off"
    }
  ]
}

I had another failure, but this time it failed to turn the heater on. Here is the trace. It seems like it tried to turn the heater on, but it didn’t switch on. Could it be a problem with the Shelly Uni? I have manually (through the HA web interface) switched the heater on. I have a 2 minute time delay in the automation to reduce ‘bouncing’ the heater. Since the turn-on temp is 60F and the turn-off temp is 63, that probably isn’t necessary. Would removing that help? The ‘turn-off’ automation that failed originally doesn’t have that.

{
  "trace": {
    "last_step": "action/0",
    "run_id": "a6e7dbfd6be932cbb37dc6b5bcb674c0",
    "state": "stopped",
    "script_execution": "finished",
    "timestamp": {
      "start": "2025-11-12T22:44:01.157588+00:00",
      "finish": "2025-11-12T22:44:01.158663+00:00"
    },
    "domain": "automation",
    "item_id": "1757860460821",
    "trigger": "numeric state of sensor.greenhouse_temp_humidity_temperature",
    "trace": {
      "trigger/0": [
        {
          "path": "trigger/0",
          "timestamp": "2025-11-12T22:44:01.157686+00:00",
          "changed_variables": {
            "this": {
              "entity_id": "automation.heater_on",
              "state": "on",
              "attributes": {
                "id": "1757860460821",
                "last_triggered": "2025-11-12T22:04:58.915340+00:00",
                "mode": "single",
                "current": 0,
                "friendly_name": "Heater On"
              },
              "last_changed": "2025-10-30T18:01:22.622194+00:00",
              "last_reported": "2025-11-12T22:04:58.968113+00:00",
              "last_updated": "2025-11-12T22:04:58.968113+00:00",
              "context": {
                "id": "01K9X1KFN3JYNDXNQVTNGV3B2W",
                "parent_id": "01K9X1FTF167T5CTWR9X6GHJR5",
                "user_id": null
              }
            },
            "trigger": {
              "id": "0",
              "idx": "0",
              "alias": null,
              "platform": "numeric_state",
              "entity_id": "sensor.greenhouse_temp_humidity_temperature",
              "below": 60,
              "above": null,
              "from_state": {
                "entity_id": "sensor.greenhouse_temp_humidity_temperature",
                "state": "60.01",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°F",
                  "device_class": "temperature",
                  "friendly_name": "Greenhouse Temp/Humidity Temperature"
                },
                "last_changed": "2025-11-12T22:40:58.561538+00:00",
                "last_reported": "2025-11-12T22:40:58.561538+00:00",
                "last_updated": "2025-11-12T22:40:58.561538+00:00",
                "context": {
                  "id": "01K9X3NCP1V5ZF0HSRMTJ7FN6P",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "to_state": {
                "entity_id": "sensor.greenhouse_temp_humidity_temperature",
                "state": "59.86",
                "attributes": {
                  "state_class": "measurement",
                  "unit_of_measurement": "°F",
                  "device_class": "temperature",
                  "friendly_name": "Greenhouse Temp/Humidity Temperature"
                },
                "last_changed": "2025-11-12T22:42:01.155743+00:00",
                "last_reported": "2025-11-12T22:42:01.155743+00:00",
                "last_updated": "2025-11-12T22:42:01.155743+00:00",
                "context": {
                  "id": "01K9X3Q9T3Y59PG1K2WEF0H0FH",
                  "parent_id": null,
                  "user_id": null
                }
              },
              "for": {
                "__type": "<class 'datetime.timedelta'>",
                "total_seconds": 120
              },
              "description": "numeric state of sensor.greenhouse_temp_humidity_temperature"
            }
          }
        }
      ],
      "action/0": [
        {
          "path": "action/0",
          "timestamp": "2025-11-12T22:44:01.158079+00:00",
          "changed_variables": {
            "context": {
              "id": "01K9X3TZ05NZ19R2YZ1ZJR9B3R",
              "parent_id": "01K9X3Q9T3Y59PG1K2WEF0H0FH",
              "user_id": null
            }
          },
          "result": {
            "params": {
              "domain": "switch",
              "service": "turn_on",
              "service_data": {},
              "target": {
                "entity_id": [
                  "switch.shellyplusuni_c4d8d54f408c_switch_0"
                ]
              }
            },
            "running_script": false
          }
        }
      ]
    },
    "config": {
      "id": "1757860460821",
      "alias": "Heater On",
      "description": "Turn on the heater.",
      "triggers": [
        {
          "trigger": "numeric_state",
          "entity_id": [
            "sensor.greenhouse_temp_humidity_temperature"
          ],
          "for": {
            "hours": 0,
            "minutes": 2,
            "seconds": 0
          },
          "below": 60
        }
      ],
      "conditions": [],
      "actions": [
        {
          "action": "switch.turn_on",
          "metadata": {},
          "data": {},
          "target": {
            "entity_id": "switch.shellyplusuni_c4d8d54f408c_switch_0"
          }
        }
      ],
      "mode": "single"
    },
    "blueprint_inputs": null,
    "context": {
      "id": "01K9X3TZ05NZ19R2YZ1ZJR9B3R",
      "parent_id": "01K9X3Q9T3Y59PG1K2WEF0H0FH",
      "user_id": null
    }
  },
  "logbookEntries": [
    {
      "name": "Heater On",
      "message": "triggered by numeric state of sensor.greenhouse_temp_humidity_temperature",
      "source": "numeric state of sensor.greenhouse_temp_humidity_temperature",
      "entity_id": "automation.heater_on",
      "context_id": "01K9X3TZ05NZ19R2YZ1ZJR9B3R",
      "domain": "automation",
      "when": 1762987441.1577861
    }
  ]
}

I looked through the trace and don’t see anything that suggests a failure. So I got a trace of the previous ‘heater-off’ action. The time-stamp on the previous ‘heater-off’ is later than the time-stamp on this ‘heater-on’. That suggests to me that the ‘heater-on’ automation was not activated when the temp sensor entity updated below the turn-on temp. Is there a way to trace sensor updates? I did enable ‘Debug logging’ on the Sensor Push sensor. Here is the beginning of the previous (I think) heater-off trace.
{
“trace”: {
“last_step”: “action/0”,
“run_id”: “0ed57f4ac7e690c5af5a6c75529cbc4e”,
“state”: “stopped”,
“script_execution”: “finished”,
“timestamp”: {
“start”: “2025-11-12T22:15:02.692617+00:00”,
“finish”: “2025-11-12T22:15:02.717004+00:00”
},

Another observation. I looked in the logviewer and the Shellyplusuni (and all of the entities) became unavailable. I also see a large gap in the Shellyplusuni uptime plot that might correspond with the temp update that should have triggered the heater to turn on. It seems to me (not knowing much about HA and Shelly) that if the device is not available when an automation runs, the automation can’t accomplish what it is intended to accomplish. That could explain both of these failures. So my next question (which I doubt anyone here can answer) is why is the Shellyplusuni having availability issues??? I have observed that over the summer.

Oh boy, things are getting bad. Now, neither temp sensor has updated for 15 minutes (they should update every 30-90 seconds) and the Shellyplusuni heater switch won’t turn on. So I power cycled the RPi-5 and maybe things are working again. Both temp sensors seem to be updating but the Shellyplusuni ds18b20 history plot shows gaps that roughly correspond to the device unavailable periods.

After power cycling my RPi with HA, everything was stable. I thought that maybe the Shelly Plus Uni was becomming unavailable because my connection from the 5VDC power supply wasn’t secure. However, I checked that today and it does seem secure. Furthermore, the Uni became unavailable while I had the electrical box open and I did see that the Uni reported that it was connected to my network, the red LED was lit, even though HA reported it as unavailable. It does have a static IP and my router isn’t reporting any problems with the device.

What does ‘unavailable’ mean from HA?

This is exactly how it works. You can add complexity to try and address these situations, but then it gets… complicated. :slight_smile:

This scenario is exactly why I don’t do any critical automations in HA, but rather on the device (ESPHome typically) itself. Obviously not perfect, but it removes all of the variability of networks.

In general, it means it can’t communicate with the device.

@brooksben11 Thank you. Yes, several months ago I was told that HA only executes an automation once based on an update. And yes, I have given some thought to redundancy, but, as you said, it gets complicated…quickly. If the fans don’t turn on during the summer, the GH can reach 130F very quickly and cook everything. I have thought of using a ESP32 and a DS18B20 temperator sensor but have had difficulty finding an SSR with a 3.3 VDC trigger voltage that can switch 24VAC for my heater thermostat. However, the Shelly Plus Uni does exactly that.

I may have resolved the problem. Time will tell. The Shelly Plus Uni has a pathetic antenna and HA reports a bad RSSI. A few weeks ago I met a guy who designs antenna systems professionally. He suggested that I simply cut a small piece of metal and secure it ‘behind’ the antenna, to make it more uni rather than omni directional. I did that a short while ago and got a huge signal strength boost, about 10 dBm. Things look more stable now. We will see…

Hopefully your current fix lasts, but if you revisit the ESPHome approach, I used one of these in a coffee roaster I built a while back:

It’s not available currently, but it’s also nothing special, I’m sure there are tons of other brands/variations that are equivalent.

One option I’ve been considering for critical automations that might get missed, is to implement the “Retry” integration from HACS. That provides logic to retry an action. Yes, it would add a bit of complication (but still better than doing retry logic myself).

But of course, mitigating the root cause of missed actions (e.g. networking, like you’ve done) is always better. As well as the suggestion of local (non-network) controls such as ESPHome.

I have an improvement to my ‘fix’. I sent a picture of my hack to my friend. He suggested that I put a 1/2" (12.5 mm) piece of foam between the antenna and the metal. While adding the metal helps change the signal from omni to uni directional, it also effectively shorts the antenna by reducing the impedance. He showed a graph of impedance vs. wavelength. Max impedance is reached at about 30% wavelength. For 2.4 GHz Wifi, that 30% is about 1.5" (38 mm). However, there is still the wave shaping to consider. It is a compromise between the 2. I added some foam and improved the signal again. While it had been better than before AND the uptime graph didn’t show any ‘unavailable’ occurrences (over only a couple of days), it did bounce around and wasn’t as good as I hoped. Now that I have included the foam, the signal is again much better. I discovered a way in HA to download the data as a CSV and have included a few of the data points. The first few data points are before the foam, the -85 is probably when I actually was making the change, the rest are after. It is a nice improvement. I will make a standalone post of this to hopefully help others searching for Shelly uni signal issues.

|sensor.shellyplusuni_c4d8d54f408c_rssi|-73|2025-11-16T14:39:19.449Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-72|2025-11-16T14:42:19.452Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-73|2025-11-16T14:43:19.445Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-72|2025-11-16T14:44:19.441Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-73|2025-11-16T14:45:19.441Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-72|2025-11-16T14:47:19.445Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-73|2025-11-16T14:48:19.585Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-85|2025-11-16T14:49:36.744Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-71|2025-11-16T14:50:36.471Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-70|2025-11-16T14:51:36.458Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-69|2025-11-16T14:52:36.448Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-67|2025-11-16T14:53:36.445Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-66|2025-11-16T14:57:36.447Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-68|2025-11-16T15:00:36.464Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-65|2025-11-16T15:01:36.448Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-68|2025-11-16T15:02:36.447Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-66|2025-11-16T15:04:36.446Z|
|sensor.shellyplusuni_c4d8d54f408c_rssi|-65|2025-11-16T15:05:36.446Z|

1 Like