MQTT EspEasy 2 way communication?

  • Platform information:
    • Hardware: Pi4
    • OS: latest stable OH3 openhabian

Hello all,
I’m running an esp8266 on EspEasy. I have been successfully running this for approx 2yrs now. I use the ESP to control an 8 port relay board, which controls sprinkler valve (porch auto watering plants), hall way lights, etc) that are on timers within openhab. This entire system, openhabian, 24vac, relay board, esp8266 are all on backup power but only last about 1 day. During winter after I had drained the system and an extended power outtage I noticed during reboot, that some of the relays come on after boot but dont communicate with openhab their status. Is there a way to make this happen? I’ve tried checking the box in espeasy to commicate status box to controller and set to 60 seconds. I see it in the logs of espeasy, but dont see any updates within openhab 3.

What am I missing here, or is this something thats not able to be done?

So you see it at your MQTT broker?

Yes, im able to control it with no issues. However openhab has no confirmation what the status of the esp8266 is. Example if openhab believes the switch is off, power goes out and back on. The esp8266 boots with a relay powered on, openhab had no clue the device is on and they will not align until the scheduled rule runs again. In my scenario this is rather bad because its a watering system :laughing:

From where? openHAB?

And you have confirmed that your MQTT Broker (mosquitto?) has received the message from your esp8266 which says that the relay is ON?

Don’t forget that messages will flow:

esp8266 <-> MQTT Broker <-> openHAB

Irrespective of control method, you should fix this locally. Not sure of the options with espEasy, but Tasmota has the pulsetime setting which will automatically switch OFF a relay/switch/light/whatever after a configurable amount of time after it was switched ON.

I guess that you are using a IO expansion board like PCF8574 since if you are using a ESP8266 GPIO you don’t have this behavior. If so, you could create a rule on ESP8266 that sends a command to PCF to turn any GPIO to on or off on every startup. PCF will send all GPIO states to ESPEasy and it will sends any state change by MQTT if correctly configured.

on System#Boot do
 pcfgpio,17,1
 pcfgpio,25,1
 pcfgpio,33,1
endon 

In the above example, there are 3 PCF boards. Once they receive the command, ESPEasy pin state buffer is updated.
Hope that this will help you…