Battery-operated Sensor Unavailable due to WiFi Sleep, wreaks havoc on Generic Thermostat on HASS restart

Hi, everyone

I have a Shelly H&T WiFi sensor in my setup that I want to use as the Temperature sensor for a Generic Thermostat configuration.

I’ve set everything up correctly, but have come across one issue: because the sensor is battery-operated and in sleep mode most of the time (only waking up when the measurement delta is relevant), when I restart HASS usually the entity comes up as “unavailable”. It comes back after a while (because it will start connecting to the network to update values), so the sensor itself is working correctly.

The issue apparently comes from the Generic Thermostat trying to access an unavailable sensor: not only won’t it work while the sensor doesn’t come back “online”, but it even locks up the “heater” switch that is part of the same setup.

I’ve asked the Shelly integration author to look into this, but is there any way I can work around the problem?

I’m thinking if setting up a Template Sensor that somehow gets its value from the H&T’s last available Temp value - and using that Template Sensor as the Generic Thermostat input - wouldn’t work…?

'Appreciate your input.

Cheers

Are you using the Shelly cloud?

You could try using mqtt but to prevent the same thing happening you would have to disable LWT messages (blank Will topic, blank Will message). It’s under internet and security settings / advanced developer settings in the web interface.

The other advantage of using mqtt over the cloud connection is that it still works when your internet connection is down.

I’d like to stay with my current integration (using CoAP and REST, not the Shelly cloud). MQTT is something I can’t put the time in to learn right now, and I like the cloud history Shelly provides.

Isn’t there any other way to overcome this issue?