Created
February 8, 2017 14:12
-
-
Save elneruda/b8fba9947e2f623dd20bb1e01dce9070 to your computer and use it in GitHub Desktop.
plexpy -> iFTTT Maker -> hue
This file contains 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/sh | |
HOOK_IFTTT_MAKER_KEY="" | |
HOOK_PLEX_USERNAME="" | |
HOOK_PLEX_PLAYER="" | |
HOOK_PLEX_NIGHT_HOUR_MIN=19 | |
HOOK_PLEX_NIGHT_HOUR_MAX=6 | |
HOOK_PLEX_PLAY="Play" | |
HOOK_PLEX_STOP="Stop" | |
HOOK_PLEX_PAUSE="Pause" | |
HOOK_PLEX_RESUME="Resume" | |
HOOK_PLEX_WATCHED="watched" | |
HOOK_PLEX_BUFFER="buffer" | |
HOOK_PLEX_CREATED="created" | |
HOOK_PLEX_INTDOWN="intdown" | |
HOOK_PLEX_INTUP="intup" | |
HOOK_PLEX_EXTDOW="extdown" | |
HOOK_PLEX_EXTUP="extup" | |
HOOK_PLEX_PMSUPDATE="pmsupdate" | |
HOOK_PLEX_CONCURRENT="concurrent" | |
HOOK_PLEX_NEWDEVICE="newdevice" | |
isTimeToPerformUpdates () { | |
now=$(date +"%H") | |
if [ $now -lt $HOOK_PLEX_NIGHT_HOUR_MAX ]; then | |
return 0 | |
fi | |
if [ $now -gt $HOOK_PLEX_NIGHT_HOUR_MIN ]; then | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
isPlayerEnabled () { | |
if [ "$1" = "$HOOK_PLEX_PLAYER" ]; then | |
# 0 = true | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
isUserEnabled () { | |
if [ "$1" = "$HOOK_PLEX_USERNAME" ]; then | |
# 0 = true | |
return 0 | |
else | |
return 1 | |
fi | |
} | |
postIFTTTHook () { | |
#echo "$1, $2, $3" | |
brightness=50 | |
if [ "$1" = "$HOOK_PLEX_PAUSE" ]; then | |
brightness=$((brightness + 10)) | |
else | |
brightness=$((brightness - 10)) | |
fi | |
curl -s -X POST -H "Content-Type: application/json" -d '{"value1":"'"$1"'","value2":"'"$2"'","value3":"'"$brightness"'"}' https://maker.ifttt.com/trigger/plexpy_"$1"/with/key/"$HOOK_IFTTT_MAKER_KEY" > /dev/null | |
} |
This file contains 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/sh | |
. ./hueHelper.sh | |
if isTimeToPerformUpdates && isUserEnabled "$2" && isPlayerEnabled "$3"; | |
then | |
postIFTTTHook "$1" "$2" "$3" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment