[SOLVED] MQTT Switch doesn't work

Get one and use one. They are the best tools for debugging mqtt

How they would help me debug? It seems that openhab just don’t publish MQTT message

Btw, DE1State item from my .items work - when I do mosquitto_pub -h 192.168.1.170 -t de1/state_update -m "test" I see state gets updated in habmin

Also if I do ‘mosquitto_pub -h 192.168.1.170 -t de1/command -m “test”’ I can also see my mosquitto_sub window showing “test” - so broker is working

Fine if you don’t want my advice


I am sorry, I didn’t mean that I don’t want your advice, I am trying to understand how subscribing to the topic can help debugging problem when it seems that openhab doesn’t publish anything


Launched MQTT.fx, subscribed to de1/command topic - nothing

Broker Status in MQTT.fx shows that number of Messages Publish Sent doesn’t change
Is there a way to turn on logs in openhab to see if it even try to publish anything?

Yes your log

There is nothing new in openhab.log when I change state of the switch :confused:

Can I see the log?

Subscribing to the topic will turn ‘seems’ into certainty

As I mentioned in several of my previous posts - I don’t get message when I subscribe

It’s literally the same as I posted earlier - there is no new lines in openhab.log when I toggle switch. I will post it again when I get home

Try changing the topic.

Changed to “de1/trigger” - same result

showlogs:

==> /var/log/openhab2/events.log <==
2018-06-13 05:16:00.001 [vent.ChannelTriggeredEvent] - astro:sun:local:daylight#event triggered START
2018-06-13 05:16:00.002 [vent.ChannelTriggeredEvent] - astro:sun:local:rise#event triggered END
2018-06-13 05:16:00.003 [.event.RuleStatusInfoEvent] - eafb1fc3-79a9-466a-b599-721e29ffd762 updated: RUNNING
2018-06-13 05:16:00.004 [ome.event.ItemCommandEvent] - Item 'exterior_light_switch' received command OFF
2018-06-13 05:16:00.004 [ome.event.ItemCommandEvent] - Item 'zwave_device_contoller_node12_switch_binary' received command OFF
2018-06-13 05:16:00.004 [.event.RuleStatusInfoEvent] - eafb1fc3-79a9-466a-b599-721e29ffd762 updated: IDLE
2018-06-13 05:24:00.001 [vent.ChannelTriggeredEvent] - astro:moon:local:rise#event triggered START
2018-06-13 12:44:00.002 [vent.ChannelTriggeredEvent] - astro:moon:local:phase#event triggered NEW
2018-06-13 13:10:00.002 [vent.ChannelTriggeredEvent] - astro:sun:local:noon#event triggered START
2018-06-13 13:11:00.001 [vent.ChannelTriggeredEvent] - astro:sun:local:noon#event triggered END

==> /var/log/openhab2/openhab.log <==
2018-06-13 18:23:01.961 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'DE1Plus.items'
2018-06-13 18:23:01.963 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1
2018-06-13 18:23:01.963 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1
2018-06-13 18:23:01.963 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Removing message producer for broker 'mosquitto'
2018-06-13 18:23:01.964 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message consumers for item DE1State
2018-06-13 18:23:01.964 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Unsubscribing message consumer for topic 'de1/state_update' from broker 'mosquitto'
2018-06-13 18:23:01.964 [DEBUG] [.internal.MqttGenericBindingProvider] - Removing message publishers for item DE1State
2018-06-13 18:23:01.965 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'DE1State' : 1 subscribers, 0 publishers
2018-06-13 18:23:01.965 [DEBUG] [t.mqtt.internal.MqttBrokerConnection] - Starting message consumer for broker 'mosquitto' on topic 'de1/state_update'
2018-06-13 18:23:01.965 [DEBUG] [binding.mqtt.internal.MqttItemConfig] - Loaded MQTT config for item 'DE1' : 0 subscribers, 1 publishers

.items:

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/trigger:command:*:default]" }

Not sure if that relevant, but when I subscribe to ‘#’ topic I see retained message to “myhome/bedroom/switch2” in MQTT.fx showing up
 I do have it defined in another .items file - but it also doesn’t work when I trigger switch - no mqtt messages

switch.items:

//Switch Switch1 {mqtt=">[mosquitto:myhome/bedroom/switch1:command:ON:1],>[mosquitto:myhome/bedroom/switch1:command:OFF:0],<[mosquitto:myhome/bedroom/switch1:state:ON:1],<[mosquitto:myhome/bedroom/switch1:state:OFF:0"}
Switch SwitchMQTT { mqtt=">[mosquitto:myhome/bedroom/switch2:command:ON:1],>[mosquitto:myhome/bedroom/switch2:command:OFF:0],<[mosquitto:myhome/bedroom/switch2:state:ON:1],<[mosquitto:myhome/bedroom/switch2:state:OFF:0]" }

How do you trigger your switches?
In classicui?
Can I see your sitemap, please?

After reading some source code (https://github.com/openhab/openhab1-addons/blob/db62be70e9cd9561036d8925a177a2e37aaa4bd4/bundles/binding/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/internal/MqttItemBinding.java) I kinda starting to thinking that it might be
my item doesn’t receive any commands when I trigger them from Habmin Sitemaps

I feel like an idiot now, when I trigger switch from Habmin - nothing happens, when I trigger form Basic UI - everything works :frowning:

Thanks a lot for dealing with me, I feel bad for wasting so much your time

Use habmin for Zwave configuration. Use the rest of openhab for other things.

Can you mark the solution, please?
Thank you

Good luck