I have one particular z-wave Leviton switch where the state of the switch sometimes gets out of sync with what Home Assistant thinks the state is. As a consequence when my pyscript automation decides to turn off the switch (which controls a fan), HA seems to think the switch is already off, so no command gets to the switch and it just stays running forever. Or when my script asks HA what the state is, it gets a wrong answer and then makes wrong decisions. End, result, the fan runs forever until a human notices it.
Apparently the state got out of sync when some z-wave command failed to get delivered and sure enough I can see a couple failed transmissions.
I don’t know much about z-wave, but is there any way in the z-wave sub-system to require delivery confirmation of commands sent before HA updates its internal state? Or how else do I prevent this situation where HA’s cached state is out of sync with the actual switch state?