Created
February 10, 2023 06:46
-
-
Save thomaswitt/9aaf6a8b4b3e48535c2b1f5857bafc4e to your computer and use it in GitHub Desktop.
Turn Sony Bravia TV on and off – To be used with EventScripts (https://www.mousedown.net/software/EventScripts.html)
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
#!/usr/bin/env bash | |
# Turn Sony Bravia TV on and off | |
# To be used with EventScripts (https://www.mousedown.net/software/EventScripts.html) | |
# Get Auth Cookie Script from https://github.com/breunigs/bravia-auth-and-remote.git | |
IP="0.0.0.0" | |
MACADDR="00:00:00:00:00:00" | |
COOKIE="output from https://github.com/breunigs/bravia-auth-and-remote/blob/master/auth_cookie_examples/auth.sh" | |
OWN_SSID="MY_SSID" | |
SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F' SSID: ' '/ SSID: / {print $2}') | |
if [ "${SSID}" = "${OWN_SSID}" ]; then | |
if [ "$1" = "Screen password unlocked" ]; then | |
echo "Switching on TV" | |
/opt/homebrew/bin/wakeonlan -i ${IP} ${MACADDR} | |
else | |
echo "Switching off TV" | |
curl -q --cookie "auth=${COOKIE}" -X POST http://${IP}/sony/system \ | |
-d '{"id":55,"method":"setPowerStatus","version":"1.0","params":[{"status":false}]}' | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment