From e17dbb8baa7e3a4a7eab7e9bc4798453844d1f16 Mon Sep 17 00:00:00 2001 From: dietmar63 <> Date: Sun, 28 Jul 2013 13:37:42 +0000 Subject: [PATCH] RandomTimer module added - a module to simulate the random funktionality of a timer clock like FS20ZSU. git-svn-id: https://svn.fhem.de/fhem/trunk@3521 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_RandomTimer.pm | 484 ++++++++++++++++++++++++++++++++++++ fhem/MAINTAINER.txt | 1 + 2 files changed, 485 insertions(+) create mode 100644 fhem/FHEM/98_RandomTimer.pm diff --git a/fhem/FHEM/98_RandomTimer.pm b/fhem/FHEM/98_RandomTimer.pm new file mode 100644 index 000000000..5a978725a --- /dev/null +++ b/fhem/FHEM/98_RandomTimer.pm @@ -0,0 +1,484 @@ +############################################################################## +# +# 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 . +# +############################################################################## +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->{AttrList} = "loglevel:0,1,2,3,4,5,6 onCmd offCmd switchmode disable:0,1 disableCond ". + $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 \"[+][*]