Hello everybody!
Im working on controlling my 433mhz remote controlled RF outlets with openhab and exec and i would need some help.
My current status is that my RF outlets are controlled by a shell-script that takes two parameters, device id and command.
My RF outlets are a bit peculiar, they have a unique code for each device and state, meaning device1 & ON = 1381717 while device1 & OFF = 1381719.
So, how should i configure exec to send two commands to the script?
The complete command string to be sent looks like this:
“/opt/rf433.sh 1 off” to turn device 1 off.
I verified that the script works with openhab user with the above command string, but i havent a clue how to send more than one parameter from exec…
I havent really started on the openhab config files, just experimenting wildly so far, but here´s the script:
#!/bin/bash
# must be called with a parameter
# rf433_send.sh [channel] [command]
# will send the associated command to the corresponding RF outlet over 433mhz radio.
if [ $# -lt 2 ] #Check to see if at least two parameters was supplied
then
echo "Must be called with the channel id and command to send to the RF outlet"
echo "example: " $0 "1 on" # $0 is the name of the program
echo "For help, use: " $0 " -? "
exit 1
fi
if [ $# -ge 2 ] # if there were 2 or more parameters
then
case $1 in
"-?") echo "Supported channel id is 1..14" ;;
"1")
case $2 in
"on") echo /opt/RF433Utils/RPi_utils/codesend 1381717
/opt/RF433Utils/RPi_utils/codesend 1381717
;;
"off") echo /opt/RF433Utils/RPi_utils/codesend 1381719
/opt/RF433Utils/RPi_utils/codesend 1381719
;;
*) echo "unknown state, should be "on" or "off""
;;
esac
;;
"2")
case $2 in
"on") echo /opt/RF433Utils/RPi_utils/codesend 1394005
/opt/RF433Utils/RPi_utils/codesend 1394005
;;
"off") echo /opt/RF433Utils/RPi_utils/codesend 1394004
/opt/RF433Utils/RPi_utils/codesend 1394004
;;
*) echo "unknown state, should be "on" or "off""
;;
esac
;;
"3")
case $2 in
"on") echo /opt/RF433Utils/RPi_utils/codesend 1397077
/opt/RF433Utils/RPi_utils/codesend 1397077
;;
"off") echo /opt/RF433Utils/RPi_utils/codesend 1397076
/opt/RF433Utils/RPi_utils/codesend 1397076
;;
*) echo "unknown state, should be "on" or "off""
;;
esac
;;
"4")
case $2 in
"on") echo /opt/RF433Utils/RPi_utils/codesend 1397845
/opt/RF433Utils/RPi_utils/codesend 1397845
;;
"off") echo /opt/RF433Utils/RPi_utils/codesend 1397844
/opt/RF433Utils/RPi_utils/codesend 1397844
;;
*) echo "unknown state, should be "on" or "off""
;;
esac
;;
*) echo "unknown device id, should be "1"..."14""
;;
esac
else
echo "input needs a second parameter"
echo "usage: " $0 " [device-id] [state]"
echo "device id is 1-16, state is on/off"
fi
# end of the input case
exit 0
My shell-script is dependent on a utility called 433Utils/RPi_utils from NinjaBlocks.