publish MQTT will not work

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

publish MQTT will not work

#1 Post by bruno iemanon » 07 Oct 2019, 20:47

Hy,
I’m a new user of ESPeasy on a ESP8266
Mi goal is to publish MQTT messages from the esp to a mosquitto broker.

I have a working MQTT mosquitto broker. I tested it with MQTT lens.
In ESPeasy I also installed the controler.
Controller Settings
Protocol: Openhab MQTT
Locate Controller: Use IP address
Controller IP: 192.168.x.xxx
Controller Port: 1883
Minimum Send Interval: 100 [ms]
Max Queue Depth: 10
Max Retries: 10
Full Queue Action:Ignore new
Check Reply:ignore acknowlegdment
Client Timeout: 1000 [ms]
Controller User: openhab
Controller Password: •••••
Controller Subscribe: /%sysname%/#
Controller Publish: /%sysname%/%tskname%/%valname%
Controller lwl topic: muziek
LWT Connect Message:
LWT Disconnect Message:

When I use the command "publish muziek, test123" in the command line of the Tools-tab, all works fine.
I recieve the same message in the broker (i verified this with MQTT Lens)

When i add a DS18B20-sensor as a device, i’ts measuring the correct temperature. I also checked "send to controler"

But still there is no temperature published to the broker. (according to what i can see with MQTT Lens).
I have the same problem with the AM2320-sensor.
What am I doing wrong?

User avatar
grovkillen
Core team member
Posts: 3284
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: publish MQTT will not work

#2 Post by grovkillen » 08 Oct 2019, 08:10

I suspect the first / is what is causing your problem. Try to remove that from your settings of the controller. Or make sure that MQTT Lens is subscribing to that empty first level.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

Re: publish MQTT will not work

#3 Post by bruno iemanon » 08 Oct 2019, 17:20

Thanks for your answer.
I removed the / but that makes no difference.

What do you mean with "make sure that MQTT Lens is subscribing to that empty first level"

any other advice?

User avatar
grovkillen
Core team member
Posts: 3284
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: publish MQTT will not work

#4 Post by grovkillen » 08 Oct 2019, 17:54

You can subscribe to all messages using #
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

Re: publish MQTT will not work

#5 Post by bruno iemanon » 11 Oct 2019, 10:30

Thanks a lot,

Thats's works fine.

Just to undertand the whole picture, could you explain what's the meaning/purpose of:
- Controller lwl topic:
- LWT Connect Message:
- LWT Disconnect Message:

User avatar
grovkillen
Core team member
Posts: 3284
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: publish MQTT will not work

#6 Post by grovkillen » 11 Oct 2019, 11:15

Those are the topics for when the unit is connected and disconnected (as seen by the broker). If the unit connects/disconnected the broker will publish those messages.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

waspie
Normal user
Posts: 111
Joined: 09 Feb 2017, 19:35

Re: publish MQTT will not work

#7 Post by waspie » 11 Oct 2019, 15:16

I've just compiled the October 3 release and all my MQTT publishes are jacked in openhab (related to this topic???)


Formerly this worked fine:
(rules) Publish /%sysname%/delta,[utilityMisc#delta]
as seen by the broker: 2019-10-11 09:15:11.962 /utilityRoom/delta 0

As seen by openhab:
2019-10-11 09:15:32.180 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Incoming payload '0 ' not supported by type 'N
umberValue'


Previous to this I was using something from early September (i think).


***edit***
not just rules, even publishing a temperature via a dallas sensor gives this error. it seems as if openhab thinks extra crap is getting sent. this worked perfectly fine for the 2+ years i've been using ESPEasy until the October 3 release (or maybe slightly before this one)

bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

Re: publish MQTT will not work

#8 Post by bruno iemanon » 11 Oct 2019, 20:38

Thanks grovkillen,
i am learning every day...

I have now 2 esp8266 running. One named "woonkamer 1" and one names "luidsprekers"

on "woonkamer 1" i installed 1 controler and 2 devices:
- mqtt openhab controler
Controller Subscribe: %sysname%/#
Controller Publish: %tskname%/%valname%

- Switch input - Switch
Name: dkrl1
Data Acquisition Send to Controller ❶
Values Name 1 state

- Generic - MQTT Import
Name: mqrl1
Enabled: x
MQTT Topic 1: dkrl1/state

on this esp ("woonkamer 1") the MQTT import works fine. (value 1 of the generic mqtt import device changes by using the switch input device)

with mqtt lens all works fine as well.

on "luidsprekers" i installed the same mqtt controler and the same mqtt import device:

- mqtt openhab controler
Controller Subscribe: %sysname%/#
Controller Publish: %tskname%/%valname%

- Generic - MQTT Import
Name: mqrl1
Enabled: x
MQTT Topic 1: dkrl1/state

on this esp ("luidsprekers") the MQTT import doesn't work. (value 1 of the generic mqtt import device doesn't change).

Any idee?

what is the purpose off the "Controller Subscribe: %sysname%/#" in the controler?
And what is the difference with the MQTT Topic of a generic mqtt import device?

TD-er
Core team member
Posts: 1656
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: publish MQTT will not work

#9 Post by TD-er » 12 Oct 2019, 00:31

Is it maybe related to this issue: https://github.com/letscontrolit/ESPEasy/issues/2657 ???
Judging from the logs you post, it looks like there is a space behind the 0 in the publish line.
Can you test the same logitem test I suggested in that issue on Github?

bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

Re: publish MQTT will not work

#10 Post by bruno iemanon » 12 Oct 2019, 17:46

There was no space behind the %.
Unfortuanaly the github conversation is on this moment still chinese for me.

But i found the reason. The responce time is +- 40 seconds. So i just didn't waited long enough to see the value changing.

But how can i reduce the time between pushing a button on one device and recieving the mqtt message on another device.

current Controller Settings on both devices:
- MQTT Retain Msg: x
- Message Interval: 100 [ms]

TD-er
Core team member
Posts: 1656
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: publish MQTT will not work

#11 Post by TD-er » 12 Oct 2019, 18:18

40 seconds is way too long, at least to be practical.

It is hard to see why it is taking so long without knowing more.

bruno iemanon
Normal user
Posts: 6
Joined: 07 Oct 2019, 20:04

Re: publish MQTT will not work

#12 Post by bruno iemanon » 12 Oct 2019, 18:47

seems like it's the refresh time of my browser.

Any idea how i can reduce that?

TD-er
Core team member
Posts: 1656
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: publish MQTT will not work

#13 Post by TD-er » 13 Oct 2019, 20:33

The refresh on the device page is done by a piece of JavaScript.
That's taking a JSON file from the ESP and this file has a suggested refresh time in it.
This refresh is based on when a new value can be expected.

It is computed by looking at the set "interval" value on all active plugins and the lowest value is then used.
So you can set any task to a lower interval value and it will perform more frequent updates on the Devices page.

Post Reply

Who is online

Users browsing this forum: No registered users and 21 guests