ikir
(Kirill)
June 10, 2018, 7:46pm
1
I am trying to make a simple switch that would send message to the MQTT topic
here is my .items:
String DE1State {mqtt="<[mosquitto:de1/state_update:state:default]"}
Switch DE1 "DE1" ["Switchable"] {mqtt=">[mosquitto:de1/command:command:*:Switch ${itemName} was turned ${command}]"}
My .sitemap:
sitemap demo label="My MQTT Demo Switches" {
Frame label="Demo" {
Text item=DE1State
Switch item=DE1
}
}
I see that my string idem gets updated when I publish something to de1/state_update topic, but nothing happened when I toggle switch in Habmin - I donât see any topic gets publishedâŠ
I tried
Switch DE1 "DE1" ["Switchable"] {mqtt=">[mosquitto:de1/command:command:*:default"}
it didnât work eitherâŠ
Any ideas what I am doing wrong?
vzorglub
(Vincent Regaud)
June 10, 2018, 7:55pm
2
You need a space after the {
and before the }
Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:Switch ${itemName} was turned ${command}]" }
ikir
(Kirill)
June 10, 2018, 8:01pm
3
Hm⊠I donât have space in my String my itemâŠ
vzorglub
(Vincent Regaud)
June 10, 2018, 8:02pm
4
Yours:
Switch DE1 "DE1" ["Switchable"] {mqtt=">[mosquitto:de1/command:command:*:Switch ${itemName} was turned ${command}]"}
Mine:
Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:Switch ${itemName} was turned ${command}]" }
See the difference now?
ikir
(Kirill)
June 10, 2018, 8:03pm
5
Also, looking at openhab.log it didnât fail parsing and actually added subscription on topic de1/command:
2018-06-10 13:02:14.878 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1â : 1 subscribers, 1 publishers
2018-06-10 13:02:14.878 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker âmosquittoâ on topic âde1/commandâ
ikir
(Kirill)
June 10, 2018, 8:04pm
6
Adding space didnât help
vzorglub
(Vincent Regaud)
June 10, 2018, 8:07pm
7
You should have 1 publisher, 0 subscribers
It that the entire item definition?
vzorglub
(Vincent Regaud)
June 10, 2018, 8:11pm
8
Try this:
Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:default]" }
ONLY
hmerk
(Hans-Jörg Merk)
June 10, 2018, 8:54pm
10
Square bracket missing at the end.
vzorglub
(Vincent Regaud)
June 10, 2018, 8:56pm
11
@hmerk , Yes I missed that
But the longer definition should work, though. Going back to basics.
Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:default]" }
ikir
(Kirill)
June 11, 2018, 2:05am
14
mosquitto.url=tcp://localhost:1883
mosquitto.clientId=openhab
mosquitto.retain=true
mosquitto.async=false
Dim
(Angelos)
June 11, 2018, 4:42am
15
ikir:
â] { mqtt="
could be a typo, but try to use the correct quote marks everywhere: ""
instead of ââ
Also, add a spaces in the tag (it should work also without i think)
Switch DE1 "DE1" [ "Switchable" ] { mqtt=">[mosquitto:de1/command:command:*:default]" }
you should have some log entry about errors in your items file.
vzorglub
(Vincent Regaud)
June 11, 2018, 5:40am
16
I didnât see these bloody quotes on my phone screen!
1 Like
vzorglub
(Vincent Regaud)
June 11, 2018, 5:53am
17
mosquitto.url=tcp://127.0.0.1:1883
mosquitto.clientId=openhab
mosquitto.retain=true
mosquitto.async=false
Show me the openhab.log when OH starts and when you edit the item file, please
Also can you publish the complete items file, thanks
1 Like
ikir
(Kirill)
June 11, 2018, 11:35pm
18
Complete .items file:
String DE1State { mqtt="<[mosquitto:de1/state_update:state:default]" }
//Switch DE1 "DE1" ["Switchable"] {mqtt="<[mosquitto:de1/state_update:state:default],>[mosquitto:de1/turn_on:command:ON:1],>[mosquitto:de1/turn_off:command:OFF:0]"}
//Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:default],<[mosquitto:de1/command:command:*:default]" }
//Switch DE1 "DE1" ["Switchable"] {mqtt=">[mosquitto:de1/command:*:Switch ${itemName} was turned ${command}]"}
//Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:default" }
Switch DE1 "DE1" ["Switchable"] { mqtt=">[mosquitto:de1/command:command:*:default]" }
openhab.log:
2018-06-11 16:33:22.745 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1â : 0 subscribers, 1 publishers
2018-06-11 16:33:22.748 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model âDE1Plus.itemsâ
2018-06-11 16:33:22.750 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1State
2018-06-11 16:33:22.750 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Unsubscribing message consumer for topic âde1/state_updateâ from broker âmosquittoâ
2018-06-11 16:33:22.750 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1State
2018-06-11 16:33:22.751 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1
2018-06-11 16:33:22.751 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1
2018-06-11 16:33:22.751 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Removing message producer for broker âmosquittoâ
2018-06-11 16:33:22.751 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1Stateâ : 1 subscribers, 0 publishers
2018-06-11 16:33:22.752 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker âmosquittoâ on topic âde1/state_updateâ
2018-06-11 16:33:22.752 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1â : 0 subscribers, 1 publishers
2018-06-11 16:33:22.757 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model âDE1Plus.itemsâ
2018-06-11 16:33:22.759 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1State
2018-06-11 16:33:22.759 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Unsubscribing message consumer for topic âde1/state_updateâ from broker âmosquittoâ
2018-06-11 16:33:22.760 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1State
2018-06-11 16:33:22.760 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1
2018-06-11 16:33:22.760 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1
2018-06-11 16:33:22.761 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Removing message producer for broker âmosquittoâ
2018-06-11 16:33:22.761 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1Stateâ : 1 subscribers, 0 publishers
2018-06-11 16:33:22.761 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker âmosquittoâ on topic âde1/state_updateâ
2018-06-11 16:33:22.762 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item âDE1â : 0 subscribers, 1 publishers
vzorglub
(Vincent Regaud)
June 12, 2018, 6:08am
19
It should work
Do you have an MQTT monitor like mqtt.fx or mqtt-spy?
Get one and subcribe to the topic de1/command
. You should see the payload ON
and OFF
when you action the switch.
ikir
(Kirill)
June 12, 2018, 11:59pm
20
It doesnât work, I use mosquito_sub -t de1/command to listen and when trigger control from habminâs sitemap I donât see anything in terminal where mosquito_sub is runnin