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