SoftwareAG / cumulocity-dynamic-mapper

The ultimate Mapper for building the bridge between any Message Broker and Cumulocity IoT in a zero-code approach!
Apache License 2.0
9 stars 9 forks source link

Mapping for Measurement Value not working #15

Closed anonymosh closed 1 year ago

anonymosh commented 1 year ago

Hi all,

I tried the mapper with some custom Measurement mapping, but it looks like all mappings to the c8y_TemperatureMeasurement.T.value become null - although the value can be found on the incoming MQTT message (see log below for an example) I tried to hardcode the value in the mapping definition instead of making a dynamic mapping and had the same result. I would assume the path c8y_TemperaturMeasurement.T.value can be found, otherwise it would stay at its initial value (110) (?)

I also tried to rule out any interfering rules on the type, by exchanging the fragment name and measurement type, but the result is always the same.

The mapping does work when I test it with the example message.

Thanks, Mario Heidenreich

2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Message received on topic '/moneo/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest'  with message [
{
"tid":"5e4bac9f-b47a-499e-8601-68fc16a9847c",
"psid":"Crest",
"devicePath":"c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
"processDataUnit":"",
"values":[
{
"value":4.6,
"timestamp":1648562285347
}
]
}
]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/moneo/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'moneo/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest' in [moneo]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest' in [c2818e07-4c09-42f0-ba24-ddb712573ab5]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/AL1352/192168221/80/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'AL1352/192168221/80/X03/VVB001StatusB/Crest' in [AL1352]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/192168221/80/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '192168221/80/X03/VVB001StatusB/Crest' in [192168221]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/80/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '80/X03/VVB001StatusB/Crest' in [80]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/X03/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'X03/VVB001StatusB/Crest' in [X03]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/VVB001StatusB/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'VVB001StatusB/Crest' in [VVB001StatusB]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: '/Crest' in [/]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.InnerNode             : Trying to resolve: 'Crest' in [Crest]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.model.MappingNode           : Resolved mapping: Mapping(id=1, subscriptionTopic=/moneo/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest, templateTopic=/moneo/c2818e07-4c09-42f0-ba24-ddb712573ab5/AL1352/192168221/80/X03/VVB001StatusB/Crest, indexDeviceIdentifierInTemplateTopic=-1, targetAPI=MEASUREMENT, active=true, tested=true, qos=AT_LEAST_ONCE, substitutions=[MappingSubstitution(pathSource=$now(), pathTarget=time, definesIdentifier=false), MappingSubstitution(pathSource=**.value, pathTarget=c8y_TemperatureMeasurement.T.value, definesIdentifier=false), MappingSubstitution(pathSource="k", pathTarget=c8y_TemperatureMeasurement.T.unit, definesIdentifier=false), MappingSubstitution(pathSource="moneo_device1", pathTarget=source.id, definesIdentifier=true)], mapDeviceIdentifier=false, createNonExistingDevice=false, updateExistingDevice=false, externalIdType=c8y_Serial, snoopStatus=STOPPED, lastUpdate=1666282647656), tp.size(): 0
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Patched payload:false, [ {
  "tid" : "5e4bac9f-b47a-499e-8601-68fc16a9847c",
  "psid" : "Crest",
  "devicePath" : "c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
  "processDataUnit" : "",
  "values" : [ {
    "value" : 4.6,
    "timestamp" : 1648562285347
  } ]
} ]
2022-10-20 16:18:07.211  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Patched sub.pathSource: $now(), $now()
2022-10-20 16:18:07.212  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Evaluated substitution (pathSource, substitute): ($now(),"2022-10-20T16:18:07.212Z"), (pathTarget): (time), [ {
  "tid" : "5e4bac9f-b47a-499e-8601-68fc16a9847c",
  "psid" : "Crest",
  "devicePath" : "c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
  "processDataUnit" : "",
  "values" : [ {
    "value" : 4.6,
    "timestamp" : 1648562285347
  } ]
} ], {"c8y_TemperatureMeasurement":{"T":{"unit":"C","value":110}},"time":"2022-08-05T00:14:49.389+02:00","source":{"id":"909090"},"type":"c8y_TemperatureMeasurement"}
2022-10-20 16:18:07.212  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Patched sub.pathSource: **.value, **.value
2022-10-20 16:18:07.212  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Evaluated substitution (pathSource, substitute): (**.value,4.6), (pathTarget): (c8y_TemperatureMeasurement.T.value), [ {
  "tid" : "5e4bac9f-b47a-499e-8601-68fc16a9847c",
  "psid" : "Crest",
  "devicePath" : "c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
  "processDataUnit" : "",
  "values" : [ {
    "value" : 4.6,
    "timestamp" : 1648562285347
  } ]
} ], {"c8y_TemperatureMeasurement":{"T":{"unit":"C","value":110}},"time":"2022-08-05T00:14:49.389+02:00","source":{"id":"909090"},"type":"c8y_TemperatureMeasurement"}
2022-10-20 16:18:07.213  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Patched sub.pathSource: "k", "k"
2022-10-20 16:18:07.213  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Evaluated substitution (pathSource, substitute): ("k","k"), (pathTarget): (c8y_TemperatureMeasurement.T.unit), [ {
  "tid" : "5e4bac9f-b47a-499e-8601-68fc16a9847c",
  "psid" : "Crest",
  "devicePath" : "c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
  "processDataUnit" : "",
  "values" : [ {
    "value" : 4.6,
    "timestamp" : 1648562285347
  } ]
} ], {"c8y_TemperatureMeasurement":{"T":{"unit":"C","value":110}},"time":"2022-08-05T00:14:49.389+02:00","source":{"id":"909090"},"type":"c8y_TemperatureMeasurement"}
2022-10-20 16:18:07.213  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Patched sub.pathSource: "moneo_device1", "moneo_device1"
2022-10-20 16:18:07.213  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Evaluated substitution (pathSource, substitute): ("moneo_device1","moneo_device1"), (pathTarget): (source.id), [ {
  "tid" : "5e4bac9f-b47a-499e-8601-68fc16a9847c",
  "psid" : "Crest",
  "devicePath" : "c2818e07-4c09-42f0-ba24-ddb712573ab5_AL1352_192168221_80_X03_VVB001StatusB_Crest",
  "processDataUnit" : "",
  "values" : [ {
    "value" : 4.6,
    "timestamp" : 1648562285347
  } ]
} ], {"c8y_TemperatureMeasurement":{"T":{"unit":"C","value":110}},"time":"2022-08-05T00:14:49.389+02:00","source":{"id":"909090"},"type":"c8y_TemperatureMeasurement"}
2022-10-20 16:18:07.263  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.processor.PayloadProcessor  : Found id 3690875 for external id: moneo_device1
2022-10-20 16:18:07.333  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] mqtt.mapping.core.C8yAgent               : New measurement posted: {"self":"http://t161291189.eu-latest.cumulocity.com/measurement/measurements/3691186","time":"2022-10-20T16:18:07.212Z","id":"3691186","source":{"self":"http://t161291189.eu-latest.cumulocity.com/inventory/managedObjects/3690875","id":"3690875"},"type":"c8y_TemperatureMeasurement","c8y_TemperatureMeasurement":{"T":{"unit":"k","value":null}}}
2022-10-20 16:18:07.333  INFO 13 --- [MQTT Call: cumulocity-mqtt-test_d1] m.mapping.processor.impl.JSONProcessor   : Added payload for sending: {"c8y_TemperatureMeasurement":{"T":{"unit":"k"}},"time":"2022-10-20T16:18:07.212Z","source":{"id":"3690875"},"type":"c8y_TemperatureMeasurement"}, MEASUREMENT, numberDevices: 1
sagIoTPower commented 1 year ago

Hi Mario, I identified the bug and fixed this in the latest commit. We will release a new version shortly.

Regards Christof

switschel commented 1 year ago

@sagIoTPower I think this is fixed already and this issue can be closed?