无法在 IoT Agent Fiware 中配置执行器

问题描述

我正在使用以下 python 代码创建服务组

import json
import requests

url = 'http://localhost:4041/iot/services'
headers = {'Content-Type': "application/json",'fiware-service': "openiot",'fiware-servicepath': "/mtp"}

data = {
 "services": [
   {
     "apikey":      "456dgffdg56465dfg","cbroker":     "http://orion:1026","entity_type": "Door",#resource attribute is left blank since HTTP communication is not being used
     "resource":    ""
   }
 ]
}
res = requests.post(url,json=data,headers=headers)
#print(res.status_code)

if res.status_code == 201:
    print("Created")

elif res.status_code == 409:
    print("A resource cannot be created because it already exists")

else:
    print (res.raise_for_status())

但是在尝试配置执行器时,我收到错误请求 400 错误,代码如下:

import json
import requests

url = 'http://localhost:4041/iot/devices'
headers = {'Content-Type': "application/json",'fiware-servicepath': "/mtp"}

data = {
 "devices": [
    {
      "device_id": "door003","entity_name": "urn:ngsi-ld:Door:door003","protocol": "PDI-IoTA-UltraLight","transport": "MQTT","commands": [
        {"name": "unlock","type": "command"},{"name": "open",{"name": "close",{"name": "lock","type": "command"}
       ],"attributes": [
        {"object_id": "s","name": "state","type":"Text"}
       ]
    }
  ]
}

res = requests.post(url,headers=headers)
#print(res.status_code)

if res.status_code == 201:
    print("Created")

elif res.status_code == 409:
    print("Entity cannot be created because it already exists")

else:
    print (res.raise_for_status())

这是我在控制台中收到的错误消息。

iot-agent            | time=2021-02-17T11:39:44.132Z | lvl=DEBUG | corr=16f27639-49c2-4419-a926-2433805dbdb3 | trans=16f27639-49c2-4419-a926-2433805dbdb3 | op=IoTAgentNGSI.GenericMiddlewares | from=n/a | srv=smartdoor | subsrv=/mtp | msg=Error [BAD_REQUEST] handling request: Request error connecting to the Context Broker: 501 | comp=IoTAgent
iot-agent            | time=2021-02-17T11:39:44.133Z | lvl=DEBUG | corr=390f5530-f537-4efa-980a-890a44153811 | trans=390f5530-f537-4efa-980a-890a44153811 | op=IoTAgentNGSI.DomainControl | from=n/a | srv=smartdoor | subsrv=/mtp | msg=response-time: 29 | comp=IoTAgent

奇怪的是,如果从有效负载中删除命令,则设备配置工作正常。尝试配置执行器(不是传感器)时我做错了什么?

物联网代理版本:

{"libVersion":"2.14.0-next","port":"4041","baseRoot":"/","version":"1.15.0-next"}

猎户座版本:

{
"orion" : {
  "version" : "2.2.0","uptime" : "0 d,0 h,59 m,18 s","git_hash" : "5a46a70de9e0b809cce1a1b7295027eea0aa757f","compile_time" : "Thu Feb 21 10:28:42 UTC 2019","compiled_by" : "root","compiled_in" : "442fc4d225cf","release_date" : "Thu Feb 21 10:28:42 UTC 2019","doc" : "https://fiware-orion.rtfd.io/en/2.2.0/"
}
}

我的 docker-compose 文件如下所示:

iot-agent:
    image: fiware/iotagent-ul:latest
    hostname: iot-agent
    container_name: iot-agent
    restart: unless-stopped
    depends_on:
        - mongo-db
    networks:
        - default
    expose:
        - "4041"
    ports:
        - "4041:4041"
    environment:
        - IOTA_CB_HOST=orion
        - IOTA_CB_PORT=1026
        - IOTA_NORTH_PORT=4041
        - IOTA_REGISTRY_TYPE=mongodb
        - IOTA_LOG_LEVEL=DEBUG
        - IOTA_TIMESTAMP=true
        - IOTA_CB_NGSI_VERSION=v2
        - IOTA_AUTOCAST=true
        - IOTA_MONGO_HOST=mongo-db
        - IOTA_MONGO_PORT=27017
        - IOTA_MONGO_DB=iotagentul
        - IOTA_PROVIDER_URL=http://iot-agent:4041
        - IOTA_MQTT_HOST=mosquitto
        - IOTA_MQTT_PORT=1883

提前致谢。

问候,

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...