UI does not update when topic is sent to HA over mqtt

New to HA.

Trying to figure out why state in HA does not update.

Sending this from VS Code

# ## Switch test
topic: homeassistant/switch/poe/test/config

{
    "name": "test",
    "unique_id": "test",
    "state_topic": "poe/test/state",
    "command_topic": "poe/test/set",
    "optimistic" : true,
    "device": {
    "identifiers": [
      "poe001"
    ]
    }
}

A switch will show up in HA, all good. When I switch it, the state will be published.

Now I want to publish from VS Code and expect it to update in HA, but it does not.

Publishing:

topic: poe/test/set

OFF

How do I get the state in HA to reflect the published state?

Hi, the same problem with light brightness status which does not update when esp publishes new status.