Command 'true' not supported by type 'OnOffValue':

I’ve searched Openhab-community to understand how to convert an incoming true/false response to ON/OFF mapping but I haven’t found a simple example. I have a MQTT generic thing in OH3 for a switch that has two different topics for state and command as defined in a channel. For the state topic, the payload is simply ‘true’ or ‘false’. For the command topic, it is a ‘{“id”: 8, “isOn”: true}’ or ‘{“id”: 8, “isOn”: false}’ for a custom value on or off; respectively. It works when I turn on/off the switch but I get an error in the log file that “Command ‘true’ not supported by type ‘OnOffValue’: No enum constant org.openhab.core.library.types.OnOffType.true.” The state payload is not json so I wonder how I can use the incoming transformation to convert true to ON.

Command Topic Configuration

Payload from State Topic

Any suggestions will be helpful.

You can use any transformation service you like, not limited to JSONPATH.

I think I’d use MAP here. You can use the same MAP for in and out transforms. looking up the JSON for ON or OFF, and also looking up ON/OFF for true or false.

So I created a map file in the transform folder (/etc/openhab/transform/) that has two key value pairs and modified my channel as follows:

UID: mqtt:topic:d69bc8ed3f:LowSpeedNoHeat
label: Pump Low Speed
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:d69bc8ed3f
location: Outside
  - id: LowSpeedFeatureChannel
    channelTypeUID: mqtt:switch
    label: Low Speed Feature Channel
    description: ""
      commandTopic: virtual-controllerAlt/state/features/setState
      postCommand: true
      stateTopic: virtual-controllerAlt/state/features/8/isOn
      transformationPattern: truefalse:map
      off: '{"id": 8, "isOn": false}'
      on: '{"id": 8, "isOn": true}'

Yet, I get the following error when I save the thing channel.

Transformation service TRUEFALSE for pattern map not found!

This syntax is incorrect.

Should be something like:


But don’t you want this on the outgoing transformation? Your custom on/off values should probably be set to true/false, then in your map file you transform from true to {"id": 8, "isOn": true} and false to {"id": 8, "isOn": false}.

1 Like

Thank you, that worked. I reviewed the documentation but could not find sample syntax for entering a transformation map in a channel configuration; especially MAP. I’m using custom on/off values for the command topic because each switch has a different id number and that would require an outgoing transformation map for each switch.