Hi there, I am new to OpenHab community. I have installed OpenHab 2.2.0 (runtime) and Mosquitto 1.4.15 on a windows 10 desktop. mqtt binding and openhab are working fine. However the messages published are not replacing ${itemName} properly. Any suggestions ?
GH/in/${itemName} Open
GH/out/GH_GarageDoor_Cmd/state ON
GH/out/GH_GarageDoor_Cmd/cmd ON
GH/in/${itemName} Close
GH/out/GH_GarageDoor_Cmd/state OFF
GH/out/GH_GarageDoor_Cmd/cmd OFF
[quote=“ykgoel, post:1, topic:45399”]
Hi Dim,
That will be interesting as another item defined for subscribe as follows:
String GH_GarageDoor_State “Door [%s]” (Garage) {mqtt="<[localBroker:GH/out/${itemName}:state:default]",autoupdate=“true”}"]
is able to get the message from the queue. So I doubt it will behave different for publish. I can definitely hardcode the item name here but eventually I would like to use mqtt event bus so not sure if its a limitation here.
Thanks for your suggestion and quick response.
yes, I saw that also… the variable works for inbound (sub) but doesn’t work for outbound (pub)… that’s strange
maybe this case is worth a creation of an issue on github for the mqtt binding (to allow on both the use of the variables)
Thanks again Dim. Also if you can help me with one thing that’s puzzling.
I changed the variables to hardcoding as suggested in default.item file as follows:
String GarageDoor_State “Door [%s]” (Garage) {mqtt="<[localBroker:GH/out/GH_GarageDoor_State:state:default]",autoupdate=“true”}
Switch GarageDoor_Cmd “DoorCmd” (Garage) {mqtt=">[localBroker:GH/in/GH_GarageDoor_Cmd:command:ON:Open],>[localBroker:GH/in/GH_GarageDoor_Cmd:command:OFF:Close]"}
However I am not able to understand why two extra messages for topic “GH/out/GarageDoor_Cmd/State and cmd” are being getting generated ? Please see output from mosquitto - v - t “#” below. Is it expected ? Any thoughts.
GH/in/GH_GarageDoor_Cmd Close
GH/out/GarageDoor_Cmd/state OFF
GH/out/GarageDoor_Cmd/cmd OFF
GH/in/GH_GarageDoor_Cmd Open
GH/out/GarageDoor_Cmd/state ON
GH/out/GarageDoor_Cmd/cmd ON
Maybe? the remote device (the Garage Door thingy) is reporting these 2 messages to the broker after it receives the Close message?
Which device is publishing these 2 payloads to the MQTT Broker?
The first payload is obviously being published by openHAB (the “Close” message). The other 2… I am not sure.
I thought that too first but then I turned the IoT (Nodemcu with sensor) device completely off for trouble shooting. Currently only OpenHab runtime and Mosquitto broker are running and I still see these messages coming into the queue. So definitely Openhab is generating these messages but why that’s puzzling. Any pointers ?
No I haven’t configured anything yet in mqtt-eventbus.cfg but was planning to do that later. Right now trying to keep it simple to understand the concept.
The extra message generation is getting more and more interesting. It seems like for each item OpenHab is publishing one/two extra messages to report the state and cmd respectively.
I issued following two manual commands for mosquito and changed the switch position (openhab app on android)
GH/out/GH_GarageDoor_State Close <-- Came from manual command
GH/out/GarageDoor_State/state Close <–Came from OpenHab. Topic is different
GH/out/GH_GarageDoor_State Open <–Came from manual command
GH/out/GarageDoor_State/state Open <–Came from OpenHab. Topic is different
GH/in/GH_GarageDoor_State Close <–Came from turning switch off from app
GH/out/GarageDoor_Cmd/state OFF <–Came from OpenHab. Topic is different
GH/out/GarageDoor_Cmd/cmd OFF <–Came from OpenHab. Topic is different
GH/in/GH_GarageDoor_Cmd Open <–Came from turning switch on from app
GH/out/GarageDoor_Cmd/state ON <–Came from OpenHab. Topic is different
GH/out/GarageDoor_Cmd/cmd ON <–Came from OpenHab. Topic is different
I decided to turn everything off and restart (openhab and mosquito servers) still same output. Puzzled ?
It seems like the userdata file stored all the enteries that I was trying out with mqtt-event-bus file. Even when I commented out changes in original file this file still keeps everything. Is there a good way to cleanup userdata to reflect original entries. I just manual updated the userdata files.
Appreciated your prompt help and response. You are awesome!
this story with the stale configs has been a pain in the @ss for many people
stale configs: you edit/modify your regular config files in conf folder but some old settings remain stored in the userdata and they are not cleaned up / overwritten.
This issue has been solved recently in OH 2.
I will find the thread where Kai mentioned the fix and link it here @rlkoshak had opened up the issue on github… i will find the link to it also