Last active
January 27, 2019 19:02
-
-
Save rejeep/0544486b0d9b839bed8348baeae595dd to your computer and use it in GitHub Desktop.
Robin check temperature script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# DEPENDENCIES: brew install jq curl | |
curl -X POST "https://mypages.verisure.com/j_spring_security_check?locale=sv_SE" \ | |
--data '[email protected]&j_password=...' \ | |
--cookie cookie.txt \ | |
--cookie-jar cookie.txt | |
curl -X GET "https://mypages.verisure.com/overview/climatedevice?_=1548613153475" \ | |
--cookie cookie.txt \ | |
--cookie-jar cookie.txt \ | |
--output climatedevice.json | |
TOO_COLD_ROOMS=$(cat climatedevice.json | jq 'map({location: .location, temperature: .temperature | gsub(",.+"; "") | tonumber}) | map(select(.temperature < 20))') | |
if [[ -z "$TOO_COLD_ROOMS" ]]; then | |
echo "No rooms too cold" | |
else | |
echo "$TOO_COLD_ROOMS" | |
# Need to set up local SMTP server for this to work | |
# echo $TOO_COLD_ROOMS | mail -s "I'm cold, damn it" "[email protected]" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment