iotagent-node-lib
iotagent-node-lib copied to clipboard
use of object_id for commands
Hey there,
"object_ids" and "name" are used as a translation layer between how things are called in field layer and in FIWARE, respectively.
That works well for attributes (measurement values coming from the field layer).
Nevertheless, this does not work for commands. When you register a device in the IoTA - let's say JSON - that has a command, this command get's posted as a registration in orion. This way, a PATCH on that command will trigger a request from orion to the IoTA.
In my case, all communication between FIWARE and the field layer is done via MQTT. So the IoTA forwards this command to the corresponding topic (which works fine) but the payload looks like
{"<attr_name>":
Thanks for clearing things up :)
If you provision a device with a command like this:
"commands":[
{
"name":"expression",
"type":"Number",
"expression":"'hi'"
}
And then, you send the command, you will obtain, as message payload (No matter what you put on expression command attribute)
"hi"
Note that you have the quotes. This can be change through the command option parameters payloadType
and contentType
More info for IOTA-JSON here
So, through the usage of an expression, you can define a custom payload simulating whatever you want, for example, the typical behaviour:
{"cmdName":{"paramName":"paramValue"}}