2007-01-30 12:47:36 +00:00
|
|
|
##############################################
|
2007-04-14 08:22:18 +00:00
|
|
|
# Example perl functions. Put this file into the FHEM directory.
|
|
|
|
#
|
|
|
|
# # Activate 2 rollades at once with one button, open them to
|
|
|
|
# # a different degree.
|
|
|
|
# define ntfy_1 notifyon btn3 {MyFunc("@", "%")}
|
|
|
|
#
|
|
|
|
# # Swith the heater off if all FHT actuators are closed,
|
|
|
|
# # and on if at least one is open
|
|
|
|
# define at_1 at +*00:05 { fhem "set heater " . (sumactuator()?"on":"off") };
|
2007-01-30 12:47:36 +00:00
|
|
|
|
|
|
|
package main;
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
sub
|
|
|
|
PRIV_Initialize($$)
|
|
|
|
{
|
|
|
|
my ($hash, $init) = @_;
|
2007-04-14 08:22:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub
|
|
|
|
sumactuator()
|
|
|
|
{
|
|
|
|
my $sum = 0;
|
|
|
|
foreach my $d (keys %defs) {
|
|
|
|
next if($defs{$d}{TYPE} ne "FHT");
|
|
|
|
my ($act, undef) = split(" ", $defs{$d}{READINGS}{"actuator"}{VAL});
|
|
|
|
$act =~ s/%//;
|
|
|
|
$sum += $act;
|
|
|
|
}
|
|
|
|
return $sum;
|
2007-01-30 12:47:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
sub
|
|
|
|
MyFunc($$)
|
|
|
|
{
|
|
|
|
my ($a1, $a2) = @_;
|
|
|
|
|
|
|
|
Log 2, "Device $a1 was set to $a2 (type: $defs{$a1}{TYPE})";
|
|
|
|
if($a2 eq "on") {
|
2007-04-14 08:22:18 +00:00
|
|
|
fhem "set roll1 on-for-timer 10";
|
|
|
|
fhem "set roll2 on-for-timer 16";
|
2007-01-30 12:47:36 +00:00
|
|
|
} else {
|
2007-04-14 08:22:18 +00:00
|
|
|
fhem "set roll1 off";
|
|
|
|
fhem "set roll2 off";
|
2007-01-30 12:47:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|