What you propose is quite cool, @petro !
I will admit, it will take me a bit to understand the latter post, but I get the gist of it. Yes, this will simplify the automation, but it does complicate the mqtt.yaml.
The one thing left out is that my controller expects a value for the zone and then then, two seconds later, the switch is toggled.
Two seconds because HA sends the data to the MQTT broker; the MQTT broker sends to the MySensors gateway, which is also the destination MySensors node, Then the node acknowledges by sending do the value to the gateway, which sends it to the MQTT broker which sends it to HA. (each step has protocol handshaking). The communication is usually much faster than 2 seconds; the operative word is usually.
It is desirable to keep the dependence of code specifics to a minimum. I could write my controller code to operate independent of HA, but then I’m locked into SIP. The way it is is a bit clunky, but it’s made of building blocks that requires only small bit of file-to-fit
Thanks for you help!