Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- server=https://stanleyroad.co.za:8123
- token=
- # Retrieving ABB Usage Data
- cookie="$(mktemp)"
- waterusage=$(curl -c $cookie -b $cookie -H 'Connection: keep-alive' -H 'sap-alias: <uname>' -H 'sap-password: <pwd>' 'https://eservices1.capetown.gov.za/coct/api/zuces/device/JJK5176?partner_id=1001532966&account_number=000226025214&contract=0006509716&_=1582468908478')
- rm $cookie
- echo $waterusage
- # Get Variables from String
- deviceID=$(echo "$waterusage" | jq '.["device"]')
- address=$(echo "$waterusage" | jq '.["ad_formatted"]')
- unitsMeasure=$(echo "$waterusage" | jq '.["mr_unit"]')
- lastUpdated=$(echo "$waterusage" | jq '.["mr_last_date"]')
- meterReading=$(echo "$waterusage" | jq '.["meter_reading"]')
- # Build JSON output
- waterusagejson='{"state":"","attributes":{"usage":"","deviceID":'"$deviceID"',"address":'"$address"',"unitsMeasure":'"$unitsMeasure"',"lastUpdated":'"$lastUpdated"',"meterReading":'"$meterReading"'}}'
- echo $waterusagejson
- curl -X POST -H "Authorization: Bearer $token" \
- -H "Content-Type: application/json" \
- -d "$waterusagejson" \
- "$server"/api/states/sensor.cct_water_usage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement