# $Id$ ############################################################################## # # 98_RandomTimer_Initialize.pm # written by Dietmar Ortmann # # This file is part of fhem. # # Fhem is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License, or # (at your option) any later version. # # Fhem is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with fhem. If not, see . # # define t1 RandomTimer *23:01:10 Zirkulation 23:02:10 100; attr t1 verbose 5; # define t2 RandomTimer *23:01:20 Zirkulation 23:03:20 100; attr t2 verbose 5; # define t3 RandomTimer *23:01:30 Zirkulation 23:04:30 100; attr t3 verbose 5; # define t4 RandomTimer *23:01:40 Zirkulation 23:02:40 100; attr t4 verbose 5; # ############################################################################## # 10.09.2013 Svenson : disable direct if attribute changed, add state disabled; # randomtimer run every day if attribut runonce 0 (default is 1) # ############################################################################## package main; use strict; use warnings; use IO::Socket; use Time::HiRes qw(gettimeofday); sub RandomTimer_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "RandomTimer_Define"; $hash->{UndefFn} = "RandomTimer_Undef"; $hash->{AttrFn} = "RandomTimer_Attr"; $hash->{AttrList} = "onCmd offCmd switchmode disable:0,1 disableCond runonce:0,1 keepDeviceAlive ". $readingFnAttributes; } # # # sub RandomTimer_Undef($$) { my ($hash, $arg) = @_; RemoveInternalTimer($hash); delete $modules{RandomTimer}{defptr}{$hash->{NAME}}; return undef; } # # # sub RandomTimer_Define($$) { my ($hash, $def) = @_; RemoveInternalTimer($hash); my ($name, $type, $timespec_start, $device, $timespec_stop, $timeToSwitch) = split("[ \t][ \t]*", $def); return "wrong syntax: define RandomTimer " if(!defined $timeToSwitch); return "Wrong timespec_start <$timespec_start>, use \"[+][*]