@Heiko_Fanieng you need to check the messages on your broker, then configure your item accordingly. Can’t help further with the details provided…
Thanks for your reply @ThomDietrich
Meanwhile i found another thread in the community that pointed me to do some Mappings for the MQTT-Values.
Switch 61_FibaroSensorAnwesenheit "Anwesenheit [%s]" <Motion> { mqtt="<[pi:zway/60Flur/bewegung:state:MAP(uppercase.map)]"}
uppercase.map:
on=ON
off=OFF
Maybe you want to extend this Tutorial with this inforamtions?
Regards
Heiko
Hmm well this is a feature of the MQTT Binding you can work with after the basic communication via MQTT works. The latter is the subject of this Tutorial. I’m not sure how far we want to drive it. I guess it wouldn’t be wrong to at least add a hint wrt the issue at the end of the article. @rlkoshak wdyt?
@Heiko_Fanieng the Tutorial is a wiki article, meaning that everyone is allowed to modify it. As I am currently preoccupied I’d like to ask you to add this part. Thanks!
I’m ambivalent. It wouldn’t hurt to mention that the messages might need to be transformed in the article and how to do so, but at some point we will just be duplicating what is already in the README, which I don’t think we want to do.
Like you say, its a wiki so @Heiko_Fanieng, please consider adding to the article.
Maybe we need an MQTT 201 article.
Dear all,
Thank you also for the geat tutorial that got me so far in the right direction but now I got stuck with connection a Sonoff touch. I followed the tutorial and tested it sucessfully with mqttspy.
See: (yeahh!!)
==> /var/log/openhab2/events.log <==
2018-02-22 23:52:19.622 [vent.ItemStateChangedEvent] - MQTT_Test changed from NULL to ON
2018-02-22 23:52:25.424 [vent.ItemStateChangedEvent] - MQTT_Test changed from ON to OFF
But to start with: I´m running openHAB 2.2.0-1 on RPI 2
I flashed successfully an Sonoff touch with the Tasmota Software.
I then tried to follow the tutorial @ https://github.com/arendst/Sonoff-Tasmota/wiki/openHAB#integration
which showed the same specs like my module. But doesnt react to to the switch i defined in sonoff.items that I found in the tutorial.
Can you please tell me if there i an example for a working test.items to work with sonoff touch?
thanks a lot!!
rob
Dear diary,
Again late evening and still trying to hook on a sonoff touch onto openhab2.
Well: configured the sonoff module sucess: config as shown:
/etc/services/mqtt.cfg as follows:
Then I wrote an test.items in /items as follows:
and finally a nice test.sitemap for to be displayed in the basisui
The result is then shown in the basicui
and when I push the lever in the ui i can see the logfile that “test” switches from 0 to 1 or 1 to 0
But unfortunatly the sonoff touch wont react inbound nor outbound? What did i wrong??
dear diary … have a nap now… ;-))
first of all: better not to use a tutorial thread to solve problems (open up a new thread)
secondly: your broker alias is broker
(as set in mqtt.cfg)… use this alias in the items file (not openhabianpi)
Thanks a lot for the prompt answer. Ahh… that makes sense!
So if i would rename the broker to eg. ohbroker i should have written:
mqtt.cfg:
ohbroker.url=tcp://openhabian:1883
ohbroker.user=openhabian
ohbroker.password=password
and then test.items:
Switch test “testchen” { mqtt=">[ohbroker:cmnd/sonoff-wz/POWER:command:*:default], <[ohbroker:stat/sonoff-wz/POWER:state:default]" }
correct?
tested but no result.
see config:
I can see a reaction when i shift the lever but no interaction with the sonoff touch! why???
You configured a custom full topic for MQTT, however you are not using it.
You need to start each statement with “tasmota”.
, like:
ohbroker:tasmota/cmnd/sonof…
Thank you Jürgen, good suggestion - I updated test.items according your thoughts - but still the same result:
log reacts on the lever in basic ui but no way interaction with the tasmota touch. see updated screens…
In addition and desperation I also edited mqtt-eventbus.cfg
and mqtt-persistence.cfg
New Status: Working!
Reason: I changed the name of the host from openhabianpi to its IP-adress. Obviously the module has problems in nameresulution?
Anyways - it´s working. Maybe interesting for others?
, glad you got it working, although the problem you observed is definetly not a gerneral one. My sonoff devices work on the name of my OH-raspi!
@opus
I have had this problem before, even with 'localhost'
!
I now always put the IP address to avoid that
On the wiki troubleshooting bit?
(I know that I can edit the first post )
should we replace these troubleshooting instructions with the new setting?
pid: org.openhab.mqtt
I haven’t tested this yet (soon, I will) so I am asking around for now
Sorry to have to ask a stupid question.
I get everything working fine up to step 7. I send the MQTT message from the client but nothing is showing up in the openHAB logs. Note, the logs is showing that the binding is able to connect to the broker. Would there be something obvious I am missing?
Could you post your mqtt.cfg and items, please
Hi vzorglub.
Never mind - worked it out. Had left a < on one of the entries in mqtt.cfg. Sorry for the stupidity
Absolutely.
ok… here we go… I did a small test on the pid parameter story… conclusion: It works as expected
@Kai
start:
Clean openHAB 2.3 RC1 on rPi3 with Zulu Embedded build 1.8.0_152-b76 aarch32hf and mosquitto 1.5
installed mqtt1 binding and configured /etc/openhab2/services/mqtt.cfg
as follows:
rpi3.url=tcp://127.0.0.1:1883
rpi3.clientId=oh2rpi3
rpi3.user=openhab
rpi3.pwd=some_strange_stuff
Got connected ok
2018-05-25 18:03:04.760 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-05-25 18:03:04.764 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'rpi3'
check console for stored configs:
openhab> config:list "(service.pid=org.openhab.mqtt)"
----------------------------------------------------------------
Pid: org.openhab.mqtt
BundleLocation: mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.12.0.RC1
Properties:
felix.fileinstall.filename = file:/var/lib/openhab2/etc/org.openhab.mqtt.cfg
rpi3.clientId = oh2rpi3
rpi3.pwd = some_strange_stuff
rpi3.url = tcp://127.0.0.1:1883
rpi3.user = openhab
service.pid = org.openhab.mqtt
checked the contents of /var/lib/openhab2/etc/org.openhab.mqtt.cfg
rpi3.clientId = oh2rpi3
rpi3.url = tcp://127.0.0.1:1883
rpi3.pwd = some_strange_stuff
rpi3.user = openhab
and /var/lib/openhab2/config/org/openhab/mqtt.config
rpi3.clientId="oh2rpi3"
rpi3.pwd="some_strange_stuff"
rpi3.url="tcp://127.0.0.1:1883"
rpi3.user="openhab"
service.pid="org.openhab.mqtt"
All good so far… now we go for the intentional hiccup
added a second (wrong) broker config in the /etc/openhab2/services/mqtt.cfg
:
rpi3.url=tcp://127.0.0.1:1883
rpi3.clientId=oh2rpi3
rpi3.user=openhab
rpi3.pwd=some_strange_stuff
ERRORrpi3.url=tcp://127.0.0.1:1884
logged it:
==> openhab.log <==
2018-05-25 18:15:20.570 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-05-25 18:15:20.576 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'errorrpi3'
2018-05-25 18:15:20.621 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79) [223:org.openhab.io.transport.mqtt:1.12.0.RC1]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [223:org.openhab.io.transport.mqtt:1.12.0.RC1]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
... 2 more
2018-05-25 18:15:20.675 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'rpi3'
check again the console:
openhab> config:list "(service.pid=org.openhab.mqtt)"
----------------------------------------------------------------
Pid: org.openhab.mqtt
BundleLocation: mvn:org.openhab.io/org.openhab.io.transport.mqtt/1.12.0.RC1
Properties:
ERRORrpi3.url = tcp://127.0.0.1:1884
felix.fileinstall.filename = file:/var/lib/openhab2/etc/org.openhab.mqtt.cfg
rpi3.clientId = oh2rpi3
rpi3.pwd = some_strange_stuff
rpi3.url = tcp://127.0.0.1:1883
rpi3.user = openhab
service.pid = org.openhab.mqtt
and /var/lib/openhab2/etc/org.openhab.mqtt.cfg
:
rpi3.clientId = oh2rpi3
rpi3.url = tcp://127.0.0.1:1883
rpi3.pwd = some_strange_stuff
rpi3.user = openhab
ERRORrpi3.url = tcp://127.0.0.1:1884
and /var/lib/openhab2/config/org/openhab/mqtt.config
:
ERRORrpi3.url="tcp://127.0.0.1:1884"
felix.fileinstall.filename="file:/var/lib/openhab2/etc/org.openhab.mqtt.cfg"
rpi3.clientId="oh2rpi3"
rpi3.pwd="some_strange_stuff"
rpi3.url="tcp://127.0.0.1:1883"
rpi3.user="openhab"
service.pid="org.openhab.mqtt"
stop OH2.3RC1 (systemctl stop openhab2
), remove the ERRORrpi3.url=tcp://127.0.0.1:1884
line from /etc/openhab2/services/mqtt.cfg
, started OH2 and of course …
2018-05-25 18:21:07.051 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'errorrpi3'
2018-05-25 18:21:07.412 [ERROR] [penhab.io.transport.mqtt.MqttService] - Error starting broker connection
org.eclipse.paho.client.mqttv3.MqttException: Unable to connect to server
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:79) [223:org.openhab.io.transport.mqtt:1.12.0.RC1]
at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:650) [223:org.openhab.io.transport.mqtt:1.12.0.RC1]
at java.lang.Thread.run(Thread.java:748) [?:?]
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method) ~[?:?]
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[?:?]
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[?:?]
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[?:?]
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[?:?]
at java.net.Socket.connect(Socket.java:589) ~[?:?]
at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:70) ~[?:?]
... 2 more
2018-05-25 18:21:07.449 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'rpi3'
and console as well as both /var/lib/openhab2/etc/org.openhab.mqtt.cfg
and /var/lib/openhab2/config/org/openhab/mqtt.config
have kept the stale setting.
stop OH2.3RC1, add pid:org.openhab.mqtt
as the first line within /etc/openhab2/services/mqtt.cfg
and… Voila!
errors are gone and ConfigAdmin has been updated with the exclusive settings in the mqtt.cfg file !
2018-05-25 18:37:14.755 [WARN ] [g.dispatch.internal.ConfigDispatcher] - The file /etc/openhab2/services/mqtt.cfg subsequently defines the exclusive PID 'org.openhab.mqtt'. Overriding existing configuration now.
So: It works as expected and we will update the first post
edit: First post has been updated. By the way, this works also with a live system (no real need to stop/start OH2… I left it there just as an extra step). Of course, this pid exclusive config story can be used with many other binding configs (not only mqtt).