1

My configuration includes orion, IoT Agent JSON, and mongoDB. I want to build a Fiware Lamp actuator and I want to have is on/off status (as sensor) as well.

At the moment I use a PATCH request with body (form ORION) : At First with on command:

{
  "on": {
      "type" : "command",
      "value" : ""
  }
}

And then with off command:

{
  "off": {
      "type" : "command",
      "value" : ""
  }
}

When I receive anything from the above, I respond from the dummy device with 200 OK.

The above in my configuration makes both the on and off tags as pending:

{
    "id": "urn:ngsi-ld:Lamp:001",
    "type": "Lamp",
    "TimeInstant": "2020-11-04T22:42:37.00Z",
    "category": [
        "actuator",
        "sensor"
    ],
    "controlledProperty": "lamp",
    "function": [
        "onOff",
        "sensing"
    ],
    "off_info": " ",
    "off_status": "PENDING",
    "on_info": " ",
    "on_status": "PENDING",
    "refStore": "urn:ngsi-ld:Store:001",
    "state": " ",
    "supportedProtocol": [
        "JSON"
    ],
    "supportedUnits": "My Unit 2",
    "on": "",
    "off": ""
}

I guess that I miss something in the way, so is there any response that I have to sent back to IoT Agent json to to make one of the two tags to stop be pending? Must I Update State or Info along the way?

P.S I expected to have a reply like this:

{
    "id": "urn:ngsi-ld:Lamp:001",
    "type": "Lamp",
    "TimeInstant": "2020-11-04T22:42:37.00Z",
    "category": [
        "actuator",
        "sensor"
    ],
    "controlledProperty": "lamp",
    "function": [
        "onOff",
        "sensing"
    ],
    "off_info": " ",
    "off_status": "PENDING",
    "on_info": " ",
    "on_status": "OFF",
    "refStore": "urn:ngsi-ld:Store:001",
    "state": " ",
    "supportedProtocol": [
        "JSON"
    ],
    "supportedUnits": "My Unit 2",
    "on": "",
    "off": ""
}
ssavva05
  • 114
  • 3
  • 14

1 Answers1

2

The flow of a command can be seen below:

enter image description here

Assuming your command has reached the lamp and it has turned on, the result needs to be passed back into the IoT Agent. For the JSON IoT Agent, the payload looks something like this:

{"on" : "OK"}

Where the key is the name of the command, and the value is the status. My guess is that your device is just responding 200 OK without a payload, so the IoT Agent doesn't know which command has fired.

Note that in the case of a distributed network (e.g. MQTT or AMPQ) the response will be posted asynchronously on another topic so the command may be left in a PENDING state for some time.

Dalton Cézane
  • 3,672
  • 2
  • 35
  • 60
Jason Fox
  • 5,115
  • 1
  • 15
  • 34
  • Great Explanation! I didn't add payload in my response previously and that was the cause to have the Pending status for ever. Is there any link that contains the IoT Agent JSON acceptable payloads? – ssavva05 Nov 05 '20 at 09:55
  • 1
    The documentation can be found [here](https://fiware-iotagent-json.readthedocs.io/) - I couldn't find anything about command result payloads though. – Jason Fox Nov 05 '20 at 11:21