Commit 7dfc038b authored by Federico Sismondi's avatar Federico Sismondi

Changed() soilMoistureVwc -> soilMoisture. Update() serialize (cast) None type...

Changed() soilMoistureVwc -> soilMoisture. Update() serialize (cast) None type from python to Text type for ngsi as None type doesnt exist
parent 16211803
......@@ -64,7 +64,7 @@ We have `IoT sensor for humidity`, and `WMS for watering scheduling`, then we co
| | | |
| IoT Platform +<---------------+ WMS - Watering |
| | SUBSCRIBE | weekly scheduler |
+----------------------+ /FlowerBed/soilMoistureVwc |
+----------------------+ /FlowerBed/soilMoisture |
+-------------------+
......@@ -86,10 +86,10 @@ We have `IoT sensor for humidity`, and `WMS for watering scheduling`, then we co
| | | |
| IoT Platform +--------------->+ WMS - Watering |
| | POST | weekly scheduler |
+-----+----------------+ /FlowerBed/soilMoistureVwc |
+-----+----------------+ /FlowerBed/soilMoisture |
^ +-------------------+
UPDATE|
/FlowerBed/soilMoistureVwc
/FlowerBed/soilMoisture
|
+-----+----------------+
| |
......@@ -107,7 +107,7 @@ UPDATE|
| | | |
| IoT Platform +<-----------------------------------+ WMS - Watering |
| | GET | weekly scheduler |
+----------------------+ /FlowerBed/soilMoistureVwc?limit=100 |
+----------------------+ /FlowerBed/soilMoisture?limit=100 | |
+-------------------+
......
......@@ -35,7 +35,7 @@ def get_ngsiv2_typed_description(val):
elif isinstance(val, dict):
return {'type': 'StructuredValue', 'value': val}
elif isinstance(val, type(None)):
return {'type': 'None', 'value': None}
return {'type': 'Text', 'value': None}
else:
raise NotImplementedError("Couldn't get NGSIv2 type for object {} of type {}".format(val, type(val)))
......
......@@ -4,7 +4,7 @@
echo "Querying QuantumLeap API at: ${QUANTUM_HOST}"
curl --location --request GET \
"http://$QUANTUM_HOST:8668/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value?limit=100" \
"http://$QUANTUM_HOST:8668/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value?limit=100" \
--header "Fiware-Service: carouge" \
--header "Fiware-ServicePath: /" \
--header "Accept: application/json"
......
......@@ -6,5 +6,5 @@
echo "Querying Fiware entrypoint (PEP_PROXY) at: ${PROXY_HOST}"
curl -X GET \
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value"\
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value"\
--header "Fiware-Service: carouge"
......@@ -8,7 +8,7 @@ echo "Querying Fiware entrypoint (PEP_PROXY) at: ${PROXY_HOST}"
[[ -z "$KEYROCK_TOKEN" ]] && echo "Please set KEYROCK_TOKEN env var. E.g. export KEYROCK_TOKEN=****" && exit
curl -X GET \
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value"\
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value"\
--header "Fiware-Service: carouge" \
--header "X-Auth-Token: $KEYROCK_TOKEN"
......@@ -11,7 +11,7 @@ echo
echo
curl --location --request PUT \
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value"\
"http://$PROXY_HOST:1027/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value"\
--header "Fiware-Service: carouge" \
--header "X-Auth-Token: $KEYROCK_TOKEN" \
--header "Content-Type: text/plain" \
......
......@@ -8,7 +8,7 @@ echo "Querying Fiware entrypoint (PEP_PROXY) at: ${PROXY_HOST}"
[[ -z "$KEYROCK_TOKEN" ]] && echo "Please set KEYROCK_TOKEN env var. E.g. export KEYROCK_TOKEN=****" && exit
[[ -z "$SUBSCRIPTION_URL" ]] &&
echo "Please set SUBSCRIPTION_URL env var. E.g. export SUBSCRIPTION_URL=http://172.18.1.11:5000/on_change_soilMoistureVwc" &&
echo "Please set SUBSCRIPTION_URL env var. E.g. export SUBSCRIPTION_URL=http://172.18.1.11:5000/on_change_soilMoisture" &&
echo "You can check out the wms-example source code for a server implementation example." &&
exit
......@@ -21,7 +21,7 @@ curl --location --request POST \
--header "Accept: application/json" \
--header "X-Auth-Token: $KEYROCK_TOKEN" \
--data '{
"description": "A subscription to subscribe to FlowerBed.soilMoistureVwc",
"description": "A subscription to subscribe to FlowerBed.soilMoisture",
"subject": {
"entities": [
{
......@@ -31,7 +31,7 @@ curl --location --request POST \
],
"condition": {
"attrs": [
"soilMoistureVwc"
"soilMoisture"
]
}
},
......@@ -40,7 +40,7 @@ curl --location --request POST \
"url": "'${SUBSCRIPTION_URL}'"
},
"attrs": [
"soilMoistureVwc"
"soilMoisture"
],
"attrsFormat": "keyValues"
},
......
......@@ -20,6 +20,6 @@ curl -iX POST \
"addressCountry": "Switzerland"
},
"soilTemperature": 17,
"soilMoistureVwc": 0.85
"soilMoisture": 0.85
}
'
......@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}"
curl --location --request GET \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value" \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value" \
--header "Fiware-Service: carouge" \
| python -mjson.tool
......
......@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}"
curl --location --request GET \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc" \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture" \
--header "Fiware-Service: carouge" \
| python -mjson.tool
......@@ -4,7 +4,7 @@
echo "Querying context broker at: ${ORION_HOST}"
curl --location --request PUT \
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoistureVwc/value"\
"http://$ORION_HOST:1026/v2/entities/urn:ngsi-ld:FlowerBed:FlowerBed-1/attrs/soilMoisture/value"\
--header "Fiware-Service: carouge" \
--header "Content-Type: text/plain" \
-d $(( RANDOM % 10 ))
......@@ -3,7 +3,7 @@
[[ -z "$ORION_HOST" ]] && echo "Please set ORION_HOST env var. E.g. export ORION_HOST=127.0.0.1" && exit
echo "Querying context broker at: ${ORION_HOST}"
[[ -z "$SUBSCRIPTION_URL" ]] && echo "Please set SUBSCRIPTION_URL env var. E.g. export SUBSCRIPTION_URL=http://172.18.1.11:5000/on_change_soilMoistureVwc" && exit
[[ -z "$SUBSCRIPTION_URL" ]] && echo "Please set SUBSCRIPTION_URL env var. E.g. export SUBSCRIPTION_URL=http://172.18.1.11:5000/on_change_soilMoisture" && exit
echo "Callback URL for subscriptions is: ${SUBSCRIPTION_URL}"
......@@ -13,7 +13,7 @@ curl --location --request POST \
--header "Content-Type: application/json" \
--header "Accept: application/json" \
--data '{
"description": "A subscription to subscribe to FlowerBed.soilMoistureVwc",
"description": "A subscription to subscribe to FlowerBed.soilMoisture",
"subject": {
"entities": [
{
......@@ -23,7 +23,7 @@ curl --location --request POST \
],
"condition": {
"attrs": [
"soilMoistureVwc"
"soilMoisture"
]
}
},
......@@ -32,7 +32,7 @@ curl --location --request POST \
"url": "'${SUBSCRIPTION_URL}'"
},
"attrs": [
"soilMoistureVwc"
"soilMoisture"
],
"attrsFormat": "keyValues"
},
......
......@@ -8,6 +8,6 @@ curl --location --request PATCH \
--header "Fiware-Service: carouge" \
--header 'Content-Type: application/json' \
--data-raw '{
"soilMoistureVwc": 899.85,
"soilMoisture": 899.85,
"soilTemperature": null
}'
......@@ -11,14 +11,14 @@ logger = logging.getLogger(__name__)
def healthcheck():
return 'This service is up and running!'
@app.route('/on_change_soilMoistureVwc',methods = ['POST'])
def on_change_soilMoistureVwc():
@app.route('/on_change_soilMoisture',methods = ['POST'])
def on_change_soilMoisture():
# if request.data:
# app.logger.info("Request data: %s" % request.data)
if request.json:
app.logger.info("Got new soil moisture value from context broker: %s" % request.json['data'])
return 'Got POST for /on_change_soilMoistureVwc, with body %s' % request.form
return 'Got POST for /on_change_soilMoisture, with body %s' % request.form
if __name__ == "__main__":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment