Lights integrated via Tasmota on a Shelly 2 constantly unavailable

Hi,

I have just repurposed a couple of Shelly 2’s. One is a Shelly Plus 2PM and the other an older Shelly 2.5. Both are running Tasmota 14.4.1, and both have previously been used elsewhere in the house with different names.

They work fine with the Tasmota web UI on the devices themselves. I’ve configured them to use my MQTT server, set SetOption30 1 so they register as lights, and set friendly names.

They turn up in HASS via the Tasmota integraton. If I delete them and then restart the devices, they re-appear, with all the correct entities. If I trigger the switches via the Tasmota web UI, these actions appear in “real time” in the Logbook in HASS.

But quite often, the devices appear “unavailable” in the HASS UI. There’s no obvious reason why. Restart them, or restarting the Tasmota integration, or restarting HASS do not make them re-appear. But sometimes they return.

I’m going slightly mad trying to debug this. Any ideas what might be going on?

I don’t think it’s a wifi issue, since I can access them via their web UI without problem. It’s as if there is a race condition or resource contention of some sort where sometimes the device correctly connects and sometimes it just fails.

Could it be related to the fact that the devices were previously configured (on the network and in HASS) with different names (hostname, MQTT name, friendly name)?