Search code examples
watson-iot

Watson IoT: Is it possible to create physical/logical interface for multiple sensors on one device?


I have successfully created a physical interface and logical interface that work if I send simple readings like {"Temperature": value } but I am wondering if there is a way to send something like this in case my device has several sensors:

       {"Sensordata":[
              {"voltage":"3.8"},
              {"temperature":"22.9"},
              {"humidity":"55.2"}
                                  ]}

I can create the physical interface to receive the array, but cant figure out if there is a way to break that array and send it to different logical interfaces.

Anyone knows if this is possible or have any resources on this?


Solution

  • Yes, this is possible. You will need to define separate Mappings... one for each Logical Interface. The property mappings for the event will need to pull out the relevant item from the array contained in the event. An example of the property mappings to extract the voltage would be as follows:

    {
        "logicalInterfaceId": "123456789012345678901234",
        "notificationStrategy": "on-state-change",
        "propertyMappings": {
            "myEvt": {
                "voltage": "$event.Sensordata[0]"
            }
        },
        "version": "draft",
        "created": "2018-06-15T12:19:22Z",
        "createdBy": "a-abcdef-1234567890",
        "updated": "2018-06-15T12:19:22Z",
        "updatedBy": "a-abcdef-1234567890"
    }
    

    Please let me know if you have any further questions.

    Thanks.