mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-05-01 20:20:10 +00:00
MAX: check arguments to "fake"
git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@2610 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
18f6489c18
commit
2186e3a683
@ -334,10 +334,19 @@ MAX_Set($@)
|
||||
return ($hash->{IODev}{Send})->($hash->{IODev},"ShutterContactState",$dest,$state,"06",undef,undef,$hash->{addr});
|
||||
} elsif($hash->{type} eq "WallMountedThermostat") {
|
||||
return "Invalid number of arguments" if(@args != 3);
|
||||
my $desiredTemperature = $args[1];
|
||||
my $measuredTemperature = $args[2];
|
||||
|
||||
return "desiredTemperature is invalid" if($args[1] < 4.5 || $args[2] > 30.5);
|
||||
|
||||
$args[2] = 0 if($args[2] < 0); #Clamp temperature to minimum of 0 degree
|
||||
|
||||
#Encode into binary form
|
||||
my $arg2 = int(10*$args[2]);
|
||||
#First bit is 9th bit of temperature, rest is desiredTemperature
|
||||
my $arg1 = (($arg2&0x100)>>1) | (int(2*$args[1])&0x7F);
|
||||
$args2 &= 0xFF;
|
||||
|
||||
return ($hash->{IODev}{Send})->($hash->{IODev},"WallThermostatState",$dest,
|
||||
sprintf("%02x%02x",int($desiredTemperature*2),int($measuredTemperature*10)),"04",undef,undef,$hash->{addr});
|
||||
sprintf("%02x%02x",$arg1,$arg2),"04",undef,undef,$hash->{addr});
|
||||
} else {
|
||||
return "fake does not work for device type $hash->{type}";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user