SCALE transform syntax in .things file

  • Platform information:
    • Hardware: x64/8 GB/512 GB
    • OS: Ubuntu 22.04.5 LTS
    • Java Runtime Environment: Debian 17.0.12
    • openHAB version: 4.2.1 (official Docker version)
  • Issue of the topic: How to chain transformations in .things; especially SCALE transformation

So I have this thing (.things) configuration for my battery operated Shelly devices:

Thing mqtt:topic:shellyhtg3-543204563724 "shellyhtg3-543204563724" (mqtt:broker:mosquitto) {
    Channels:
    Type number : wifi_rssid    "RSSID"                 [ stateTopic="shellyhtg3-543204563724/status/wifi", transformationPattern="JSONPATH:$.rssi"]
}

This perfectly delivers the rssi of the wifi signal, e.g. “-67”.
The OH Shelly-binding however gives positive integer values like e.g. “2” for wireless signal strength which is nicely rendered in the UI when using the <qualityofservice> icon.

So, I stumbled upon the SCALE transformation which looked that it can transform the signal strength dB-values to those numbers known from the Shelly binding.

I now have a db.scale file:

]-55..]=4
]-65..-55]=3
]-75..-65]=2
[..-75]=1

I got it to transform my mqtt-thing values in the .items config:

Number                  HT302_WifiSignalMQTT            "SignalstÀrke"                  <qualityofservice>  (EG, GR_Kitchen)            {channel="mqtt:topic:shellyhtg3-543204563724:wifi_rssid" [profile="transform:SCALE", function="db.scale"]}

However, I thought that using the ∩ (intersection) symbol, I could somehow chain the JSONPATH and SCALE transformation already in the thing instead of the display state in the item as I am doing now.
Unfortunately, the following doesn’t work:

Type number : wifi_rssid    "RSSID"                 [ stateTopic="shellyhtg3-543204563724/status/wifi", transformationPattern="JSONPATH:$.rss∩SCALE(db.scale):%s"]

The documentation on the MQTT things shows a similar combination of transformation in the last example (above the “Limitations” section), but I can’t figure out, how the syntax for SCALE would be or if SCALE is supported in the thing transformation at all.

Any help is appreciated.

Best regards

Marco

Please try

Type number : wifi_rssid    "RSSID"                 [ stateTopic="shellyhtg3-543204563724/status/wifi", transformationPattern="JSONPATH:$.rss∩SCALE:db.scale"]

Hi @Udo_Hartmann,
thanks, that was the solution. I’m still struggling with slightly different syntaxes that are being used in various places.

Best regards
Marco

1 Like