package main; use strict; use warnings; use POSIX qw(strftime floor); use Scalar::Util qw(looks_like_number); use Switch; sub MyFhem($) { my ($cmd) = @_; if ( $cmd =~ /([-_\w]+):([-_\w]+):([-_\w]+)(:([-_\w]+))?/ ) { $cmd = "set $1 $2 $3"; my $check = { dev => $1, reading => $2, level => $3, retry => 0 }; smInternalTimer( "c_".$1."_".$2, time+( $5 // 3 )*60, "CheckActionDone", $check, 1 ); } fhem($cmd); } my ( $notifytable_sec, $notifytable_min, $notifytable_hour, $notifytable_mday, $notifytable_mon, $notifytable_year, $notifytable_wday, $notifytable_yday, $notifytable_isdst); sub MyReadingsVal($$$) { my ($dev, $rdg, $def) = @_; my $r=''; if ( $dev eq "TIME" ) { switch ($rdg) { case 'hour' { $r = $notifytable_hour } case 'hfhour' { $r = $notifytable_hour << 1 + ( $notifytable_min > 29 ? 1 : 0 ) } case 'qhour' { $r = $notifytable_hour << 2 + floor( $notifytable_min/15 ) } case 'minute' { $r = $notifytable_min } case 0 { $r = $notifytable_min } else { $r = undef } } } else { $r = ReadingsVal( $dev, $rdg, $def ); } return $r; }