MQTT Read-only

  • Platform information:
  • Hardware: RPI 4, 4GB
  • OS: Ubuntu 20.04.2 LTS
  • Java Runtime Environment: openjdk 11.0.10 2021-01-19
  • openHAB version: openHAB 3.0.1 (release build)
  • Issue of the topic:

I have power consumption data of my home being published to MQTT

  • {“time”: 1619174609.8827522, “datetime”: “2021-04-23 10:43:29”, “printable_key”: “Current Consumption”, “key”: “consumption_now”, “value”: “3.588”, “consumption_now”: 3.588, “printable_value”: “3.588 kW”, “unit”: “kW”, “printable_string”: “Current Consumption: 3.588 kW”, “normalized_value”: “3.588 kW”, “normalized_string”: “Current Consumption: 3.588 kW”}

The JSON content is published under topic:

home/power/consumption/total/consumption

The channel on my Generic MQTT Thing looks like this (snippet from “Code”-view)

  • id: cCurrentconsumption
    channelTypeUID: mqtt:string
    label: Current Consumption
    description: “”
    configuration:
    stateTopic: home/power/consumption/total/consumption
    transformationPattern: JSONPATH:$.value

I created an item, just showing the channel value as a string

Result: I see the complete JSON message, no filtering on JSONPATH:$.value

What am I doing wrong?

I’ve tried your JSON string with https://jsonpath.com/ and it worked.
Except that I had to replace all of the quotation marks(") since the ones in your post are “ and ” instead of "

I don’t believe that you get a JSON with the strange marks but that’s the only thing I can see by the given data

JSONPATH is an installable add-on.

As mentioned you’ll need the JSONPATH Transformation Service installed. See step 6.1 for a how-to.