Good, that helps to confirm its operation. Let’s forget everything that’s been attempted so far and return to the basics with a simple MQTT Switch (not an MQTT Light).
It should work perfectly because it is simplicity itself: 0=off and 99=on. By default, MQTT Switch assumes the reported states are equivalent to payload_on and payload_off so there’s no need to specify state_on and state_off.
If it fails to work (you may try ‘99’ and ‘0’ … but you said both string and integer work), then I suspect there are deeper problems in your system.
What happens if you turn off the zwave dimmer and then turn it on but only to 50 percent? Theoretically, the MQTT Switch should fail to indicate the light is on because it will receive 50 instead of 99.
If the MQTT Switch receives a value greater than 0 the template will covert it to 99. This permits the MQTT Switch to report its status as on for any value > 0.
I’m very interested to learn if this template works like I just explained or will cause the switch to indicate on by default.
Its back to previous behavior of defaulting to on, switching back to on after trying to the mqtt switch off. If I switch the mqtt switch to off and back on quickly, only then does the light turn on.
It’s exactly the same as what I proposed earlier but with one very important correction to the template. The previous version’s template was incorrect because it compared a string to an integer.
Now I would appreciate it if you could mark my post as ‘Solution’ to make it easier for other users to find it (this thread has grown to over 32 posts in length). Only you, the author, can mark a post as ‘Solution’. It will automatically place a link to the Solution under your first post in this thread.
Great post! I had exactly the same issue and was able to identify where I was going wrong.
What in the end was wrong in my configuration file is that I had the string values that were send for the state changes wrong. I used ‘0’ and ’ 100’, while I should have used ’ 0.00’ and ‘100.00’.
I have been looking for a few weeks to find a good step-by-step guide on how to identify errors. This post helped me a great deal understanding how mqtt/home assistant works…
Thanks a lot!