Page 1 of 1

EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 08:37
by kevin9r
Hello,
i try to connect my espeasy devices with openhab. The openhab is on a rpi.
I have install mosquitto and configured it already. I have set the configuration in the espeasy device. I can connect to the mqtt broker and i see the devices there if i make a subscribe over mqttfx.
Now i try to change a pin state first over mqttfx. I make a publish with this command:
/Strassenlicht/GPIO/13:command:ON:1

but it isn't working. On the Esp is the newest espeasy system installed. Over http i can change the gpio pin states. I think my mqtt command is wrong but i couldn't find other commands.

Thanks for your help!

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 10:20
by grovkillen
Have you looked into the wiki section regarding commands?

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 13:24
by kevin9r
Hello,
thanks for your reply! Yes, the http command works fine. I had tried more mqtt commands. From the wiki i think correct is this:
/Strassenlicht/control?cmd=GPIO,13,1

But it doesn't work... Had tried this in mqttfx and this as a openhanded item:
Switch switch1 "Strassenlicht" { mqtt=">[jedyn:Strassenlicht/control?cmd=GPIO,12,1],
<[jedyn:Strassenlicht/control?cmd=GPIO,12,1]" }

nothing works... only http

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 13:39
by grovkillen
I don't know what you're exact topics are that your controller settings is using but this is how you should do it:

topic

Code: Select all

Strassenlicht/cmd
message/payload

Code: Select all

GPIO,12,1

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 13:44
by kevin9r
So my mqtt command should be:
Strassenlicht/cmd GPIO,13,1?

This is not working. I had put my config in attachments and my try too

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 13:50
by grovkillen
I suggest you do screenshots instead of photos.

You have the following setting /%sysname%/# according to your picture. so the topic should then be:

Code: Select all

/Strassenlicht/cmd
Please observe that leading front slash!!

And the payload should then be:

Code: Select all

GPIO,12,1
Or whatever pin you want to control.

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 17:13
by kevin9r
/Strassenlicht/cmd GPIO,13,1 is not working and

/Strassenlicht/cmd/GPIO,13,1 isnt working too... :oops:

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 17:21
by randytsuch
Format needs to be
topic: /ESP_EASY/cmd
payload: gpio,12,1

Its not clear from your screenshot what the topic is, and what the payload is.
MQTT messages always have a topic and a payload.

For gpio, you can also do this
topic: /ESP00/gpio/12
payload of 0 or 1

It will work, but not recommended, the first way works for any command, the 2nd only works for gpio.

BTW, you should really remove the first "/" from everything (esp side and openhab side), but as long as you are consistent, you have it both places or don't have it both places, it should work.

I also found a mqtt sniffer program to REALLY help figure out mqtt problems. It shows exactly what is being sent.

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 17:31
by kevin9r
okay thanks for your information. I couldn't find much information at the internet and i had tried a lot of possibilities. Can you tell me where i find the information about the topic and the payload? Depent it on the mqttbroker? Or is it in the ESPEasy configuration?

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 17:37
by grovkillen
The topic and payload I suggested should work. Seems like how you're sending the info is the problem. Please use another MQTT client since the one you're using seems a bit vague on how to do things.

Re: EspEasy with openhab and mqtt not working

Posted: 11 Sep 2018, 21:41
by randytsuch
You really should get a mqtt sniffer
https://www.hivemq.com/blog/seven-best- ... ient-tools

It will take a few minutes to figure out how to setup and get it working, but it makes it SO much easier when you can actually see what's going on.

And you can use them to send stuff too.

I've used both mqtt.fx and mqttlens from the list above, and they both work fine for helping to debug mqtt problems.