leos1971

domoticz_main

May 2nd, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.61 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # script to turn on heater
  4.  
  5. device_id=$3
  6. status=$4
  7. MASTERSWITCH="40"
  8. SUBSCRIPT="/opt/domoticz/scripts/heateron.sh"
  9.  
  10. #echo $device_if $status
  11.  
  12. if [ "$device_id" = "$MASTERSWITCH" ] ; then
  13.   CHK=`ps aux|grep $SUBSCRIPT|grep -v grep`
  14.   if [ "$status" = "On" ] ; then
  15.     if [ "$CHK" = "" ] ; then
  16.       echo "Heater control system is ON"
  17.       $SUBSCRIPT &
  18.     else
  19.       echo "Heater already running"
  20.     fi
  21.   else
  22.     if [ "$CHK" != "" ] ; then
  23.       echo "Heater control system is OFF"
  24.       killall -9 `basename $SUBSCRIPT`
  25.     else
  26.       echo "Heater not running"
  27.     fi
  28.   fi
  29. fi
Advertisement
Add Comment
Please, Sign In to add comment