Skip to content

Instantly share code, notes, and snippets.

View thatguychrisw's full-sized avatar

Christopher Willard thatguychrisw

View GitHub Profile
@thatguychrisw
thatguychrisw / ifttt_toggle_device_state.sh
Last active December 26, 2019 15:12
Shell script to toggle a device using a smart switch
# In IFTTT create two webhooks named using the pattern, "$DEVICE_on" and "$DEVICE_off"
DEVICE="desk_fan"
# This is where the state of the device is kept
DEVICE_STATE_FILE=~/.${DEVICE}.state
IFTTT_KEY=""
# Set the default state of the device to "off" if the status file does not exist
[ -s $DEVICE_STATE_FILE ] || echo "off" > $DEVICE_STATE_FILE