Mike Xydas
Mike Xydas

Reputation: 489

How to issue command to Orion

I have a camera and I want to send it a command to take a snapshot. My setup is Orion <--> iotagent-json <--> mosquitto <--> device.

However, when I try to issue a command the iotagent does not receive anything.

The request I used for provisioning the device (to the agent):

curl -X POST \
  http://localhost1:4041/iot/devices \
  -H 'Content-Type: application/json' \
  -H 'fiware-service: actuatoriot' \
  -H 'fiware-servicepath: /' \
  -d '{
 "devices": [
   {
     "device_id":   "actuatorCamera002",
     "entity_name": "urn:ngsi-ld:ActuatorCamera:002",
     "entity_type": "Actuator",
     "protocol":    "PDI-IoTA-UltraLight",
     "transport":   "MQTT",
     "timezone":    "Europe/Berlin",
     "commands": [
       { "object_id": "screen", "name": "Screen", "type": "command"}
     ]
   }
 ]
}'

The device created on Agent:

{  
   "device_id":"actuatorCamera002",
   "service":"actuatoriot",
   "service_path":"/",
   "entity_name":"urn:ngsi-ld:ActuatorCamera:002",
   "entity_type":"Actuator",
   "transport":"MQTT",
   "attributes":[  

   ],
   "lazy":[  

   ],
   "commands":[  
      {  
         "object_id":"screen",
         "name":"Screen",
         "type":"command"
      }
   ],
   "static_attributes":[  

   ],
   "protocol":"PDI-IoTA-UltraLight"
}

The entity created on Orion:

{
    "id": "urn:ngsi-ld:ActuatorCamera:002",
    "type": "Actuator",
    "Screen_info": {
        "type": "commandResult",
        "value": "aaa",
        "metadata": {}
    },
    "Screen_status": {
        "type": "commandStatus",
        "value": "UNKNOWN",
        "metadata": {}
    },
    "TimeInstant": {
        "type": "ISO8601",
        "value": " ",
        "metadata": {}
    }
}

I have tried sending PATCH requests on the entity values but nothing seems to be getting pushed to the iotagent-json.

(I have been using the iotagent and Orion for sensor measurements and everything works fine.)

EDIT:

GET v2/registrations

[
    {
        "id": "5d3af2188d657958a5cefec1",
        "expires": "2019-08-25T12:29:12.00Z",
        "dataProvided": {
            "entities": [
                {
                    "id": "urn:ngsi-ld:ActuatorCamera:002",
                    "type": "Actuator"
                }
            ],
            "attrs": [
                "Screen"
            ]
        },
        "provider": {
            "http": {
                "url": "http://localhost:4041"
            },
            "supportedForwardingMode": "all",
            "legacyForwarding": true
        },
        "status": "active"
    }
]

Upvotes: 1

Views: 129

Answers (1)

Mike Xydas
Mike Xydas

Reputation: 489

Thanks to fgalan's comment I was able to find out I was using a wrong command name when issuing the PATCH.

The correct request for issuing a command was:

curl -X PATCH \
  http://<contextBrokerIp>:1026/v2/entities/urn:ngsi-ld:ActuatorCamera:002/attrs \
  -H 'fiware-service: actuatoriot' \
  -H 'fiware-servicepath: /' \
  -d '{
  "Screen": {
      "type" : "command",
      "value" : ""
  }
}'

Upvotes: 1

Related Questions