MQTT entity not appearing when state_topic is included

Hi,

I’m relatively new to home assistant. I have done a recent install and am currently on the latest version. I was starting to get my head around the process of adding a new MQTT entity. I was having a bunch of trouble, however I managed to make it work with the following code.

light:
  - platform: mqtt
    name: "TEST LED RGB CONTROL"
    command_topic: "matt/test/led"
    payload_on: "ON"
    payload_off: "OFF"`

SO,

It worked, which was great. I then added the follow state_topic

light:
  - platform: mqtt
    name: "TEST LED RGB CONTROL"
    state_topic: "matt/test/set"
    command_topic: "matt/test/led"
    payload_on: "ON"
    payload_off: "OFF"

And suddenly the previous entity cannot be found. The same situation happened if I try to add LED controls.
I also tried it with optimistic: false (I don’t know what it does, the documentation seemed like it was a good idea)

Any help is appreciated!

Please post the configuration for the other light(s) as well.

Both configurations are in the original post.

The first configuration allows me to see the light, the second is the change I made and it disappeared.

If it “disappeared” that means Home Assistant detected a syntax error and refused to load it.

Did you check the system log for errors?
Did you run a Config Check?