[SOLVED] MQTT and http binding combined rule hangs when http down

I have the following rule defined which runs an mqtt command and http binding command,

Switch sw_Pump "Water Pump On/Off" <poweroutlet_us> (gTank) {mqtt=">[mosquitto:cmnd/sonoff-123/POWER:command:*:default], <[mosquitto:stat/sonoff-123/POWER:state:default]", http=">[ON:POST:http://192.168.1.2/control?cmd=oledcmd,on] >[OFF:POST:http://192.168.1.2/control?cmd=oledcmd,off]" }

When the remote http ESP Easy sensor (192.168.1.2) is down the above command simply hangs, so even the mqtt is not triggered. Is there a way to trigger the mqtt irrespective whether the http device is up or down?

I believe that ESPeasy is also controlable by MQTT, is it not?

To elaborate on Vincent’s question, why are you using both MQTT and HTTP? ESP Easy supports MQTT so just use MQTT.

There is no way to trigger just the MQTT whether or not the HTTP device is up or down. I suppose you could write a Rule to do something like that with Timers and such, but ultimately it would far less work to use MQTT with the ESP Easy.

I was able to set a rule in ESPEasy to turn the OLED ON and OFF based on MQTT.

Would you share your rule, please for the other users.
Thanks

I used the following code in an ESP Easy rule,

on motor#OLEDSTATE do
  if [motor#OLEDSTATE]>0
     OLEDCMD,on
  else
     OLEDCMD,off
  endif
endon

This rule was used with a device of type ‘Generic - MQTT Import’, with the device named ‘motor’ and a variable called OLEDSTATE.

1 Like