Hi all,
i was wondering if it is possible to get a number value to the item extracted by the JSONPath transform service in the ItemChannelLink Profile. See details below.
As of now i only get a string, which cannot be displayed in diagrams etc…
-
Platform information:
- Hardware: Synology DS1513+
- OS: DSM6
- Java Runtime Environment: 8 (I think)
- openHAB version: 2.4
-
Issue of the topic:
Channel is configured as string, to receive:
{“Time”:“2019-06-27T09:26:34”,“AM2301”:{“Temperature”:23.2,“Humidity”:87.3},“TempUnit”:“C”}
I configured the ItemChannelLink to extract Time, Temperature and Humidity from this JSON Sting, which works like a charm. But now my issue: The Item gets the values as string and cannot convert them to numbers, so they can be stored correctly.
I also tried to add ‘:%.3f’ to the function, which also does not work.
ItemLinkConfig:
"MarkusLivingroomNodeMCUT1Temperature -\u003e mqtt:topic:85dcec01:NodeMCUT1_Sensor": {
"class": "org.eclipse.smarthome.core.thing.link.ItemChannelLink",
"value": {
"channelUID": {
"segments": [
"mqtt",
"topic",
"85dcec01",
"NodeMCUT1_Sensor"
]
},
"configuration": {
"properties": {
"profile": "transform:JSONPATH",
"function": "$.AM2301.Temperature",
"sourceFormat": "%.3f"
}
},
"itemName": "MarkusLivingroomNodeMCUT1Temperature"
}
},
ItemConfig:
"MarkusLivingroomNodeMCUT1Temperature": {
"class": "org.eclipse.smarthome.core.items.ManagedItemProvider$PersistedItem",
"value": {
"groupNames": [
"LivingRoom",
"MarkusLivingRoomNodeMCUT1"
],
"itemType": "Number:Temperature",
"tags": [],
"label": "Markus - LivingRoom - NodeMCUT1 - Temperature",
"category": "Temperature"
}
},
Channel Config:
{
"acceptedItemType": "String",
"kind": "STATE",
"uid": {
"segments": [
"mqtt",
"topic",
"85dcec01",
"NodeMCUT1_Sensor"
]
},
"channelTypeUID": {
"segments": [
"mqtt",
"string"
]
},
"label": "NodeMCUT1 Sensor",
"configuration": {
"properties": {
"postCommand": false,
"retained": false,
"formatBeforePublish": "%s",
"commandTopic": "",
"allowedStates": "",
"stateTopic": "/kristenhome/markus/livingroom/NodeMCUT1/tele/SENSOR",
"transformationPattern": ""
}
},
"properties": {},
"defaultTags": []
},
Error Message:
2019-06-27 10:32:30.908 [WARN ] [ofiles.JSonPathTransformationProfile] - Could not transform state '{"Time":"2019-06-27T09:26:34","AM2301":{"Temperature":23.2,"Humidity":87.3},"TempUnit":"C"}' with function '$.AM2301.Temperature' and format '%.3f'