我正在嘗試創建訂閱,以通知我關於某些傳感器值的更改。FIWARE Orion:訂閱的服務路徑
curl broker.waziup.io/v2/subscriptions -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service:watersense' --header 'Fiware-ServicePath:/#' -d @- <<EOF
{
"description": "Send XXX when YYY",
"subject": {
"entities": [
{
"id": "WS_UPPA_Sensor2",
"type": "SensingDevice"
}
],
"condition": {
"attrs": [
"SM1"
],
"expression": {
"q": "SM1>400"
}
}
},
"notification": {
"httpCustom": {
"url": "https://api.plivo.com/v1/Account/MAMDA5ZDJIMDM1NZVMZD/Message/",
"headers": {
"Content-type": "application/json",
"Authorization": "Basic XXX"
},
"method": "POST",
"payload": "{ %22src%22: %2200393806412092%22, %22dst%22: %2200393806412093%22, %22text%22: %22WaterSense: Field is too dry. \${id} humidity value is \${SM1} %22}"
},
"attrs": [
"SM1"
]
},
"expires": "2040-05-24T20:00:00.000Z",
"throttling": 1
}
EOF
第一個問題,ServicePath在訂閱中有什麼用處? 它似乎在檢索與該訂閱相關的實體時使用。所以/#
是有效的。這是否正確(我沒有在文檔中找到它)?
其次,假設你想創建一個基於幾個實體屬性值的訂閱。如果這些實體屬性具有相同的名稱(通常是這種情況),那麼您如何引用它們?你可以這樣做:有效載荷類似
"q": "Sensor1.SM1>100, Sensor2.SM1>100"
而且什麼東西?
我已經回答了第一個問題。對於第二個問題,我需要一點澄清。你的意思是* *不同*實體中的*相同*名稱的屬性?那是對的嗎?謝謝! – fgalan
我認爲他可以使用'idPattern'之類的東西,就像這個鏈接所說的:'https:// stackoverflow.com/questions/43230064/fiware-orion-subscribe-to-all-entities'。或者,也許只需將所有感興趣的實體放入訂閱結構中的「id」字段即可。 @fgalan,做這件事的正確方法是什麼,在訂閱結構中指定許多實體ID? – Dalton
@fgalan是在不同實體中具有相同名稱的屬性。 – cdupont