I asked a similar question a couple of weeks ago - I believe you can do the transformation in the channel definition like this. Then you don’t need the .map file reference in your .items if I understand correctly.
Try it out and let me know - otherwise I’m sure someone else will be around to correct us!
Edit - here is my question from a few weeks ago - in case you notice something else useful:
Edit 2:
Just saw that your transform is opposite of what I put. I am now thinking you may need to change the second channel to a “contact” instead of a “switch” and do the opposite transformation - perhaps this is close:
Type contact : contact “Contact” [ commandTopic=“cmnd/rearGarageDoorSensor/POWER2”, OPEN=“ON”, CLOSED=“OFF” ]
Please be aware that all the quotes are of wrong type, because the first posting used quoting instead of code fences. The thing definition should be without colons.
The channel is wrong either, the bridge is missing (mqtt:topic:oh:rearGarageDoor:contact instead of mqtt:topic:rearGarageDoor:contact)
One question, in the thing definition should the type be switch, contact, or can either work? His commands coming from the sonoff are ON and OFF, I would have thought that the contact “thing” would be:
Type contact : contact "Contact" [ commandTopic="cmnd/rearGarageDoorSensor/POWER2", OPEN="ON", CLOSED="ON" ]
Edit again - Do you need to have the contact be a stateTopic instead of a commandTopic channel? ( clearly I might not be the best helper here, hopefully I can learn something as well and not get others too confused. )
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.
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
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!
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
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?
Honestly, sincere thank you! You have been key in getting this sorted, so thank you
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…
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?
Yet the first line is faulty
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:
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 ), the Thing would appear in Paper UI control at the LIGHT tab and with the Name laundry