2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 18:59:33 +00:00
fhem-mirror/fhem/examples/02_fs20
rudolfkoenig 873ccc570c See the changes file
git-svn-id: https://svn.fhem.de/fhem/trunk@284 2b470e98-0d58-463d-a4d8-8e2adae1ed80
2008-12-09 14:12:40 +00:00

74 lines
2.4 KiB
Plaintext

#
# fhem.pl configfile
#
# The challange: We have 2 rollades (which are connected via the FS20MS).
# Button 3 on the FS20S20 should activate both rollades. There are three
# solutions:
# 1. Builtin commands
# 2. Perl expression
# 3. Shell script (realized via external script at the end of this file)
# Common part
attr global logfile /tmp/fhem/fhem-%Y-%m.log
attr global statefile /tmp/fhem/fhem.save # where to save the state of the devices
attr global verbose 3 # "normal" verbosity
attr global port 7072 # our TCP/IP port (localhost only)
attr global modpath /tmp/fhem/fhem # where our FHEM directory is
define FHZ FHZ /dev/tts/USB0 # the serial port of an FHZ 1000 PC
define roll1 FS20 7777 02 # type FS20, transmitter code 7777, button 3
define roll2 FS20 7777 03 # type FS20, transmitter code 7777, button 4
define btn3 FS20 8765 03 # define a button from the FS20S20
setstate roll1 off # initial state is closed
# Note: Only one of the methods should be used
# Method 1a: builtin commands. Note the double ;
define n_1a notify btn3 set roll1 %;; set roll2 %
# Method 1b: shorter:
define n_1b notify btn3 set roll1,roll2 %
# Method 2a: the same in perl. Everything between {} is evaluated as perl code
define n_2a notify btn3 { fhem "set roll1,roll2 %" }
# Method 2b: perl. open the rollades only to a certain amount if they are
# closed. Else do the required command.
define n_2b notify btn3 {\
if("%" eq "on" && $value{roll1} eq "off") {\
fhem "set roll1 on-for-timer 10";;\
fhem "set roll2 on-for-timer 16";;\
} else { \
fhem "set roll1,roll2 %"\
} \
}
# Method 3: shell. Everything between "" is evaluated as a shell command. The
# script follows after "quit". Dont forget to chmod u+x it.
define n_3 notify btn3 "/usr/local/bin/roll.sh %"
quit # Ignore the rest of this file
#!/bin/sh
#
# roll1 needs 10 sec to open to a certain level, roll2 16 sec. The following
# shell script opens both of them when called woth "on", and closes both of
# them else. We rely on the fact, that the FS20MS switches off after ca 60s.
#
# Note that for greater time values the FS20 timer gets inaccurate, you
# can use something like
# $fhem 7072 "set roll1 on; at +00:00:21 set roll1 on"
# instead.
#
fhem=/usr/local/bin/fhem.pl
if test $1 = "on"; then
$fhem 7072 "set roll1 on-for-timer 10"
$fhem 7072 "set roll2 on-for-timer 16"
else
$fhem 7072 "set roll1,roll2 off"
fi