However, I get a warning, and the switch does not work.
2022-11-08 22:48:53.192 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '1' from channel 'mqtt:topic:mosquitto:modbus_spp:solar_hybrid_control_8' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.1
profiles operate on links. That’s to say, on the link between channel and Item.
Your error message comes from the channel, which being a switch type channel, is trying to convert the MQTT payload into standard ON/OFF long before the update gets to the profile,
If you wanted to do it this for an experiment or something, use a string type MQTT channel so that it doesn’t care what the payload is.
The more conventional approach is to use the “mini-mapping” built in the MQTT channel for on= and off= arguments, and not use a profile at all.
Or failing that use the transformation feature built into the MQTT channel to use your MAP, again not using a profile at all.
Get rid of the MAP transformation pattern. Get rid of the profile on the link.
Just make it a Switch Channel and fill in the Custom On/Open Value and the Custom Off/Closed Value parameters.
It’ll look like this in the code tab.
- id: garagedoor1_opener
channelTypeUID: mqtt:switch
label: Large garage door opener
description: ""
configuration:
commandTopic: sensor_reporter/cerberos/garagedoor1/cmd
off: OFF
on: ON
I also had to look it up to see if an inline map like @Max_G tried to use was supported.
I know that the JavaScript transform supports inline liker that now but I can’t find anything that says MAP does. I just wanted to point that out for future readers of this thread. As of this writing MAP:0=OFF,1=ON won’t work (unless this is something added but not yet documented.
You can use the MAP transform there. But you have to supply the name of the file in the transform folder. You can’t define the map inline like that. It has to be in the file.
So it’d be MAP:onoff.map to apply the map transform using the onoff.map file.
I went with the previous solution.
I wasn’t clear the transform works for both in and outgoing messages.
(And it was late at night; getting lost around that time is not uncommon )
Also apologise for claiming:
I meant to say: I got there based on other posts which specified …
As always: thank you for your reasoned posts, which help understanding the ‘why’.