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": "" }
2019-09-02 11:42|CREATED monitor | # answers= 0, accepted answer= False