Convert switch from Mqtt binding 1.x to 2.5

Hi,
I need help for this: I convert my working Mqtt 1.14.0 binding in 2.5 version, for most of items it work fine, but for one item i have trouble.
In 1.14.0 version
xxx.items was

Switch EtatProjo “Etat de projecteur " (Gr_Piscine) {autoupdate=“false”, mqtt=”>[mosquitto:/Piscine/CmdProjo:command:ON:ON],>[mosquitto:/Piscine/CmdProjo:command:OFF:ON],<[mosquitto:/Piscine/Projo:state:ON:M],<[mosquitto:/Piscine/Projo:state:OFF:A]"}

The hardware behind is a bistable relais command by “ON” patern and the return information is “A” or “M” (Marche or Arret)

In 2.5 version, I create
xxx.things
Bridge mqtt:broker:mosquitto “Mosquitto” [ host=“192.168.1.210”, secure=false, clientID=“openHabBkup_Piscine”]
{
Thing topic piscine “Mqtt Iot Piscine Controle” @ “PiscineCtrl”
{
Channels:

Type switch : Projecteur “Projecteur” [ stateTopic="/Piscine/Projo", commandTopic="/Piscine/CmdProjo", off=“ON”, on=“ON”]

}
}

xxx.items

Switch EtatProjo "Etat de projecteur " (Gr_Piscine) {autoupdate=“false”, channel=“mqtt:topic:mosquitto:piscine:Projecteur”}

Result:
error message:
2020-01-14 09:13:36.034 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command ‘A’ not supported by type ‘OnOffValue’:
No enum constant org.eclipse.smarthome.core.library.types.OnOffType.A

For command, it’s OK, for return information how to convert “A” or “M” in OFF or ON ?

I also try to use Paper UI for thin items, but i do not see where i convert “A” or “M” to OFF or ON

Thank for your answer

First of all here is the doc

The MQTT 2.X binding works with things and channels so no more

{autoupdate=“false”, mqtt=”>[mosquitto:/Piscine/CmdProjo:command:ON:ON],>[mosquitto:/Piscine/CmdProjo:command:OFF:ON],<[mosquitto:/Piscine/Projo:state:ON:M],<[mosquitto:/Piscine/Projo:state:OFF:A]"}

I know people will hate me for suggesting this but, I find configuration of MQTT Things via PaperUI better.
Please have mercy with me. :grimacing:

This is in your command topic definition. You need to set:

off="A", on="M"

But i have alredy off=“ON”, on=“ON” for commandTopic
I add this to the things for try, but same error and same result.

You need to introduce transformationPattern to channel configuration which will convert A to OFF and M to ON. see details from mqtt binding documentation. MAP transformation is most probably easiest for this.

Yes i see “Incoming Value Transformation” chapter in documentation, but for me an example is missing.
Can you give me the syntax for on-off.map where on-off.map contain A=OFF B=ON

Did you add to or did you modify your previous on/off definition?

I add to, if i modify previous value the probleme is not solved and the commandTopic do not work !!!

That will never work!
How should openHAB decide which of the contradicting on/off definitions it should use?

Any logs about what happened?

It was working fine with binding version 1.14.0 and i was thinking there are at least the same fonctionality in the new Mqtt binding version.

I never wrote that, please read carefully. The part i quoted is important.

If you add a second contradicting on/off definition, it will newer work!

You have to use a single on/off definition.

See the doc’s for an example.

To all, i solve this probleme after many retry:

xxx.things

Type switch : Projecteur “Projecteur” [ stateTopic="/Piscine/Projo", commandTopic="/Piscine/CmdProjo", transformationPattern=“MAP:inTransform.map”, transformationPatternOut=“MAP:outTransform.map”]

inTransform.map
A=OFF
M=ON

outTransform.map
1=ON
0=ON

It work well but i d’nt know why in ouTransform i must write 1=ON & 0= ON and not on=ON & off=ON, but it work

Tanks to all

:+1: MAP was what you needed.

Guessing that 1 or 0 is what is expected from the device.

Please click the square box on post that provided the solution to mark topic as solved.

Thanks