Get feedback from RF 433MHz switch from sonoff basic

Please help with ideas to newbie in HA.

I’m trying to introduce feedback/state control to RF433MHz/IR based switches that doesn’t have state control.
The solution is on picture.

Switch powers on some load (light bulb for example). It can be pressed manually or controlled externally, but can’t send any state/notification. I install sonoff basic in parallel with the load, i.e. when load is powered on- sonoff is powered as well.
This sonoff basic (with custom firmware) sends message to MQTT stat topic on start and continues sending these messages with some interval to handle cases when switch is pressed manually. Sonoff is not used as switch - only as a WiFi MQTT sender.

I’m trying to configure HA - add mqtt switch:

switch:
    - platform: mqtt
      name: "Light switch"
      command_topic: "cmnd/switch/power"
      state_topic: "stat/switch/power"
      qos: 1
      payload_on: "ON"
      payload_off: "OFF"
      retain: true

but I’ve faced some problems:

  1. sonoff basic takes ~10 seconds to send first message after power- on. HA expects that message in state_topic is received within ~2 seconds after sending a command, message doesn’t arrive and switch returns to OFF state. Is it possible to extend this interval (clone some python source - switch component)?

  2. I can’t send OFF state because sonoff is posered off (I’ve made some attempts with ESP.getVcc, extended capacitor in circuit etc- result is unstable). So the only solution I see is to somehow check that after power off is pressed - ping sonoff (or send MQTT message and wait 1 seconв for response) and if it is not available - threat switch as turned off.

  3. I’d like to do an “error handling” - if command haven’t been executed (433RF/IR signal wasn’t read by switch) - it should be re-executed.

Is it possible to configure such behavior using existing Homeassistant functions?

Seems like the simple solution colud be in combination of switch and binary sensor. Switch will send commands, binary sensor will display current status, but how to force them to work together , i.e. switch should send ON commanв only if sensor shows that current state is OFF.

Since you are tinkering…

I think the easiest way to do what you want would be to make the output of the livolo switch also turn on a 120v (or 240v depending on your country) relay.

You can set up the Sonoff Basic to turn on/off controlled by the exposed GPIO pins. Which pin you use depends on if the Basic is the older style (GPIO14) or newer style (GPIO3).

Then have the relay contacts close the circuit to the Sonoff basic GPIO pin to turn on/off the Sonoff to match the state of the light.