max2
(max)
December 22, 2018, 9:47pm
1
Hello,
after my first problem is solved, there is unfortanely a new one:
installed the mqtt binding and added this to the mqtt.cfg:
mqtt:broker.url=tcp://localhost:1883
mqtt:broker.clientId=openhab
mqtt:broker.retain=true
mqtt:broker.async=false
mqtt:broker.user=openhabian
mqtt:broker.pwd=XXXXXXXXX
For testing I created a item:
Switch MQTT_Test "Testing..." { mqtt="<[broker:testing/mqtt/topic:state:default], >[broker:testing/mqtt/back-topic:command:*:default]" }
But nothing changes when I send a “ON” to testing/mqtt/topic
1 Like
vzorglub
(Vincent Regaud)
December 22, 2018, 9:53pm
2
First question
Which MQTT binding did you install? v1 or v2?
Marfi
(Martin)
December 22, 2018, 11:41pm
4
Your item file is v1. You need the new format.
This might help: Migrating MQTT1 items to MQTT2.4 items
2 Likes
max2
(max)
December 23, 2018, 10:44am
5
Thanks!
I found the old format much better
So I’ve followed the guide and set up MQTT.
I’ve created a Thing (see screenshot).
But when I send a MQTT message (ON or 1) to cmnd/max/light/bed nothing changes (log)
max2
(max)
December 23, 2018, 2:11pm
7
So I’ve installed the v1 binding now and removed the v2.
But there’s still no log output when I send ON or 1 to testing/mqtt/topic.
Log:
2018-12-23 15:02:01.811 [INFO ] [ebuilder.internal.HomeBuilderServlet] - Started Home Builder at /homebuilder
2018-12-23 15:02:01.908 [INFO ] [panel.internal.HABPanelDashboardTile] - Started HABPanel at /habpanel
2018-12-23 15:02:16.948 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-12-23 15:02:17.682 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'rrd4j.persist'
2018-12-23 15:02:20.949 [INFO ] [thome.model.lsp.internal.ModelServer] - Started Language Server Protocol (LSP) service on port 5007
2018-12-23 15:02:21.523 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.sitemap'
2018-12-23 15:02:22.841 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at http://192.168.70.103:8080
2018-12-23 15:02:22.844 [INFO ] [.dashboard.internal.DashboardService] - Started Dashboard at https://192.168.70.103:8443
2018-12-23 15:02:23.283 [INFO ] [arthome.ui.paper.internal.PaperUIApp] - Started Paper UI at /paperui
2018-12-23 15:02:23.644 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-12-23 15:02:23.646 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
==> /var/log/openhab2/events.log <==
2018-12-23 15:02:24.151 [vent.ItemStateChangedEvent] - MQTT_Test changed from NULL to OFF
Edit: Tried to subscribe with mosquito to find the problem, and there is also no Output I sent to the channel.
your item should look like this:
Switch Sonoff_socket_01 "Wohnzimmer LED 1 [%s]" <lamp_globe_light> (EG_Wohnen,gPlugSwitch,gSonoff) { mqtt=">[broker:cmnd/schaltdose01/power:command:*:default],
<[broker:stat/schaltdose01/POWER:state:default]" }
max2
(max)
December 23, 2018, 3:17pm
9
With the old binding I have installed now?
yes, with mqtt 1.x.
The first command is cmnd to send power on or off, and the second (stat) is to get the state. Pls look for correct angles (<>) for the direction
max2
(max)
December 23, 2018, 9:32pm
11
Hello,
So I’ve reinstalled whole OpenHabian, but it is still not working.
Installed Mosquito with “sudo apt-get install -y mosquitto mosquitto-clients”
Installed MQTT Binding (V1)
Created mqtt.cfg with content:
broker.url=tcp://localhost:1883
broker.user=openhabian
broker.pwd=openhabian
Created home.items file with this content:
Switch Sonoff_socket_01 "Wohnzimmer LED 1 [%s]" <lamp_globe_light> (EG_Wohnen,gPlugSwitch,gSonoff) { mqtt=">[broker:cmnd/schaltdose01/power:command:*:default], <[broker:stat/schaltdose01/POWER:state:default]" }
And sent a “ON” or “1” to this channel: cmnd/schaltdose01/power
But there’s not output in the log. Where’s the mistake?
Console Output:
2018-12-23 22:20:17.074 [thome.event.ExtensionEvent] - Extension 'binding-mqtt1' has been installed.
==> /var/log/openhab2/openhab.log <==
2018-12-23 22:20:36.143 [INFO ] [penhab.io.transport.mqtt.MqttService] - MQTT Service initialization completed.
2018-12-23 22:20:36.152 [INFO ] [t.mqtt.internal.MqttBrokerConnection] - Starting MQTT broker connection 'broker'
2018-12-23 22:22:27.998 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.items'
2018-12-23 22:22:29.213 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'
2018-12-23 22:24:36.642 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'home.items'
What are your suggestions?
vzorglub
(Vincent Regaud)
December 23, 2018, 9:59pm
12
How do you send the value?
The input topic is stat/schaltdose01/POWER
not cmnd/schaltdose01/power
If you have a switch on a sitemap for this item, you should see the payload ‘ON’ sent on the topic cmnd/schaltdose01/power
The command topic for the sonoff is with POWER
not power
Change your item to:
Switch Sonoff_socket_01 "Wohnzimmer LED 1 [%s]" <lamp_globe_light> (EG_Wohnen,gPlugSwitch,gSonoff) { mqtt=">[broker:cmnd/schaltdose01/POWER:command:*:default], <[broker:stat/schaltdose01/POWER:state:default]" }
max2
(max)
December 23, 2018, 10:10pm
13
Sitemap:
sitemap demo label="My home automation" {
Frame label="Demo" {
Switch item=Sonoff_socket_01 icon="light"
}
}
And used your item, but there is still no on in the console.
(ON sent to: cmnd/schaltdose01/POWER)
vzorglub
(Vincent Regaud)
December 23, 2018, 10:14pm
14
What console?
How do you monitor you MQTT messages?
Do you mean the Web-Interface of your Sonoff, when your talking about console ?
and of course you can not use my mqtt-command one by one, you have to change the name(topic) of the sonoff you are using. You find this information here:
Or do you mean the Log-Viewer (logger) of your Openhab-Web-Interface
So, as Vincent @vzorglub asked, what is meant with console ?
BTW, what Hardware you are using ?
1 Like