Uploaded image for project: 'Help-Desk'
  1. Help-Desk
  2. HELP-16127

[fiware-stackoverflow] Sending commands to devices in FIWARE Orion is not working

    Details

      Description

      Created question in FIWARE Q/A platform on 29-08-2019 at 15:08
      Please, ANSWER this question AT https://stackoverflow.com/questions/57711025/sending-commands-to-devices-in-fiware-orion-is-not-working

      Question:
      Sending commands to devices in FIWARE Orion is not working

      Description:
      I am trying to provide a device on FIWARE and send commands. In my case, a lamp with commands ("on" and "off"). But, it's not working.
      The steps to create a device and send command are:

      Provide a device;
      Create a service group;
      Create a registration with commands;
      Send a command.

      I'm taking the fiware-tutorials following the steps, but don't work.

      The code I have used was:

      To create a device:

      curl -iX POST \
      'http://localhost:4041/iot/devices' \
      -H 'Content-Type: application/json' \
      -H 'fiware-service: openiot' \
      -H 'fiware-servicepath: /' \
      -d '{
      "devices": [
      {
      "device_id": "lamp1",
      "entity_name": "urn:ngsi-ld:Lamp:1",
      "entity_type": "Lamp",
      "protocol": "PDI-IoTA-UltraLight",
      "transport": "HTTP",
      "endpoint": "http://iot-sensors:3001/iot/lamp1",
      "commands": [

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

      ,

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

      ],
      "attributes": [

      {"object_id": "s", "name": "state", "type":"Text"}

      ,

      {"object_id": "l", "name": "luminosity", "type":"Integer"}

      ],
      "static_attributes": [

      {"name":"refStore", "type": "Relationship","value": "urn:ngsi-ld:Store:001"}

      ]
      }
      ]
      }
      '

      To create a service group:

      curl -iX POST \
      'http://localhost:4041/iot/services' \
      -H 'Content-Type: application/json' \
      -H 'fiware-service: openiot' \
      -H 'fiware-servicepath: /' \
      -d '{
      "services": [

      { "apikey": "4jggokgpepnvsb2uv4s40d59ov", "cbroker": "http://orion:1026", "entity_type": "Thing", "resource": "/iot/d" }

      ]
      }'

      To create a registration for commands:

      curl -iX POST \
      'http://localhost:1026/v2/registrations' \
      -H 'Content-Type: application/json' \
      -H 'fiware-service: openiot' \
      -H 'fiware-servicepath: /' \
      -d '{
      "description": "Lamp Commands",
      "dataProvided": {
      "entities": [

      { "id": "urn:ngsi-ld:Lamp:1","type": "Lamp" }

      ],
      "attrs": [ "on", "off" ]
      },
      "provider": {
      "http":

      {"url": "http://orion:1026/v2"}

      ,
      "legacyForwarding": true
      }
      }'

      To send a "on" command:

      curl -iX PATCH \
      'http://localhost:1026/v2/entities/urn:ngsi-ld:Lamp:1/attrs' \
      -H 'Content-Type: application/json' \
      -H 'fiware-service: openiot' \
      -H 'fiware-servicepath: /' \
      -d '{
      "on":

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

      }'

      Doing a HTTP get request to retrieve the entity:

      curl -G -X GET \
      'http://localhost:1026/v2/entities/urn:ngsi-ld:Lamp:1' \
      -d 'type=Lamp' \
      -d 'options=keyValues' \
      -H 'fiware-service: openiot' \
      -H 'fiware-servicepath: /'

      I expect a output like:

      { "id": "urn:ngsi-ld:Lamp:001", "type": "Lamp", "TimeInstant": "2019-08-28T13:33:51.00Z", "luminosity": "1115", "off_info": " ", "off_status": "UNKNOWN", "on_info": " on OK", "on_status": "OK", "refStore": "urn:ngsi-ld:Store:001", "state": "ON", "on": "", "off": "" }

      but I receive this:

      { "id": "urn:ngsi-ld:Lamp:1", "type": "Lamp", "TimeInstant": "2019-08-28T12:50:22.00Z", "luminosity": " ", "off_info": " ", "off_status": "UNKNOWN", "on_info": "There was an error in the response of a device to a command [404]: on NOT OK", "on_status": "ERROR", "refStore": "urn:ngsi-ld:Store:001", "state": " ", "on": "", "off": "" }

        Activity

        Hide
        backlogmanager Backlog Manager added a comment -

        2019-09-02 11:42|CREATED monitor | # answers= 0, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2019-09-02 11:42|CREATED monitor | # answers= 0, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2019-09-23 18:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False

        Show
        backlogmanager Backlog Manager added a comment - 2019-09-23 18:05|UPDATED status: transition Answered| # answers= 1, accepted answer= False
        Hide
        backlogmanager Backlog Manager added a comment -

        2020-11-11 12:52|UPDATED status: transition Finish| # answers= 1, accepted answer= True

        Show
        backlogmanager Backlog Manager added a comment - 2020-11-11 12:52|UPDATED status: transition Finish| # answers= 1, accepted answer= True

          People

          • Assignee:
            fermin Fermín Galán
            Reporter:
            backlogmanager Backlog Manager
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: