Fiware 使用IDAS和ContextBroker在服务中创建实体

Fiware 使用IDAS和ContextBroker在服务中创建实体,fiware,fiware-orion,Fiware,Fiware Orion,所以我觉得这是因为Fiware的服务。我不想使用OpenIoT(即使这对我也不起作用)。我没有找到任何关于服务创建的文档,可能是我创建错了 我做了Python CreateService bus_auto 4jggogkgpepnvsb2uv4s40d59ov,我不确定它是否返回我201。我更新了config.ini文件以在我的服务上工作,但是当我发送观察结果时,它不会更改contextBroker上实体的值 我现在正在运行它 我的config.ini文件: [user] # Please, c

所以我觉得这是因为Fiware的服务。我不想使用OpenIoT(即使这对我也不起作用)。我没有找到任何关于服务创建的文档,可能是我创建错了

我做了
Python CreateService bus_auto 4jggogkgpepnvsb2uv4s40d59ov
,我不确定它是否返回我201。我更新了config.ini文件以在我的服务上工作,但是当我发送观察结果时,它不会更改contextBroker上实体的值

我现在正在运行它

我的config.ini文件:

[user]
# Please, configure here your username at FIWARE Cloud and a valid Oauth2.0 TOKEN for your user (you can use get_token.py to obtain a valid TOKEN).
username=
token=NULL

[contextbroker]
host=127.0.0.1
port=1026
OAuth=no
# Here you need to specify the ContextBroker database you are querying.
# Leave it blank if you want the general database or the IDAS service if you are looking for IoT devices connected by you.
fiware_service=bus_auto

[idas]
host=130.206.80.40
adminport=5371
ul20port=5371
OAuth=no
# Here you need to configure the IDAS service your devices will be sending data to.
# By default the OpenIoT service is provided.
fiware-service=bus_auto
fiware-service-path=/
apikey=4jggokgpepnvsb2uv4s40d59ov

[local]
#Choose here your System type. Examples: RaspberryPI, MACOSX, Linux, ...
host_type=CentOS
# Here please add a unique identifier for you. Suggestion: the 3 lower hexa bytes of your Ethernet MAC. E.g. 79:ed:af
# Also you may use your e-mail address.
host_id=db:00:ff
我正在使用python脚本GetEntity.py:

python2.7 GetEntity.py bus_auto_2 
我还尝试使用我创建的python脚本:

import json
import urllib
import urllib2

BASE_URL = 'http://127.0.0.1:1026'
QUERY_URL = BASE_URL+'/v1/queryContext'

HEADERS = {
    'Content-Type': 'application/json',
    'Accept': 'application/json'
}

QUERY_EXAMPLE = {
    "entities": [
        {
            "type": "bus_auto_2",
            "isPattern": "false",
            "id": "Room1"
        }
    ]
}


def post(url, data):
    """"""
    req = urllib2.Request(url, data, HEADERS)
    f = urllib2.urlopen(req)
    result = json.loads(f.read())
    f.close()
    return result

if __name__ == "__main__":
    print post(UPDATE_URL, json.dumps(UPDATE_EXAMPLE))
    print post(QUERY_URL, json.dumps(QUERY_EXAMPLE))

我看到服务创建得很好,实际上我看到其中定义了一个设备

我甚至成功地发送了一个观测(t | 23)总线自动2装置

稍后,我在ContextBroker中签入这个实体:“thing:bus_auto_2”,我看到了我发送的最新观察结果

您是否在config.ini文件中更新了ContextBroker和IDAS部分的FIWARE_服务


干杯,

看看您的脚本,您的queryContext请求中似乎没有包含Fiware服务头。因此,查询在“默认服务”中解析,而不是在总线自动服务中解析

通过以下方式更改HEADERS映射可能会解决此问题:

HEADERS = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Fiware-Service: 'bus_auto' 
}
编辑:除上述更改外,请注意,基本URL指向本地Orion实例,而不是与IDAS(与IDAS在同一台机器上运行)连接的实例。因此,我认为您还需要通过以下方式修改BASE_URL:

BASE_URL = 'http://130.206.80.40:1026'

您是否可以编辑您的问题,以包含用于在ContextBroker检查实体的命令或机制?谢谢答案经过编辑:)感谢您的回复,但您可以通过我编辑的答案检查服务是否写得很好:)嗨,迭戈,我已经尝试过:>python SendObservation.py bus_auto_2'p | 1'1>python GetEntity.py thing:bus_auto_2我认为您查询的实体不对。迭戈,在config.ini文件中,上下文代理的IP地址应该是130.206.80.40,而不是127.0.0.1。你能用这个配置试试python GetEntity.py吗?bus_auto_2?嗨,Diego,在幻灯片5中,你有办法创建一个指向ContextBroker的IDAS服务。您可以将此作为一个问题添加到FIGWAY github中,我将在即将到来的Sprint中重新编写脚本以支持它;-)迭戈,我刚刚在修改了“CreateService.py”脚本。现在,在创建IDAS服务时,您可以选择为ContextBroker的私有实例添加IP和端口。干杯并感谢您使用IDAS!我更新了脚本,添加了新的标题,但仍然不起作用。我注册了另一个名为“autocarro”的虚拟设备,并模拟了一次观察。查询它给我的contextBroker:404找不到上下文元素。可能还需要调整BASE_URL。请看我最后一次编辑的答案帖子。