Pulse switch - check status before send command

It’s possible to check the status of the switch before sending command?
I’ve a Pulse switch configured as follow:

Switch Sala_Luce "Luce sala [%s]" ["Lighting"] {mqtt=">[mosquitto:/ESP_CORE/cmd:command:ON:MCPPULSE,5,0,50], >[mosquitto:/ESP_CORE/cmd:command:OFF:MCPPULSE,5,0,50], <[mosquitto:/ESP_CORE/stato_luce_sala/Switch:state:ON:1], <[mosquitto:/ESP_CORE/stato_luce_sala/Switch:state:OFF:0"}

Basically I’ve a Double phase Step Relay (Finder 260280240000)which it’s driven by a Optocoupler Relay that send a 50ms pulse to make the Step Relay change it’s position.
I use the second Phase of the Step Relay to get back the status in OH because I use also wall mounted button to toggle the Step Ralay.

The side effect of this configuration it’s that if i send “OFF” command to the Switch while it’s alredy in OFF state, the command it’s sent and the Optocoupler Relay pulse so the Step Relay change position and the status of the switch turn ON.

I hope I explained myself…
Any workaround?

Thank you in advance!

You could use a proxy item and a rule that checks the status of the switch, if the if is true, the rule runs.

rule "Turn light on off"
    Item Proxy_Switch changed to OFF
    if(ESP_CORE.state == OFF)return; // do nothing if off

1 Like

Thank you, it work like a charm!