Reverse status of binary sensor from Sonoff SV power2

Hi
I used to use the following yaml to reverse the status of power2 from a sonoff SV to indicate a gate being open or closed.

#binary_sensor:
#
#  #Front Gate Sensor
#  - platform: mqtt
#    name: Front Gate
#    state_topic: cmnd/front_gate/POWER2
#    payload_on: 'OFF'
#    payload_off: 'ON'
#    qos: 0

Note the payload_on:is off and off is on as the read switch I’ve set up on the gate is closed when the gate is closed causing POWER2 payload on when is should be off.

Now I’ve reconfigured Tasmota devices on the network to auto discover with setoption19 to 1 and have commented out this configuration. But now the system thinks the gate is closed when its open etc.

Whats the best way to revers the payload of power2 to indicate the correct status of my gate?

Thanks in advance
Rob

Sorry, bit confused. You have the reed switch connected to the SV but the binary_sensor topic is the command topic for the relay? Could you explain a little further? You could use a value_template to reverse or even a rule in Tasmota to publish to a topic of your choosing when reed sensor changes state.

Thanks for prompt reply. Sorry for confusion.
GPIO14 is used to detect state of read switch separately from relay.
When the gate is closed the GPIO14 “dry” circuit is closed and when open the circuit is open.
This reports “on” (or “open” for a device class of opening) when the gate is closed and visa versa. This was previously handled by this:

    payload_on: 'OFF'
    payload_off: 'ON'

Which is no longer being used with SetOption19 set to 1.

The way I’ve set it up is explained on this page.
https://www.hagensieker.com/wordpress/2019/02/18/sonoff-sv-for-garage-door-opener/

Do you have a value_template or Tasmota rule example to correct this?

Thanks
Rob

Understand now. Can you therefore just use either switchmode2 1 (to invert your current programming) or invert the switch in the module config from Switch2 to Switch2n?

image

xbmcnut
Brilliant, thanks for that. SwitchMode2 1 does the trick.

Setting GPIO14 to Switch2n (83) caused the Sonoff SV to report that the reed switch circuit was opening and closing rapidly while the gate was opening or closing and then settle in a state of open irrespective of reed switch state?

Thanks again
Rob