MQTT ESP Easy rules


I have a Sonoff relay, and i have installed ESP easy on it,
I can control the relay in OH, but I would like to use the button on the relay as a switch for the relay,

I have made a rule in the ESP Easy rules, to control the relay. it workes, but it looks like it does not send the status change to MQTT server then the button is pressed.

on LightSwitch#Switch do
if [lightState#Switch]=0
Switch sonoffrelay "sonoff Relæ [%s]" (Vejrst) {mqtt=">[<broker>:/sonoff/gpio/12:command:ON:1],>[<broker>:/sonoff/gpio/12:command:OFF:0],<[<broker>:/sonoff/gpio/12:state:ON:1],<[<broker>:/sonoff/gpio/12:state:OFF:0]"}

I have try’d to see the data by subscribe to /sonoff/gpio/12 but no data is sent then pressing the button on the sonoff device

I have found a solution, I added
This to the code:
Publish /sonoff/lightState OFF
Publish /sonoff/lightState ON

that did the job

1 Like