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

        fla Fernando Lopez made changes -
        Fix Version/s 2021 [ 12600 ]
        backlogmanager Backlog Manager made changes -
        Resolution Done [ 10000 ]
        Status Answered [ 10104 ] Closed [ 6 ]
        backlogmanager Backlog Manager made changes -
        Status In Progress [ 3 ] Answered [ 10104 ]
        fla Fernando Lopez made changes -
        Status Open [ 1 ] In Progress [ 3 ]
        fla Fernando Lopez made changes -
        HD-Enabler Orion [ 10875 ]
        Description
        Created question in FIWARE Q/A platform on 29-08-2019 at 15:08
        {color: red}Please, ANSWER this question AT{color} 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": ""
        }

        Created question in FIWARE Q/A platform on 29-08-2019 at 15:08
        {color: red}Please, ANSWER this question AT{color} 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": ""
        }

        fla Fernando Lopez made changes -
        Assignee Fermín Galán [ fermin ]
        backlogmanager Backlog Manager made changes -
        Field Original Value New Value
        Component/s FIWARE-TECH-HELP [ 10278 ]
        backlogmanager Backlog Manager created issue -

          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: