Troubleshooting MQTT? MQTT-Explorer can help you be successful!
If you have Add-ons available, try adding this Add-on repository to your Add-on list. GitHub - GollumDom/addon-repository.
With this you can see that the broker sees and likely find the bug.
HINT: I have found using this, if you look at the JSON string and it is in color, the JSON is valid. If it is monochrome, the JSON is invalid and it will not work.
The thing is, these switches are not discoverable, I can only add them through YAML. However, when I do that, the entity ID doesn’t show up after restarting Home Assistant. I’ve tried using MQTT Explorer, but that didn’t help either.
So… wait, wait, wait… All this time I thought that retain is the option to keep the state known, after restarting… It is not this? If I add retain, it will trigger a command after restart, putting the switch in the same state as before restarting? I am trying to understand it 100%
This. Might or might not be wanted. To retain the state, the device needs to set the retain flag.
As long as the state is only ever set from HA, it makes no difference. But if you can set the state on the device/other means, it does. E;g.hardwired relays running Tasmota that have a switch or button to toggle/switch on/off the relay. If the last command send with retain flag was to switch the relay off, but the physical switch turned the relay on afterwards, the state is off, but on a HA restart HA will send the last command (because retained) which may or may not be desired.
I don’t know how you configured your includes, but if your first 2 switches work the 2 spaces won’t be the problem.
Are you sure the 3rd switch can’t be found ?
I have deleted the old entity, and the new one does not appear…
I will do a test now, writing directly to configuration.yaml…
Guess, what? directly to configuration.yaml, works
My question now is:
how can I add all the switches into one file and all the sensors to another files, what I need to use for include, to include all the yaml files of mqtt, from one single folder? No matter if is switch of sensor, having them in separate files
I don’t understand how is the split configuration for mqtt…
Ok, I did it, finally. It was because of the split configuration, of course…