MQTT 2.4 Migration Help

Thank you Udo. I do have this ahead of the topic, but it is telling me BRIDGE_OFFLINE -

Bridge mqtt:broker:mosquitto “Mosquitto” @ “MQTT” [
host=“192.168.1.150”,
secure=“AUTO”,
port=1883,
qos=0,
retain=true,
clientid=“Oh2Mqtt2Thing”,
//certificate=“”,
//certificatepin=false,
//publickey=“”,
//publickeypin=false,
keep_alive_time=30000,
reconnect_time=60000,
//lastwill_message=“”,
//lastwill_qos=1,
//lastwill_topic=“”,
username=“xxxxx”,
password=“xxxxxx”

I made those adjustments, still no dice yet, although it looks like progress. I was getting some messaging, but not anything being controlled.

woot woot, it magically started working. well, not really. I had both the mqtt and the embedded mqtt services installing. Also, had to remove the last / in the topics. Thanks for the help @Udo_Hartmann!!!

I’ve got two garage doors controlled via mqtt do I have two things with 1 channel or one thing with 2 channels?

Hello,
That is up to you as both approaches will work. If the garage doors are right next to each other it would probably make more sense to have one thing with two channels (eg right door and left door) but if they are separate from each other it might make more sense in your hierarchy to have two things with a channel each. You will have to link items too the channels anyway and they won’t care what thing the channel belongs to.
Best regards Johannes

Thanks for the reply, how do check current state of a channel returned, or do I create another channel to receive state?
one thing for switch and one for state?
I use this in my oh 2.3 rule to check if door left open

You can have both a state topic and a command topic in one generic mqtt2 thing channel.
Johannes

thanks,
the button is a switch and state is a “contact” but the button isn’t just on/off its a momentary switch
these appear to be different types

I think in that case I would indeed use two channels in one garage door thing. One for the state and one for the switch.

Having some issues I don’t seem to be getting updates / status changes.
my button works but the item doesn’t appear to be updated.
what am I missing.

> 
> mqtt.things
> 
> Bridge mqtt:broker:mqttbroker [ host="localhost", secure=false, clientID="openhab" ]
>     {
>       Thing topic garagedoors "Gararge Doors" @ "Garage" {
>        Channels:
>          Type switch : GarageDoor1 "Garage Door1 Switch"   [ commandTopic="sensors/garage/command/door1", on="SWITCH", off="SWITCH" ]
>          Type contact : GarageStateDoor1 "Garage Door1 Status" [stateTopic="sensors/garage/status/door1" ]
>          Type switch : GarageDoor2 "Garage Door2 Switch"   [ commandTopic="sensors/garage/command/door2", on="SWITCH", off="SWITCH" ]
>          Type contact : GarageStateDoor2 "Garage Door2 Status" [stateTopic="sensors/garage/status/door2" ]
>         }
>     }
> 	
> 	
> garage.items
> 
> Switch GarageDoor1 "Door1" <switch> {channel="mqtt:topic:mqttbroker:garagedoors:GarageDoor1" }
> Switch GarageDoor2 "Door2" <switch> {channel="mqtt:topic:mqttbroker:garagedoors:GarageDoor2" }
> 
> Contact GarageStateDoor1 "Door 1 Status [%s]" <garagedoor> (Sensors) {channel="mqtt:topic:mqttbroker:garagedoors:GarageDoor1Status" }
> String GarageStateDoor2 "Door 2 Status [%s]" <garagedoor> (Sensors) {channel="mqtt:topic:mqttbroker:garagedoors:GarageDoor2Status" }

I’m seeing the following errors which I’m not sure why:

2019-06-06 21:15:21.374 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method 'Runnable.run()' on 'org.eclipse.smarthome.core.thing.internal.ThingManagerImpl$$Lambda$693/322684888@f7ef772': org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler cannot be cast to org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler
java.lang.ClassCastException: org.eclipse.smarthome.binding.mqtt.generic.internal.handler.GenericThingHandler cannot be cast to org.eclipse.smarthome.binding.mqtt.handler.AbstractBrokerHandler
        at org.eclipse.smarthome.binding.mqtt.internal.MqttBrokerHandlerFactory.lambda$0(MqttBrokerHandlerFactory.java:83) ~[?:?]
        at java.util.WeakHashMap.forEach(WeakHashMap.java:1025) ~[?:?]
        at java.util.Collections$SynchronizedMap.forEach(Collections.java:2647) ~[?:?]
        at org.eclipse.smarthome.binding.mqtt.internal.MqttBrokerHandlerFactory.removeHandler(MqttBrokerHandlerFactory.java:83) ~[?:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandlerFactory.unregisterHandler(BaseThingHandlerFactory.java:261) ~[?:?]
        at org.eclipse.smarthome.core.thing.internal.ThingManagerImpl.lambda$5(ThingManagerImpl.java:811) ~[?:?]
        at sun.reflect.GeneratedMethodAccessor130.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
        at java.lang.Thread.run(Thread.java:748) [?:?]

I sorry Im no help here as I dont use thing files for the mqtt Binding but do it all through paper ui :frowning:
edit: are your contacts actually sending OPEN / CLOSED Values? and Im not quite sure if it makes sense to linka type contact to a string item. But thats just me guessing

You linked a channel for the contacts that doesn’t exist (correct Channels GarageStateDoor1/GarageStateDoor2 used Channels for items GarageDoor1Status/GarageDoor2Status)

excellent its now showing correct status…
However when starting openHAB I see these errors after loading things config

things file

Bridge mqtt:broker:mqttbroker “Mosquitto” [ host=“localhost”, port=1883, secure=false, clientID=“openhab” ]
{
Thing topic garagedoors “Gararge Doors” @ “Garage” {
Channels:
Type switch : GarageDoor1 “Garage Door1 Switch” [commandTopic=“sensors/garage/command/door1”, on=“SWITCH”, off=“SWITCH”, postCommand=“false” ]
Type switch : GarageDoor2 “Garage Door2 Switch” [commandTopic=“sensors/garage/command/door2”, on=“SWITCH”, off=“SWITCH” ]
Type contact : GarageStateDoor1 “Garage Door1 Status” [stateTopic=“sensors/garage/status/door1” ]
Type contact : GarageStateDoor2 “Garage Door2 Status” [stateTopic=“sensors/garage/status/door2” ]
}
}
~

2019-06-07 07:01:27.867 [ERROR] [utomation.module.script.defaultscope] - bundle org.eclipse.smarthome.automation.module.script.defaultscope:0.10.0.oh240 (218)[org.eclipse.smarthome.automation.module.script.de
faultscope.internal.DefaultScriptScopeProvider(271)] : The addThingActions method has thrown an exception
java.lang.NullPointerException: null
        at org.eclipse.smarthome.automation.module.script.defaultscope.internal.DefaultScriptScopeProvider.addThingActions(DefaultScriptScopeProvider.java:125) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.invokeMethod(BaseMethod.java:228) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.access$500(BaseMethod.java:41) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod$Resolved.invoke(BaseMethod.java:664) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BaseMethod.invoke(BaseMethod.java:510) ~[?:?]
        at org.apache.felix.scr.impl.inject.methods.BindMethod.invoke(BindMethod.java:42) ~[?:?]
        at org.apache.felix.scr.impl.manager.DependencyManager.doInvokeBindMethod(DependencyManager.java:1809) ~[?:?]
        at org.apache.felix.scr.impl.manager.DependencyManager.bindDependency(DependencyManager.java:1637) ~[?:?]
        at org.apache.felix.scr.impl.manager.DependencyManager.bind(DependencyManager.java:1625) ~[?:?]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:301) ~[?:?]
        at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:114) ~[?:?]

every thing seems to more or less works albeit some strange errors in openhab.log

another message I don’t understand I get this error:

Cannot add “ItemChannelLink” with key “GarageDoor2 → mqtt:topic:mqttbroker:garagedoors:GarageDoor2”. It exists already from provider “GenericItemChannelLinkProvider”! Failed to add a second with the same UID from provider “ManagedItemChannelLinkProvider”!

my items file:

Switch GarageDoor1 “Door1” {channel=“mqtt:topic:mqttbroker:garagedoors:GarageDoor1” }
Switch GarageDoor2 “Door2” {channel=“mqtt:topic:mqttbroker:garagedoors:GarageDoor2” }

Contact GarageStateDoor1 “Door 1 Status [%s]” (Sensors) channel=“mqtt:topic:mqttbroker:garagedoors:GarageStateDoor1” }
Contact GarageStateDoor2 “Door 2 Status [%s]” (Sensors) {channel=“mqtt:topic:mqttbroker:garagedoors:GarageStateDoor2” }

my.things:

Bridge mqtt:broker:mqttbroker “Mosquitto” [ host=“localhost”, port=1883, secure=false, clientID=“openhab” ]
{
Thing topic garagedoors “Gararge Doors” @ “Garage” {
Channels:
Type switch : GarageDoor1 “Garage Door1 Switch” [commandTopic=“sensors/garage/command/door1”, on=“SWITCH”, off=“SWITCH”, postCommand=“false” ]
Type switch : GarageDoor2 “Garage Door2 Switch” [commandTopic=“sensors/garage/command/door2”, on=“SWITCH”, off=“SWITCH” ]
Type contact : GarageStateDoor1 “Garage Door1 Status” [stateTopic=“sensors/garage/status/door1” ]
Type contact : GarageStateDoor2 “Garage Door2 Status” [stateTopic=“sensors/garage/status/door2” ]
}
}
~

Do you have or had the “Simple Mode” on? That way an item is created for each channel automatically and the theitem is also linked automatically.
You migth need the delete such links and channels either via PaperUI or via the JSON stored database for those.