[SOLVED] Get Number from mqtt message

  • Platform information:
    Raspberry Pi 3B+
    OH 2.5.5 on openhabian
    mosquitto as external broker
    mqtt v2 binding

What I did so far:

  1. Established connection of my tablet running Fully Kiosk Browser to mosquitto.
  2. Created a generic MQTT Thing for the tablet
  3. Created multiple channels, which mostly work.

one working example channel for the ScreenState - mqtt:topic:Xido_FKB:Screen (Switch):
Topic: fully/deviceInfo/788ff136-aa884889
Custom On/Open Value: true / false
Incoming Value Transformations:
JSONPATH:$.screenOn

The item
Switch Xido_Scr "Xido Screen" (G_jdbc,G_All_OFF) {channel="mqtt:topic:Xido_FKB:Screen"}

The same thing does not work for a number item (and Number channel), when extracting the battery state:
Topic: fully/deviceInfo/788ff136-aa884889
Incoming Value Transformations:
JSONPATH:$.batteryState

EDIT:
The mqtt message for deviceInfo is:
{"deviceId":"788ff136-aa884889","batteryLevel":79,"isPlugged":true,"SSID":"\"xxx\"","Mac":"6c:c0:1c:79:01:8e","ip4":"192.168.68.40","host":"android-999.fritz.box","screenOrientation":0,"screenBrightness":180,"screenLocked":true,"screenOn":false,"foreground":"de.ozerov.fully","locale":"de_DE","serial":"87241c67d97700000000","version":"1.39.2","versionCode":712,"build":"astar_h7-userdebug 5.1.1 LMY47V 20170711 test-keys","model":"X111","manufacturer":"Allwinner","androidVersion":"5.1.1","SDK":22,"webviewUA":"Mozilla\/5.0 (Linux; Android 5.1.1; X111 Build\/LMY47V) AppleWebKit\/537.36 (KHTML, like Gecko) Version\/4.0 Chrome\/39.0.0.0 Safari\/537.36","motionDetectorStatus":2,"isDeviceOwner":false,"internalStorageFreeSpace":9504325632,"internalStorageTotalSpace":13070655488,"ramFreeMemory":499933184,"ramTotalMemory":1051566080,"appFreeMemory":70142388,"appTotalMemory":83886080,"topFragmentTag":"","appStartTime":"27.05.2020 6:31:12 vorm.","isRooted":false,"isLicensed":true,"isInForcedSleep":false,"maintenanceMode":false,"kioskMode":true,"inDaydream":false,"currentPageUrl":"http:\/\/192.168.68.28:8080\/static\/habpanel\/index.html#\/view\/Home"}

EDIT II:
The logs show ok (from my POV):
2020-05-27 14:41:07.748 [TRACE] [.MqttChannelStateDescriptionProvider] - Providing state description for channel mqtt:topic:Xido_FKB:Battery

There does not appear to be a batteryState key in your JSON payload?
Should it be batteryLevel ?

You are right - in the channel I used batteryLevel, but wrote this from my memory.
Obviously a mistake :wink:

It actually looks like the tablet stopped updating the batteryLevel…
Everything else is reported properly.
Even unplugging and restarting the tablet did not help.

For now, I would considered it to be solved.

Thanks for your quick response.

EDIT:
Root Cause confirmed.
After tablet was completely powerer down, it came up again with the batteryLevel information