From ae66cd7062f75c6447ef2662b64d904346cc86a7 Mon Sep 17 00:00:00 2001 From: jamesgo <> Date: Tue, 26 Jan 2016 18:23:13 +0000 Subject: [PATCH] 93_PWMR.pm : fix content of IODev to support xmllist git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@10640 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- contrib/93_PWMR.pm | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/contrib/93_PWMR.pm b/contrib/93_PWMR.pm index 06c3d70d1..1a7c24acc 100644 --- a/contrib/93_PWMR.pm +++ b/contrib/93_PWMR.pm @@ -1,6 +1,6 @@ # # -# 94_PWMR.pm +# 93_PWMR.pm # written by Andreas Goebel 2012-07-25 # e-mail: ag at goebel-it dot de # @@ -23,6 +23,8 @@ # 22.11.15 GA fix error handling in SetRoom (thanks to cobra112) # 30.11.15 GA fix set reading of desired-temp-used to frost_protect if window is opened # 30.11.15 GA add call PWMR_Attr in PWMR_Define if already some attributes are defined +# 26.01.16 GA fix don't call AssignIoPort +# 26.01.16 GA fix assign IODev as reference to that hash (otherwise xmllist will crash fhem) # module for PWM (Pulse Width Modulation) calculation @@ -421,7 +423,7 @@ PWMR_Define($$) return "syntax: define PWMR [:] [[,][:]]" if(int(@a) < 6 || int(@a) > 8); - my $iodev = $a[2]; + my $iodevname = $a[2]; my $factor = ((int(@a) > 2) ? $a[3] : 0.2); my $tsensor = ((int(@a) > 3) ? $a[4] : ""); my $actor = ((int(@a) > 4) ? $a[5] : ""); @@ -438,15 +440,16 @@ PWMR_Define($$) #$hash->{helper}{cycletime} = 0; - if ( !$defs{$iodev} ) { - return "unknown device $iodev"; + if ( !$iodevname ) { + return "unknown device $iodevname"; } - if ( $defs{$iodev}->{TYPE} ne "PWM" ) { - return "wrong type of $iodev (not PWM)"; + if ( $defs{$iodevname}->{TYPE} ne "PWM" ) { + return "wrong type of $iodevname (not PWM)"; } - $hash->{IODev} = $iodev; + #$hash->{IODev} = $iodev; + $hash->{IODev} = $defs{$iodevname}; ########## # calculage factoroffset @@ -556,7 +559,7 @@ PWMR_Define($$) $hash->{INTERVAL} = 300; - AssignIoPort($hash); + #AssignIoPort($hash); # if attributes already defined then recall set for them foreach my $oneattr (sort keys %{$attr{$name}}) @@ -760,7 +763,8 @@ PWMR_ReadRoom(@) my $PWMOnTime = sprintf ("%02s:%02s", int ($newpulse * $cycletime / 60), ($newpulse * $cycletime) % 60); my $iodev = $room->{IODev}; - if ($newpulse * $defs{$iodev}->{CYCLETIME} < $defs{$iodev}->{MINONOFFTIME}) { + #if ($newpulse * $defs{$iodev}->{CYCLETIME} < $defs{$iodev}->{MINONOFFTIME}) { + if ($newpulse * $iodev->{CYCLETIME} < $iodev->{MINONOFFTIME}) { $PWMPulse = 0; $PWMOnTime = "00:00"; }