-
-
Save nov-/29211179721c4c40b6b73671c69ee997 to your computer and use it in GitHub Desktop.
Homebridge disk space as Lightbulb with homebridge-cmd4 plugin
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 | |
# Plugin: https://github.com/ztalbot2000/homebridge-cmd4 | |
# | |
# config.json | |
# | |
# ... | |
# { | |
# "platform": "Cmd4", | |
# "name": "Cmd4", | |
# "accessories": | |
# [ | |
# { | |
# "type": "Lightbulb", | |
# "name": "Disk Space", | |
# "brightness":100, | |
# "polling": true, | |
# "interval": 5, | |
# "stateChangeResponseTime": 0, | |
# "state_cmd": "bash .homebridge/Cmd4Scripts/DiskSpaceLightbulb.sh" | |
# } | |
# ] | |
# } | |
# ... | |
if [ "$1" = "Get" ]; then | |
if [ "$3" == "On" ]; then | |
echo 1 | |
exit 0 | |
elif [ "$3" == "Brightness" ]; then | |
diskSpace=$(df -Bm | sed '2q;d' | sed 's/.*\([0-9][0-9]\%\).*/\1/' | sed s/\%//) | |
echo "$diskSpace" | |
exit 0 | |
fi | |
fi | |
if [ "$1" = "Set" ]; then | |
echo 1 | |
exit 0 | |
fi | |
exit -1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment