ESPEasy MQTT Sonoff with OH3

Hi all,

I just got a few Sonoff Mini and I have flashed them with ESPEasy (ESP_Easy_mega_20210114_normal_ESP8285_1M)

I have a single relay, sitting on gpio 12 and following the ESPEasy manual I’m addressing it on the topic sonoffmini/cmd gpio,12,X where x is [0,1]
I have created a thing and the item, and everything is awesome but I cant make the status work.
The status topic is sonoffmini/relay/relay and the payload is [0,1]

So…I can switch the relay, it works just fine, but when I push the button OH3 can see the change

Id appreciate every little help

Cheers

Hi jtamasi
Welcome to the OpenHAB community !!!
I’ve never tried ESPEasy (yet) but like goofing around with my ESPs and use MQTT to communicate with OpenHAB. Are you using some MQTT client (such as MQTTfx) to watch what the relay is sending? Watch your OpenHAB logs as well to provide clues. I’m sure someone with more experience will be along shortly to help you

Can we see your configuration? If it’s UI based, can you show us what’s in the Code tab of your Thing?

1 Like

Thank you all for the quick response.

Here is the YAML from the UI

UID: mqtt:topic:3f1fd85325:700506d075
label: sonoffmini
thingTypeUID: mqtt:topic
configuration:
payloadNotAvailable: Connection Lost
availabilityTopic: sonoffmini/status/LWT
payloadAvailable: Connected
bridgeUID: mqtt:broker:3f1fd85325
channels:

  • id: relay
    channelTypeUID: mqtt:switch
    label: relay
    description: “”
    configuration:
    commandTopic: sonoffmini/cmd
    stateTopic: sonoffmini/relay/relay
    off: gpio,12,0
    on: gpio,12,1

I think the problem is that OH3 expecting “gpio,12,0” or “gpio,12,1” on the state topic but there it gets only 1 or 0

Typing from my phone so cannot verify, but please check on off and formatBeforePublish options, something as below

configuration:
      commandTopic: sonoffmini/cmd
      formatBeforePublish: gpio,12,%s
      stateTopic: sonoffmini/relay/relay
      on: 1
      off: 0
1 Like

Thank you @crnjan … that’s it! :slight_smile:

1 Like

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.