Magnetic sensor in Tasmota - integrate into Home Assistant - HELP

Hello, I have a NodeMCU with Tasmota firmware.

It has two sensors connected to these doors and windows (wired, not RF).

when opening and closing the sensors (switch2 and switch3) it returns the following:

13:32:05 MQT: cmnd/sensor/POWER = OFF (retained)
13:32:05 MQT: stat/nodeMCU1/SWITCH2 = {"STATE":"OFF"}
13:32:08 MQT: cmnd/sensor/POWER = ON (retained)
13:32:08 MQT: stat/nodeMCU1/SWITCH2 = {"STATE":"ON"}
13:32:11 MQT: cmnd/sensor/POWER = OFF (retained)
13:32:11 MQT: stat/nodeMCU1/SWITCH3 = {"STATE":"OFF"}
13:32:13 MQT: cmnd/sensor/POWER = ON (retained)
13:32:13 MQT: stat/nodeMCU1/SWITCH3 = {"STATE":"ON"}

As I do to monitor the Status of these sensors in the Home Assistant, I made the following configuration in “configuration.yaml” but I have no feedback:

#DOOR SENSOR
binary_sensor:
  - platform: mqtt
    name: "Sensor Porta"
    state_topic: "stat/nodeMCU1/SWITCH2"
    payload_on: "{STATE:ON}"
    payload_off: "{STATE:OFF}"
    device_class: door
  - platform: mqtt    
    name: "Sensor Janela"
    state_topic: "stat/nodeMCU1/SWITCH3"
    payload_on: "ON"
    payload_off: "OFF"
    device_class: door
1 Like