Help with mqtt for newbee

I have a nodemcu sketch that publishes messages when a switch is triggered ,
i can see this messages on mqtt when i listen for the message

Message 5 received on device/alarm/sensor/kidsroom at 12:29 PM:

so far so good I think, so i added the yamel config

  - platform: mqtt
    name: "kidsroom"
    state_topic: "device/alarm/sensor/kidsroom"
    command_topic: "device/alarm/sensor/kidsroom"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"

I was expecting the switch to toggle depending on the status, but its not happening . I don’t know if I missed any steps
can some one advice , I did try with taking command_topic off

Your payload appears to be “1” and I assume “0”. So change your config payloads to that.

    payload_on: "1"
    payload_off: "0"

That did the trick , it works , it kind of make sense now
been a great help cheers