Control circuit for feedback for sonoff

Hello
I would like to create a circuit that lets me know the actual state of the light if it is on or off. I would like to use the gpio available on the sonoff detecting the actual output voltage of my sonoff. the sonoff is currently set up as a pusher, so when I press it if I’m not at home I can not know the actual state of my light. how can I do? how should I set the gpio? and above all how should I declare it in configuratio.yaml? I would obviously like to use mqtt, but I’m not sure how to set. At the hardware level I can use a 220v bulb and a photoresistor that detects the light on at the output of the sonoff (or rather at the input of the lamp I want to turn on).

what firmware are you running on the sonoff?

Tasmota firmware

I don’t use that but there should be a state feedback topic configured in the firmware.

you will need to add a “state_topic:” line to your config. Here is mine as an example:

- platform: mqtt
    name: "Basement Workshop Lights"
    state_topic: "home/sonoff/basement/ws/stat"
    command_topic: "home/sonoff/basement/ws"
    qos: 0
    payload_on: "on"
    payload_off: "off"
    retain: true