/opt/openhab2/send_cul.sh
#!/bin/bash
debug=0
pipe=/opt/openhab2/send_cul.fifo
cul="/dev/ttyCUL0"
function clean_up {
# Perform program exit housekeeping
rm $pipe exit $1
}
trap clean_up SIGHUP SIGINT SIGTERM
stty -F $cul raw ispeed 38400 ospeed 38400 cs8 -ignpar -cstopb -echo (cat < $cul )&
mkfifo -m 666 "$pipe"
while true;
do
while IFS= read -r cmd;
do IFS=\ read address ohcommand <<< $cmd
if [ -n "${ohcommand}" -a -n "${address}" ]
[[ debug -eq 1 ]] && echo got message: $ohcommand $address
then
if [[ x"${ohcommand}" = "xON" ]] then
[[ debug -eq 1 ]] && echo F"${address}"10 to $cul
echo F"${address}"10 > $cul
elif [[ x"${ohcommand}" = "xOFF" ]] then
[[ debug -eq 1 ]] && echo F"${address}"00 to $cul
echo F"${address}"00 > $cul
fi
fi
sleep 0.2 done < "$pipe"
done
clean_up
item configuration
Switch WallSwitch4 "Steckdose4"
/opt/openhab2/start.sh
!/bin/sh (/opt/openhab2/send_cul.sh)& [...]
/etc/udev/rules.d/cul.rules
ATTRS{idVendor}"1a86", ATTRS{idProduct}"7523" SYMLINK+="ttyCUL0" MODE="0666"