Skip to content

Instantly share code, notes, and snippets.

@rejeep
Last active January 27, 2019 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rejeep/0544486b0d9b839bed8348baeae595dd to your computer and use it in GitHub Desktop.
Save rejeep/0544486b0d9b839bed8348baeae595dd to your computer and use it in GitHub Desktop.
Robin check temperature script
#!/bin/bash
# DEPENDENCIES: brew install jq curl
curl -X POST "https://mypages.verisure.com/j_spring_security_check?locale=sv_SE" \
--data 'j_username=robin@liljeros.nu&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" "robin@liljeros.nu"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment