Skip to content

Instantly share code, notes, and snippets.

@tomasinouk
Last active October 26, 2016 01:49
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 tomasinouk/5e7d5201496b599725fa34481c6acbcb to your computer and use it in GitHub Desktop.
Save tomasinouk/5e7d5201496b599725fa34481c6acbcb to your computer and use it in GitHub Desktop.

Script reads BIN0 (binary input 0) on the Conel, SmartWorkx router and displaying it in a console. Can be looged in systemlog as well. Little modification can be done to log it into the file, in CSV format.

#!/bin/ash

OLD0="-1"
SLEEP_TIME=1

while true
do
    /usr/bin/io get bin0
    VAL0=$?  #get result from io command
    if [ "$VAL0" != "$OLD0" ]; then #value changed
        if [ "$VAL0" = "0" ]; then #relay closed
#            /usr/bin/logger "relay closed" # logging into syslog
            echo "`date +%D-%H:%M:%S`, relay closed"
#           for a in $EMAIL1 $EMAIL2

        elif [ "$VAL0" = "1" ]; then #relay open
#            /usr/bin/logger "relay open" # logging into syslog
            echo "`date +%D-%H:%M:%S`, relay open"
        fi
        OLD0=$VAL0
    elif [ "$VAL0" == "$OLD0" ]; then
#        /usr/bin/logger "no change" # logging into syslog
        echo "`date +%D-%H:%M:%S`, no change"
    fi
    sleep $SLEEP_TIME
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment