2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-01-31 12:49:34 +00:00
fhem-mirror/fhem/examples/02_fs20

72 lines
2.2 KiB
Plaintext
Raw Normal View History

#
# fhem.pl configfile
#
# 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-%Y-%m.log
attr global statefile /tmp/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 . # 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 ;
notifyon btn3 set roll1 %;; set roll2 %
# Method 1b: shorter:
notifyon btn3 set roll1,roll2 %
# Method 2a: perl.
notifyon 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.
notifyon 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. The script follows after "quit". Dont forget to chmod u+x it.
notifyon 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