So far we have established the following on our attempt to connect a webhook capable gateway (we developed a gateway that has a web app that allow for an easy webhook connectivity) with losant:
- We create an application in losant
- We created a device in the application
- We added an an attribute to each data point we wanted to track
- A Webhook Trigger was issued, copied and pasted within our gateway as the URL to send the HTTP post request to.
- We are not clear on how to set the Device State Node in order to pull values off of the payload and how to report them as state for the attribute we added on the losant device. We followed the instruction you have in your documentation but suspect this can resolve the issue we have (please instruct in detail with respect to the payload described below).
To verify our gateway is attempting to send HTTP request we changed (on our gateway) its endpoint (trigger URL) from the endpoint (HOST URL) losant generated :
https://triggers.losant.com/webhooks/xxxxxxxxxxxxxxxxxxxxxxxxxxxx$
To a pipedream requestBin (traffic inspector) endpoint(HOST URL) generated.
On the pipedream traffic inspector we found our gateway send HTTP requests and they are received as HTTP post requests. Below you can see the headers and Raw body of the request.
Headers:
host: xxxxxxxxxx.x.pipedream.net
accept: application/json
Content-Type: application/json
Content-Length: 831
Connection: keep-alive
Raw Body:
{
“deviceId”: “xxxxxxx_xxx”,
“data”: {
“500”: {
“analog-input:1”: {
“present-value”: [
{
“value”: 26.399999618530273,
“timestamp”: 1553543607126
}
]
},
“analog-input:5”: {
“present-value”: [
{
“value”: 50,
“timestamp”: 1553543607126
}
]
},
“analog-input:4”: {
“present-value”: [
{
“value”: 1.0998377799987793,
“timestamp”: 1553543607126
}
]
},
“analog-input:8”: {
“present-value”: [
{
“value”: 0.00244140625,
“timestamp”: 1553543607126
}
]
},
“analog-input:3”: {
“present-value”: [
{
“value”: 21.5,
“timestamp”: 1553543607126
}
]
},
“analog-input:6”: {
“present-value”: [
{
“value”: 873,
“timestamp”: 1553543607126
}
]
},
“analog-input:7”: {
“present-value”: [
{
“value”: 0.004999999888241291,
“timestamp”: 1553543607126
}
]
},
“analog-input:2”: {
“present-value”: [
{
“value”: 79.5199966430664,
“timestamp”: 1553543607126
}
]
},
“analog-input:9”: {
“present-value”: [
{
“value”: 0,
“timestamp”: 1553543607126
}
]
}
}
},
“type”: “liveData”
}
Once we changed the gateway endpoint (HOST URL) back to the one losant generated for us we were not able to verify the header or raw body on your platform. With the following workflow configuration: Webhook–>Webhook Reply–>Debug we were able to see the above json in the losant debug window.
Questions: In losant workflow we want to set the Webhook Reply and the Device State.
- How should the Webhook Reply be set in order to enable the gateway to be read, so far we set the response code template at 200. Should the body reply, reply headers be filled?
- How should the Device State Value per each attribute be set with respect to the above json response from the HTTP post request?
- Please confirm the unknow connection status of the device is an MQTT connection indicator only that has not been resolved yet.
- As you can see the time response in the json above is in UNIX EPOCH how can it be handled in Losant?
- If the immediate goal is to have the attributes from our Gateway displayed in the dashboard will the following workflow be sufficient?:
Webhook (Trigger)–>Webhook Reply (Output)–>Debug (Output) -->Device State (Output)
Please note we tried the following explanations with respect to the above questions with no viable resolutions:
https://docs.losant.com/workflows/outputs/webhook-reply/
https://docs.losant.com/devices/state/
Thank you