iotblackbelt / node-red-contrib-azure-iot-device

Azure IoT Device node for Node-Red
MIT License
21 stars 18 forks source link

Sending telemetry with properties, wrong format? #29

Closed hixfield closed 2 years ago

hixfield commented 2 years ago

If I look at https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-messages-construct#application-properties-of-d2c-iot-hub-messages it indicates to send properties under a sub-object messageProperties

If I look at the manual here -> https://github.com/iotblackbelt/node-red-contrib-azure-iot-device/blob/master/USE.md#input-telemetry and also look in the node js code (as the code code still send them differently then the input message), I believe its sending them under "properties".

I think the module is wrongfully using "properties" and it should be messageProperties?

sandervandevelde commented 2 years ago

Hello @hixfield ,

the node is making use of the Node.JS SDK for Azure IoT. For an example on how a message is constructed, see this example (this example also sends a user properties name 'temperatureAlert').

The format you see here is a high-level description of the message as ingested in the IoT Hub. This is not the actual format sent by the device. The device typically only sends the 'telemetry' part. The rest is a construction showing iot hub data.

The format used by the node has a specific structure so the internal node logic can make the right mapping. So 'properties' end up in 'messageProperties'.

I recommend playing around with this MS Learn module so you get a feeling about the Device-to-cloud communication.

iotblackbelt commented 2 years ago

Closed based on response given by @sandervandevelde.