HA States icons not changing for mosquitto terminal command

I am trying to get Home Assistant to recognize a change in state (change the icon in the HA States window) performed by the following mosquitto terminal command
mosquitto_pub -h 192.168.1.123 -t cmnd/sonoff2/power -m "on"

the light comes on, however, the icons in the HA States window still show the light as off

my configuration.yaml entry

  broker: 192.168.1.123 

light: 
  - platform: mqtt 
    command_topic: "cmnd/sonoff2/power" 
    name: "Desk Light"

thank you for your assistance

I would think you need to set optimistic to yes in config or add a state topic to config - which will tell HASS how to know the state of the switch.

phileep…
it was the state topic I needed, and also payloads
now it works wonderful!

    state topic: "cmnd/sonoff2/power"
    payload on: "on"
    payload off: "off"

Thank you for your assistance!