Mqtt monitoring / syncing states, need bit of help

all my switches are retaining their states, so it should.
will report back when in production :wink:

edit: it works indeed, let's see if there will be some weird rapid switching after some time of using this