MAX: update validation of "desiredTemperature" command

git-svn-id: svn://svn.code.sf.net/p/fhem/code/trunk@8445 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
mgehre
2015-04-16 19:53:53 +00:00
parent 686652d8a8
commit 0061cc519d

View File

@@ -271,7 +271,7 @@ MAX_Set($@)
#This enables the automatic/schedule mode where the thermostat follows the weekly program #This enables the automatic/schedule mode where the thermostat follows the weekly program
#There can be a temperature supplied, which will be kept until the next switch point of the weekly program #There can be a temperature supplied, which will be kept until the next switch point of the weekly program
if(@args > 1) { if(@args == 2) {
if($args[1] eq "eco") { if($args[1] eq "eco") {
$temperature = MAX_ReadingsVal($hash,"ecoTemperature"); $temperature = MAX_ReadingsVal($hash,"ecoTemperature");
} elsif($args[1] eq "comfort") { } elsif($args[1] eq "comfort") {
@@ -279,18 +279,21 @@ MAX_Set($@)
} else { } else {
$temperature = MAX_ParseTemperature($args[1]); $temperature = MAX_ParseTemperature($args[1]);
} }
} else { } elsif(@args == 1) {
$temperature = 0; #use temperature from weekly program $temperature = 0; #use temperature from weekly program
} else {
return "To many parameters: desiredTemperature auto [<temperature>]";
} }
$ctrlmode = 0; #auto $ctrlmode = 0; #auto
} else { } else {
return "To many parameters to desiredTemperature: expected one" if(@args > 1);
if($args[0] eq "boost") { if($args[0] eq "boost") {
return "To many parameters: desiredTemperature boost" if(@args > 1);
$temperature = 0; $temperature = 0;
$ctrlmode = 3; $ctrlmode = 3;
#TODO: auto mode with temperature is also possible #TODO: auto mode with temperature is also possible
} elsif($args[0] eq "eco") { } elsif($args[0] eq "eco") {
$temperature = MAX_ReadingsVal($hash,"ecoTemperature"); $temperature = MAX_ReadingsVal($hash,"ecoTemperature");
} elsif($args[0] eq "comfort") { } elsif($args[0] eq "comfort") {
@@ -298,12 +301,16 @@ MAX_Set($@)
} else { } else {
$temperature = MAX_ParseTemperature($args[0]); $temperature = MAX_ParseTemperature($args[0]);
} }
}
if(@args > 1 and ($args[1] eq "until") and ($ctrlmode == 1)) { if(@args > 1) {
$ctrlmode = 2; #temporary #@args == 3 and $args[1] == "until"
return "Second parameter must be 'until'" if($args[1] ne "until");
return "Not enough parameters: desiredTemperature <temp> [until <date> <time>]" if(@args == 3);
return "To many parameters: desiredTemperature <temp> [until <date> <time>]" if(@args > 4);
$ctrlmode = 2; #switch manual to temporary
$until = sprintf("%06x",MAX_DateTime2Internal($args[2]." ".$args[3])); $until = sprintf("%06x",MAX_DateTime2Internal($args[2]." ".$args[3]));
} }
}
my $payload = sprintf("%02x",int($temperature*2.0) | ($ctrlmode << 6)); my $payload = sprintf("%02x",int($temperature*2.0) | ($ctrlmode << 6));
$payload .= $until if(defined($until)); $payload .= $until if(defined($until));