Configuring MQTT and first item

  • Platform information:
    • RaspberryPi 3+
    • OS: current stable Openhabian

I’ve just started and I’m trying to configure the following:
Sonoff Basic->Tasmota->MQTT->Mosquitto->OpenHabBinding 1.12.0->OpenHab->>Alexa

So basically to be able to switch a Sonoff Basic on and off from Alexa!

I have Sonoff Basic->Tasmota->MQTT->Mosquitto working. I can monitor and control the Sonoff via:
mosquitto_pub -t cmnd/ESP01/POWER -m 1
mosquitto_sub -t stat/ESP01/POWER -v

I also have the OpenHab->>Alexa bit working because I can control a Wemo device which has been configured and discovered (by Alexa).

I installed Mosquitto via the openhabian config tool and it’s on the same device as OpenHab.

I’ve only edited on line in MQTT.cfg:

# URL to the MQTT broker, e.g. tcp://localhost:1883 or ssl://localhost:8883

and my “item” file looks like this:

//Sonoff Basic / Sonoff S20 Smart Socket
Switch LivingRoom_Corner_Light "Indirect Corner Light" <light> (LR,gLight)
    { mqtt=">[mosquitto.url:cmnd/ESP01/power:command:*:default],
            <[mosquitto.url:stat/ESP01/POWER:state:default]" }
//... please visit wiki for more ..

I don’t see this item appearing anywhere in Openhab which I can monitor or interact with it except in “Configuration>items”

and there nothing configurable about it!

Actually I can see it in in the list of openHAB cloud exposable items:

But it cant be “discovered”.
I’m stumped

How can I tell if the Openhab<->mosquitto connection is working?

without .url

//Sonoff Basic / Sonoff S20 Smart Socket
Switch LivingRoom_Corner_Light "Indirect Corner Light" <light> (LR,gLight) { mqtt=">mosquitto:cmnd/ESP01/power:command:*:default], <[mosquitto:stat/ESP01/POWER:state:default]" }

Correct. You need to create a sitemap to be able to see (and control) this item.

Correct. Since you are using an .items file, you can’t modify it from PaperUI (only from the file itself)

Because of the (.url) typo. You should have some error logged in openhab.log… did you check it?

check logs (both openhab and mosquitto)

1 Like

Thanks Dim for the comprehensive response.
Progress made. I can now see the status of the MQTT device changing in the OpenHab event log.
However I seem to have broken the OpenHab->---->Alexa connection in the process :slight_smile:
More investigation needed on my part.

1 Like