watering_07_subscribe_to_entity.sh 1.23 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
#!/usr/bin/env bash

[[ -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
echo "Callback URL for subscriptions is: ${SUBSCRIPTION_URL}"


curl --location --request POST \
    "http://$ORION_HOST:1026/v2/subscriptions/" \
    --header "Fiware-Service: carouge" \
13
    --header "Fiware-ServicePath: /Watering" \
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data '{
      "description": "A subscription to subscribe to FlowerBed.soilMoistureVwc",
      "subject": {
        "entities": [
          {
            "id": "urn:ngsi-ld:FlowerBed:FlowerBed-345",
            "type": "FlowerBed"
          }
        ],
        "condition": {
          "attrs": [
            "soilMoistureVwc"
          ]
        }
      },
      "notification": {
        "http": {
          "url": "'${SUBSCRIPTION_URL}'"
        },
        "attrs": [
          "soilMoistureVwc"
        ],
        "attrsFormat": "keyValues"
      },
      "throttling": 5
    }'