Я использую IoT-агент для ультралегкого и я хотел бы отправить команду (включая определенное значение) обратно на мое IoT-устройство. Если я последую примеру умной двери здесь , я могу отправить что-то вроде:
curl -iX PATCH \
'http://localhost:1026/v2/entities/urn:ngsi-ld:pysense:002/attrs' \
-H 'Content-Type: application/json' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-d '{
"color": {
"type" : "command",
"value" : "100"
}
}'
Fiware публикует полезную нагрузку "urn: ngsi-ld: pysense: 002 @ color |" моему mqtt-брокеру. Но я ожидаю, что будет также передано значение «100»?
Я также нашел эту документацию по Git, касающуюся mqtt-команд. Но тот не указывает, куда и как отправить? Я предполагаю, что он использует тот же URL, что и этот запрос: http://localhost:4041/v1/updateContext
?? Это современный способ выдачи команд?
Я использую Orion-ld и iotagent-ul: 1.8.0.
Может ли кто-нибудь помочь мне также ввести значение "color" в mqtt-сообщение?
Спасибо!
EDIT1:
Я только что попробовал orion: 2.2.0 и перерегистрировал команду следующим образом:
{
"description": "Setting LED",
"dataProvided": {
"entities": [
{
"id": "urn:ngsi-ld:pysense:002", "type": "pysense"
}
],
"attrs": ["color", "brightness"]
},
"provider": {
"http": {"url": "http://orion:1026/v2"},
"legacyForwarding": true
}
}
Если я пытаюсь отправить команду, orion-logs сходят с ума (продолжайте прокручивать) со следующим текстом:
fiware-orion | INFO@06:42:33 logMsg.h[1844]: Starting transaction from 172.18.1.1:35800/v2/entities/urn:ngsi-ld:pysense:002/attrs
fiware-orion | INFO@06:42:33 rest.cpp[885]: Service Path 0: '/dresden'
fiware-orion | INFO@06:42:33 connectionOperations.cpp[239]: Database Operation Successful (count: { _id.id: "urn:ngsi-ld:pysense:002", _id.servicePath: { $in: [ /^/dresden$/ ] } })
fiware-orion | INFO@06:42:33 connectionOperations.cpp[94]: Database Operation Successful (query: { _id.id: "urn:ngsi-ld:pysense:002", _id.servicePath: { $in: [ /^/dresden$/ ] } })
fiware-orion | INFO@06:42:33 connectionOperations.cpp[94]: Database Operation Successful (query: { $or: [ { entities.id: "urn:ngsi-ld:pysense:002", $or: [ { entities.type: "pysense" }, { entities.type: { $exists: false } } ], entities.isPattern: "false", entities.isTypePattern: { $ne: true }, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] } }, { entities.isPattern: "true", entities.isTypePattern: { $ne: true }, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... }, { entities.isPattern: "false", entities.isTypePattern: true, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... }, { entities.isPattern: "true", entities.isTypePattern: true, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... } ] })
fiware-orion | INFO@06:42:33 connectionOperations.cpp[177]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "urn:ngsi-ld:pysense:002", type: "pysense" }, { type: "pysense", id: "urn:ngsi-ld:pysense:002" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1559716953 }, contextRegistration.attrs.name: { $in: [ "color" ] }, servicePath: { $in: [ /^/dresden$/ ] } }, orderby: { _id: 1 } })
fiware-orion | ERROR@06:42:33 postUpdateContext.cpp[553]: Internal Error (attribute 'color' not found)
fiware-orion | INFO@06:42:33 logMsg.h[1844]: Starting transaction to http://orion:1026/v1/updateContext
fiware-orion | INFO@06:42:33 httpRequestSend.cpp[592]: Sending message 8 to HTTP server: sending message of 433 bytes to HTTP server
fiware-orion | INFO@06:42:33 logMsg.h[1844]: Starting transaction from 172.18.1.7:46738/v1/updateContext
fiware-orion | INFO@06:42:33 rest.cpp[885]: Service Path 0: '/dresden'
fiware-orion | INFO@06:42:33 connectionOperations.cpp[94]: Database Operation Successful (query: { _id.id: "urn:ngsi-ld:pysense:002", _id.type: "pysense", _id.servicePath: { $in: [ /^/dresden$/ ] } })
fiware-orion | INFO@06:42:34 connectionOperations.cpp[94]: Database Operation Successful (query: { $or: [ { entities.id: "urn:ngsi-ld:pysense:002", $or: [ { entities.type: "pysense" }, { entities.type: { $exists: false } } ], entities.isPattern: "false", entities.isTypePattern: { $ne: true }, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] } }, { entities.isPattern: "true", entities.isTypePattern: { $ne: true }, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... }, { entities.isPattern: "false", entities.isTypePattern: true, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... }, { entities.isPattern: "true", entities.isTypePattern: true, expiration: { $gt: 1559716953 }, status: { $ne: "inactive" }, servicePath: { $in: [ /^$|^/#$|^/dresden/#$|^/dresden$/, null ] }, $where: function(){for (var i=0; i < this.entities.length; i++) {if (this.enti... } ] })
fiware-orion | INFO@06:42:34 connectionOperations.cpp[177]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "urn:ngsi-ld:pysense:002", type: "pysense" }, { type: "pysense", id: "urn:ngsi-ld:pysense:002" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1559716954 }, contextRegistration.attrs.name: { $in: [ "color" ] }, servicePath: { $in: [ /^/dresden$/ ] } }, orderby: { _id: 1 } })
fiware-orion | INFO@06:42:34 logMsg.h[1844]: Starting transaction to http://orion:1026/v1/updateContext
...
И я получаю следующую ошибку в качестве почтальона:
{
"error": "NotFound",
"description": "The requested entity has not been found. Check type and id"
}
Когда orion регистрирует команду самостоятельно, это выглядит следующим образом с iot-agent в качестве поставщика вместо orion / v1:
{
"id": "5cf677b7c7ecc4737e1e0ec9",
"expires": "2020-06-04T13:52:55.00Z",
"dataProvided": {
"entities": [
{
"id": "urn:ngsi-ld:pysense:002",
"type": "pysense"
}
],
"attrs": [
"color",
"brightness"
]
},
"provider": {
"http": {
"url": "http://iot-agent:4041"
},
"supportedForwardingMode": "all",
"legacyForwarding": true
},
"status": "active"
}
С этим я действительно могу отправить команду, но она по-прежнему пропускает значение. :(
EDIT2:
Что-то, что я нашел в обширном журнале отладки orion:
fiware-orion | INFO@07:35:09 connectionOperations.cpp[177]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "urn:ngsi-ld:pysense:002", type: "pysense" }, { type: "pysense", id: "urn:ngsi-ld:pysense:002" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1559720109 }, contextRegistration.attrs.name: { $in: [ "color" ] }, servicePath: { $in: [ /^/dresden$/ ] } }, orderby: { _id: 1 } })
fiware-orion | ERROR@07:35:09 postUpdateContext.cpp[553]: Internal Error (attribute 'color' not found)
После этого IoT-Agent обновляет контекст, но без значения.