From de2f83356aefcc4623ca4384092a25c1a1231dda Mon Sep 17 00:00:00 2001 From: mgehre <> Date: Thu, 29 Aug 2013 20:15:24 +0000 Subject: [PATCH] MAX: move temperature validation and parsing to MaxCommon git-svn-id: https://svn.fhem.de/fhem/trunk@3819 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_MAX.pm | 8 -------- fhem/FHEM/MaxCommon.pm | 11 ++++++++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/fhem/FHEM/10_MAX.pm b/fhem/FHEM/10_MAX.pm index 518edb14d..005362117 100755 --- a/fhem/FHEM/10_MAX.pm +++ b/fhem/FHEM/10_MAX.pm @@ -25,7 +25,6 @@ my %boost_durationsInv = reverse %boost_durations; my %decalcDays = (0 => "Sat", 1 => "Sun", 2 => "Mon", 3 => "Tue", 4 => "Wed", 5 => "Thu", 6 => "Fri"); my %decalcDaysInv = reverse %decalcDays; -sub validTemperature { return $_[0] eq "on" || $_[0] eq "off" || ($_[0] ~~ /^\d+(\.[05])?$/ && $_[0] >= 5 && $_[0] <= 30); } sub validWindowOpenDuration { return $_[0] ~~ /^\d+$/ && $_[0] >= 0 && $_[0] <= 60; } sub validMeasurementOffset { return $_[0] ~~ /^-?\d+(\.[05])?$/ && $_[0] >= -3.5 && $_[0] <= 3.5; } sub validBoostDuration { return $_[0] ~~ /^\d+$/ && exists($boost_durationsInv{$_[0]}); } @@ -139,13 +138,6 @@ MAX_CheckIODev($) return !defined($hash->{IODev}) || ($hash->{IODev}{TYPE} ne "MAXLAN" && $hash->{IODev}{TYPE} ne "CUL_MAX"); } -#Identify for numeric values and maps "on" and "off" to their temperatures -sub -MAX_ParseTemperature($) -{ - return $_[0] eq "on" ? 30.5 : ($_[0] eq "off" ? 4.5 :$_[0]); -} - # Print number in format "0.0", pass "on" and "off" verbatim, convert 30.5 and 4.5 to "on" and "off" # Used for "desiredTemperature", "ecoTemperature" etc. but not "temperature" sub diff --git a/fhem/FHEM/MaxCommon.pm b/fhem/FHEM/MaxCommon.pm index 2fe33ee7a..3269c069b 100644 --- a/fhem/FHEM/MaxCommon.pm +++ b/fhem/FHEM/MaxCommon.pm @@ -2,7 +2,7 @@ package MaxCommon; require Exporter; @ISA = qw(Exporter); -@EXPORT = qw(%device_types %msgId2Cmd %msgCmd2Id $defaultWeekProfile); +@EXPORT = qw(%device_types %msgId2Cmd %msgCmd2Id $defaultWeekProfile MAX_ParseTemperature validTemperature); %device_types = ( 0 => "Cube", @@ -52,4 +52,13 @@ require Exporter; $defaultWeekProfile = "444855084520452045204520452045204520452045204520452044485508452045204520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc55144520452045204520452045204520452045204448546c44cc5514452045204520452045204520452045204520"; +sub validTemperature { return $_[0] eq "on" || $_[0] eq "off" || ($_[0] ~~ /^\d+(\.[05])?$/ && $_[0] >= 5 && $_[0] <= 30); } + +#Identify for numeric values and maps "on" and "off" to their temperatures +sub +MAX_ParseTemperature($) +{ + return $_[0] eq "on" ? 30.5 : ($_[0] eq "off" ? 4.5 :$_[0]); +} + 1;