Json timstamp pattern (MQTT data source)
-
Hi
I'm trying to setup MQTT data source to recive time-stamped value. My Json example is as follows:
{
"post":[20191223131022, 10]
}Where 20191223131022 is the timestamp and 10 is the value.
I've setup my DS as follows:
However I'm not getting the value, though I'm not getting any error message either.
When I change subscription topic type from Jason with Timestamp to Jason (no other changes made) I receive the data (timestamped to time when recived) so the issue seems to be only that it does not get the timestamp pattern or timestamp in Json right.
Thankful for assistance to get the timestamp issue right.
-
@nathanRona your JSON format doesn't seem right. I'm not 100% sure how to handle arrays but if you can change the format to this it will work:
{ "post": { "0": "20191223131022", "1": 10 } }
I would suggest this as it makes more sense:
{ "post": { "date": "20191223131022", "value": 10 } }
and then set your JSON pointer for value to
/post/value
and the time pointer topost/date
. -
Changed is at described but still same result, i.e. if I set type to Jason with Timestamp I don't get any values and if I set to Jason I get the value.
Btw the array handling that I used is according to example give in help for MQTT ds
In addition I would like if possible to get multiple samples in single MQTT message (with diffrent time-stamps). Is that possible? How should JSON be formatted?
-
@nathanRona I just did a quick test against test.mosquitto.org and was able to publish and receive JSON with Timestamp based values. I'm posting the JSON config so you can import it and see for yourself. I can't see exactly what is wrong with your setup but this confirms that it does in fact work. In the configuration I'm providing there are 2 data points, when you set the value for one it will publish to the receiving topic of the other.
{ "dataSources":[ { "xid":"DS_b911d1a5-dcfd-424d-ab07-77134185f2a8", "name":"Test.Mosquitto.ORG Client", "enabled":true, "type":"MqttClient", "alarmLevels":{ "DATA_SOURCE_EXCEPTION_EVENT":"URGENT", "MQTT_CONNECTION_FAILURE_EVENT":"URGENT", "MQTT_PUBLISH_FAILURE_EVENT":"URGENT", "POINT_READ_EXCEPTION_EVENT":"URGENT", "MQTT_UNKNOWN_TOPIC":"IGNORE", "POINT_WRITE_EXCEPTION_EVENT":"URGENT" }, "purgeType":"YEARS", "brokerUri":"tcp:\/\/test.mosquitto.org:1883", "x509CaCrt":"", "clientId":"Mango Automation MQTT Client 148709547341099", "userName":"", "userPassword":"", "topicFilters":"infiniteautomation\/test\/#", "autoReconnect":true, "cleanSession":true, "keepAliveInterval":60, "connectionTimeout":30, "qosType":"EXACTLY_ONCE", "editPermission":"", "purgeOverride":false, "purgePeriod":1 } ], "dataPoints":[ { "xid":"DP_ba31c77f-9c4f-4f02-802c-afcfae830441", "name":"number", "enabled":true, "loggingType":"ALL", "intervalLoggingPeriodType":"MINUTES", "intervalLoggingType":"AVERAGE", "purgeType":"YEARS", "pointLocator":{ "dataType":"NUMERIC", "subscribeTopicType":"JSON_WITH_TIMESTAMP", "subscribeJsonTimestampPath":"\/ts", "subscribeJsonTimestampPattern":"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX", "subscribeJsonValuePath":"\/d", "subscribeTopic":"infiniteautomation\/test\/number", "publishTopicType":"JSON_WITH_TIMESTAMP", "publishJsonTimestampName":"ts", "publishJsonTimestampPattern":"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX", "publishJsonTimestampZone":"UTC", "publishJsonValueName":"d", "publishTopic":"infiniteautomation\/test\/set\/number" }, "eventDetectors":[ ], "plotType":"STEP", "rollup":"NONE", "unit":"s", "simplifyType":"NONE", "chartColour":"", "chartRenderer":{ "type":"IMAGE", "timePeriodType":"DAYS", "numberOfPeriods":1 }, "dataSourceXid":"DS_b911d1a5-dcfd-424d-ab07-77134185f2a8", "defaultCacheSize":1, "deviceName":"Test.Mosquitto.ORG Client", "discardExtremeValues":false, "discardHighLimit":1.7976931348623157E308, "discardLowLimit":-1.7976931348623157E308, "intervalLoggingPeriod":1, "intervalLoggingSampleWindowSize":0, "overrideIntervalLoggingSamples":false, "preventSetExtremeValues":false, "purgeOverride":false, "purgePeriod":1, "readPermission":"", "setExtremeHighLimit":1.7976931348623157E308, "setExtremeLowLimit":-1.7976931348623157E308, "setPermission":"", "tags":{ }, "textRenderer":{ "type":"ANALOG", "useUnitAsSuffix":true, "format":"0.00" }, "tolerance":0.0 }, { "xid":"DP_0460c207-8a22-4b7c-92b6-ab70c1c41d1c", "name":"number-recieve", "enabled":true, "loggingType":"ALL", "intervalLoggingPeriodType":"MINUTES", "intervalLoggingType":"INSTANT", "purgeType":"YEARS", "pointLocator":{ "dataType":"NUMERIC", "subscribeTopicType":"JSON_WITH_TIMESTAMP", "subscribeJsonTimestampPath":"\/ts", "subscribeJsonTimestampPattern":"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX", "subscribeJsonValuePath":"\/d", "subscribeTopic":"infiniteautomation\/test\/set\/number", "publishTopicType":"JSON_WITH_TIMESTAMP", "publishJsonTimestampName":"ts", "publishJsonTimestampPattern":"yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSSX", "publishJsonTimestampZone":"UTC", "publishJsonValueName":"d", "publishTopic":"infiniteautomation\/test\/number" }, "eventDetectors":[ ], "plotType":"STEP", "rollup":"NONE", "unit":"s", "simplifyType":"NONE", "chartColour":"", "chartRenderer":{ "type":"IMAGE", "timePeriodType":"DAYS", "numberOfPeriods":1 }, "dataSourceXid":"DS_b911d1a5-dcfd-424d-ab07-77134185f2a8", "defaultCacheSize":1, "deviceName":"Test.Mosquitto.ORG Client", "discardExtremeValues":false, "discardHighLimit":1.7976931348623157E308, "discardLowLimit":-1.7976931348623157E308, "intervalLoggingPeriod":15, "intervalLoggingSampleWindowSize":0, "overrideIntervalLoggingSamples":false, "preventSetExtremeValues":false, "purgeOverride":false, "purgePeriod":1, "readPermission":"", "setExtremeHighLimit":1.7976931348623157E308, "setExtremeLowLimit":-1.7976931348623157E308, "setPermission":"", "tags":{ }, "textRenderer":{ "type":"ANALOG", "useUnitAsSuffix":true, "format":"0.00" }, "tolerance":0.0 } ] }