Warning about missing transformation despite json transformation pattern

  • Platform information:
    • OS: _what OS is used and which version: x86 64bit ubuntu
    • openHAB version: docker container of openhab/openhab:3.3.0"

Hi,

I am using openhab to read in some mqtt messages from zigbee2mqtt. For example I receive json strings like this from a zigbee switch.

{"action":"on","battery":74,"last_seen":"2023-12-20T19:37:53+01:00","linkquality":114,"update":{"state":"available"}}

To link this data to an item, I created a generic mqtt thing within the openhab GUI and specified the “Incoming Value Transformations” to “JSONPATH:$.action” and set the “Custom On/Open Value” to “on” in one of the “thing”-channels.

This works fine, but I still get a warning inside of the openhab.log file which sais:

2023-12-20 19:37:53.100 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'on' from channel 'mqtt:topic:mosquitto:sw_02:state' not supported by type 'OnOffValue': No enum constant org.openhab.core.library.types.OnOffType.on.

I found a post regarding this topic (here) and the solution seems to be to add a dedicated transformation from ‘on’ to ‘ON’.

So basically I have two questions:

  1. How can I link a custom transformation created within my myTransformation.map file to my GUI ‘thing’? In the mentioned post it was done within the items file itself.
  2. Why is this necessary? Whats the point of the GUI settings “Custom On/Open Value” if I need a mapping anyway? And why does it work despite the warning?

Many thanks in advance.

Case matters. ON is not the same as on.

You don’t need a transformation for this, though that is an option. The MQTT switch Channel has an onValue and offValue property. Set the former to on and the latter to off and the binding will translate the lower case to the upper case for you automatically.

If you want to chain a MAP transform to the JSONPATH you could do that too as an option.

When you look at the description for the the “Incoming value transformation” and “Outgoing value transformation” it says:

Applies transformations to an incoming MQTT topic value. A transformation example for a received JSON would be “JSONPATH:$.device.status.temperature” for a json {device: {status: { temperature: 23.2 }}}. You can chain transformations by separating them with the intersection character ∩.

So you would chain a MAP transform to the JSONPATH using that intersection character. Then the JSONPATH will go first and the result of that will be passed through the MAP transform.

Since you don’t show your MQTT config :person_shrugging: If it is configured correctly it should work.