Details
-
Type: Monitor
-
Status: Closed
-
Priority: Major
-
Resolution: Done
-
Affects Version/s: None
-
Fix Version/s: 2021
-
Component/s: FIWARE-TECH-HELP
-
Labels:
-
HD-Enabler:Orion
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": "off","type": "command"} ],
"attributes": [
,
{"object_id": "l", "name": "luminosity", "type":"Integer"} ],
"static_attributes": [
]
}
]
}
'
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": [
]
}'
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": [
],
"attrs": [ "on", "off" ]
},
"provider": {
"http":
,
"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":
}'
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
Field | Original Value | New Value |
---|---|---|
Component/s | FIWARE-TECH-HELP [ 10278 ] |
Assignee | Fermín Galán [ fermin ] |
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": "" } |
Status | Open [ 1 ] | In Progress [ 3 ] |
Status | In Progress [ 3 ] | Answered [ 10104 ] |
Resolution | Done [ 10000 ] | |
Status | Answered [ 10104 ] | Closed [ 6 ] |
Fix Version/s | 2021 [ 12600 ] |