MQTT 2.4 Migration Help

Hi @crxporter & @Udo_Hartmann,

Thank you so much for your input so far, you have been a great help. Apologies, I’ve not got around to responding earlier (may be time difference, I’m in the UK).

However, I’ve now had chance to play around with configutrations and the below actually results in a error in the log.

Bridge mqtt:broker:oh [ host="localhost", secure=false  ] {
    Thing topic rearGarageDoor "Rear Garage Door" {
    Channels:
        Type switch : power "Power" [ stateTopic="stat/rearGarageDoor/POWER", commandTopic="cmnd/rearGarageDoor/POWER" ]
        Type contact : contact "Contact" [ stateTopic="cmnd/rearGarageDoorSensor/POWER2", ON="OPEN", OFF="CLOSED" ]
    }
}

Contact Rear_Garage_Door_Sensor “Garage Door Sensor [%s]” (House, Rear_Garage) { channel=“mqtt:topic:oh:rearGarageDoor:contact” }

The error that I get is:

2019-01-04 18:33:19.016 [WARN ] [eneric.internal.generic.ChannelState] - Command ‘ON’ not supported by type ‘OpenCloseValue’: No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.ON

2019-01-04 18:33:27.981 [WARN ] [eneric.internal.generic.ChannelState] - Command ‘OFF’ not supported by type ‘OpenCloseValue’: No enum constant org.eclipse.smarthome.core.library.types.OpenClosedType.OFF

Any ideas what I could try next?

Thanks,

Jeevs :slight_smile:

It looks like an error sending “ON” and “OFF” to a “contact” item. I would try this next - note switching ON<->OPEN and OFF<->CLOSED

Bridge mqtt:broker:oh [ host="localhost", secure=false  ] {
    Thing topic rearGarageDoor "Rear Garage Door" {
    Channels:
        Type switch : power "Power" [ stateTopic="stat/rearGarageDoor/POWER", commandTopic="cmnd/rearGarageDoor/POWER" ]
        Type contact : contact "Contact" [ stateTopic="cmnd/rearGarageDoorSensor/POWER2", OPEN="ON", CLOSED="OFF" ]
    }
}

Thank you, with the above I get no error and nothing happens on the ui :frowning:

Give me a few minutes, I’m going to try it on my 2.4 setup real quick!

Your door is sending the following, correct?

cmnd/rearGarageDoorSensor/POWER2 = OFF
cmnd/rearGarageDoorSensor/POWER2 = ON

That is absolutley correct! :slight_smile: - Thank you!

Alright mr/ms @Jeevs -

I got it working. I was very stuck but then I realized I didn’t have the “Map Transformation” installed in the paper UI.

This works:

THINGS

Bridge mqtt:broker:mosquitto "Mosquitto" [ host="localhost", port=1883, secure=false, clientID="openHAB2" ]
{
    Thing topic Jeevs "Garage" @ "Door" {
    Channels:
        Type switch : switch     "RearDoor"                [ stateTopic="stat/rearGarageDoorSensorSW/POWER2", commandTopic="cmnd/rearGarageDoorSensorSW/POWER2" ]
        Type contact : contact     "RearDoorC"             [ stateTopic="cmnd/rearGarageDoorSensor/POWER2", transformationPattern="MAP:Jeevs.map" ]
    }
}

ITEMS

Contact Rear_Garage_Door_Sensor "Garage Door Sensor [%s]" (House, Rear_Garage) { channel="mqtt:topic:mosquitto:Jeevs:contact" }

MAP: (called Jeevs.map)

ON=OPEN
OFF=CLOSED

SITEMAP:

sitemap Jeevs label="Jeevs"
{
Default item= Rear_Garage_Door_Sensor label="Jeevs"
}

I’m a little sorry it took so long - I definitely learned a lot. I got a chance to read through like 50 more forum topics, read the documentation on MQTT again, read the blog post about MQTT 2.4 by @David_Graeff again, play with node red (for my dummy item)…

Whew, that was much more fun than doing nothing for the last 2 hours of my work day. Enjoy!

Thank you so much @crxporter! You are an absolute legend!

That worked like a treat - thank you so much, really happy right now :smiley:

Your solution will most definitley help others too!! :smiley:

p.s I’m a mr :wink:

I’m glad to help! Eventually I’ll need to figure this stuff out anyway for my house, it’s good for me to practice by tackling other people’s questions.

I just barely got it figured out, too… I had a whole post all put together about everything I’d tried that didn’t work - then I realized my pi didn’t have the Maps transformation service installed :expressionless:

I’m still not sure why the ON=“OPEN”, OFF=“CLOSED” didn’t work, does anyone know? Is that for outgoing transformations while the map is needed for incoming?

1 Like

Honestly, sincere thank you! You have been key in getting this sorted, so thank you :slight_smile:

I can understand your fustrations with the transformation service, easy mistake to make and obvious only once you realise lol

Agreed, not sure why the ON=“OPEN”, OFF=“CLOSED” didn’t work…would be great to hear thoughts from others…Could well be what you say, maps for incoming and the other for outgoing…

should be

on="OPEN", off="CLOSED"

mind the lower case…

1 Like

Thank you @Udo_Hartmann. I will give this a go and report back.

I am really confused, my binding seems to install, but I cannot get any commands to be received. My things looks like -
Thing mqtt topic Laundry Room “laundry” @ “light” {
Channels:
Type switch : switch “laundry_room_light” [
stateTopic=“laundry_room_light/STAT/”,
commandTopic=“laundry_room_light/cmnd/POWER/”,
//retained=false,
//postCommand="",
//transformationPattern=“JSONPATH:$.POWER”,
//formatBeforePublish="%s",
ON=“ON”,
OFF=“OFF”
]
where my item is -
Switch laundry_room_light “Laundry Room” (FF_LaundryRoom, gLight) { channel=“mqtt:topic:laundry_room_light:switch” }

Does this formatting look good? I am having troubles understanding where the “laundry” @ “light” is derived from. can someone point me in the right direction?

thanks,
cmo

Does this formatting look good?

No. :slight_smile:

Thing mqtt topic Laundry Room "laundry" @ "light" {
    Channels:
        Type switch : switch "laundry_room_light" [
            stateTopic="laundry_room_light/STAT/",
            commandTopic="laundry_room_light/cmnd/POWER/",
            //retained=false,
            //postCommand="",
            //transformationPattern="JSONPATH:$.POWER",
            //formatBeforePublish="%s",
            ON="ON",
            OFF="OFF"
        ]

Yet the first line is faulty :slight_smile:
You must not repeat the key word mqtt in the thing definition, beside that a Thing has a name, and the name must not contain spaces. So

Thing topic Laundry_Room "laundry" @ "light" {

would suffice.
In question of the channel definition, as you are using a switch, there is no need for parameters other than stateTopic and commandTopic. The whole thing would be:

Thing topic Laundry_Room "laundry" @ "light" {
    Channels:
        Type switch : switch "laundry room light" [
            stateTopic="laundry_room_light/STAT/",
            commandTopic="laundry_room_light/cmnd/POWER/"
        ]
}

But the bridge is missing, so please be aware that you have to configure a bridge for the Thing.

Are you sure the topics are correct? I’m using Tasmota, and the topics would be more like laundry_room_light/stat/POWER and laundry_room_light/cmnd/POWER (given, you defined full topic as %topic%/%prefix%/)

By the way: the “laundry” @ “light” part:

If the channel is linked to an item (you did not link the correct channel name either :wink: ), the Thing would appear in Paper UI control at the LIGHT tab and with the Name laundry

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