MQTT Broker gateway
-
Typing from tablet => short Version
Contact items needs Open or Closed not On vor Off. Make a new map translating 0 to closed etc and it should work. or use the correct item: switch seems a better choice
https://github.com/openhab/openhab/wiki/Explanation-of-items#itemtype -
Hi @dakky
well, some luck. I made a new map contact.map with
0=Closed
1=Open
-=unknownso far the swtich now shows "Unknown" all the time; but no status updates from the sensor (even though it is showing in serial console as 1, and 0 when it is off).
Not sure why it isn't updating like it should now. Might have to reboot the server.
-
Ok, got it. Had to do the following to my items and sitemap to get a PIR to work right:
entry in default.items
Switchnode6_motion "LR Motion Test [MAP(motion.map):%s]" (FF_Living,All) {mqtt=">[mysensor:MyMQTT/6/1/V_TRIPPED:command:ON:1],>[mysensor:MyMQTT/6/1/V_TRIPPED:command:OFF:0],<[mysensor:MyMQTT/6/1/V_TRIPPED:command:MAP(motion.map)]"}and default.sitemap
Text item=node6_motion label="PIR Test LR [%s]" icon="pir"And last, the transform file (named motion.map)
1=ON 0=OFFAt least now it registers the data in text as On or Off. Thanks again @dakky
-
Is there a way to redirect all the messages from the serial console of the wifi gateway to some tcp port so they can be read via putty?
-
Hello, sorry to reopen this post, but maybe someone can help me! I'm still waiting the arrival of my arduinos to make my nodes and gateways, but I already installed openhab to start configuring the layout and MQTT. All is working, I can post to MTQQ from openhab and used the tutorial on this post to make the same button send and recieve.
The problem is that when I click the button with the code "sw2 send + recieve example" openhab enters in loop mode, it seems that keeps sending and reviving the same MTQQ request. I use MQTT.fx to test the MTQQ posts, and when I click the button, the program also crashes and takes my CPU to max.
Can any one help me?
Best Regards
Soloam -
Hello, the problem persists, the map function keeps sending the same request over and over again, If I make a click in a few seconds my mqtt client is full of requests, over 500 with the same message. Wasn't it supposed to send only one message for click?
-
I don't believe you can put both inbound and outbound mqtt messages in the switch definition. This is what creates the infinite loop since you are both sending and receiving on the same message topic. Every time the broker receives the message, it publishes it out to all subscribers. Since your switch item is also a subscriber it picks it up again and the loop continues.
Use only inbound in the definition then either a rule and/or proxy item to handle the outbound command. Set your rule definition "when item received command". That way it will only fire when you click on the switch item in openHAB. If you use any other option, ie. received update or changed, it will also continue the infinite loop.
Hope this makes sense.
-
That makes perfect seance, I was only mirroring the solution presented on the 1st post of this topic. I will try your approach!
Thank You
-
It didn't worked, the rule also changes when I receive the MQTT in openhab:
rule "Send Requst" when Item node2_sw2 received command then if(node2_sw2.state == ON){ sendCommand(node2_sw1,ON) } else{ sendCommand(node2_sw1,OFF) } endI don't believe this is a new problem to the forum, didn't any one made, a switch on the openhab with inptut and output.
-
Found the solution tanks to watou user in OpenHab Forum.
Switch node2_sw2 "sw2 send + recieve example" (node2,all) {mqtt=">[mysensor:MyMQTT/21/2/V_LIGHT:command:OFF:0],>[mysensor:MyMQTT/21/2/V_LIGHT:command:ON:1],<[mysensor:MyMQTT/21/2/V_LIGHT:state:MAP(1on0off.map)]"}The secret is in the :state: declaration on the MAP!
Thank you all