From e357833ec2d6581a3c406dfad7f7c09525b4d85f Mon Sep 17 00:00:00 2001 From: Wzut <> Date: Thu, 7 May 2020 16:51:40 +0000 Subject: [PATCH] 10_MAX.pm: remove Log3 line, update command.ref git-svn-id: https://svn.fhem.de/fhem/trunk@21891 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/10_MAX.pm | 281 +++++++++++++++++++++++--------------------- 1 file changed, 145 insertions(+), 136 deletions(-) diff --git a/fhem/FHEM/10_MAX.pm b/fhem/FHEM/10_MAX.pm index 22d6cfd88..494ca450b 100755 --- a/fhem/FHEM/10_MAX.pm +++ b/fhem/FHEM/10_MAX.pm @@ -32,7 +32,7 @@ use AttrTemplate; use Date::Parse; my %device_types = ( - 0 => "Cube", + 1 => "HeatingThermostat", 2 => "HeatingThermostatPlus", 3 => "WallMountedThermostat", @@ -40,7 +40,8 @@ my %device_types = ( 5 => "PushButton", 6 => "virtualShutterContact", 7 => "virtualThermostat", - 8 => "PlugAdapter", + 8 => "PlugAdapter" + ); my %msgId2Cmd = ( @@ -161,29 +162,29 @@ sub MAX_Initialize } ############################# -sub MAX_Define -{ - my $hash = shift; - my $def = shift; - my @arg = split("[ \t][ \t]*", $def); - my $name = $hash->{NAME}; - return 'name '.$name.' is reserved for internal use' if($name eq 'fakeWallThermostat' or $name eq 'fakeShutterContact'); - return 'wrong syntax: define MAX type address' if(int(@arg)!=4 || $arg[3] !~ m/^[a-fA-F0-9]{6}$/i); - return 'incorrect address 000000' if ($arg[3] eq '000000'); +sub MAX_Define { - my $type = $arg[2]; - my $addr = lc($arg[3]); #all addr should be lowercase + my $hash = shift; + my $def = shift; - if(exists($modules{MAX}{defptr}{$addr}) && $modules{MAX}{defptr}{$addr}->{NAME} ne $name) - { - my $msg = 'MAX_Define, a Device with addr '.$addr.' is already defined ('.$modules{MAX}{defptr}{$addr}->{NAME}.')'; - Log3 $hash, 2, $msg; - return $msg; - } + my ($name, undef, $type, $addr) = split(m{ \s+ }xms, $def, 4); - return $type." is not a valid MAX type !" if (!MAX_TypeToTypeId($type) && ($type ne 'Cube')); + return "name $name is reserved for internal use" if (($name eq 'fakeWallThermostat') || ($name eq 'fakeShutterContact')); + my $devtype = MAX_TypeToTypeId($type); + return "$name, invalid MAX type $type !" if (!$devtype); + return "$name, invalid address $addr !" if (($addr !~ m/^[a-fA-F0-9]{6}$/ix) || ($addr eq '000000')); + + $addr = lc($addr); # all addr should be lowercase + + + if (exists($modules{MAX}{defptr}{$addr}) && $modules{MAX}{defptr}{$addr}->{NAME} ne $name) { + my $msg = "MAX_Define, a MAX device with address $addr is already defined as ".$modules{MAX}{defptr}{$addr}->{NAME}; + Log3($name, 2, $msg); + return $msg; + } + my $old_addr = ''; # check if we have this address already in use @@ -196,51 +197,50 @@ sub MAX_Define if (($old_addr ne '') && ($old_addr ne $addr)){ my $msg1 = 'please dont change the address direct in DEF or RAW !'; my $msg2 = "If you want to change $old_addr please delete device $name first and create a new one"; - Log3($hash, 3, "$name, $msg1 $msg2"); + Log3($name, 3, "$name, $msg1 $msg2"); return $msg1."\n".$msg2; } if (exists($modules{MAX}{defptr}{$addr}) && $modules{MAX}{defptr}{$addr}->{type} ne $type) { my $msg = "$name, type changed from $modules{MAX}{defptr}{$addr}->{type} to $type !"; - Log3($hash, 2, $msg); + Log3($name, 2, $msg); } - Log3 $hash, 5, 'Max_define, '.$name.' '.$type.' with addr '.$addr; - $hash->{type} = $type; - $hash->{devtype} = MAX_TypeToTypeId($type); - $hash->{addr} = $addr; - $hash->{TimeSlot} = -1 if ($type =~ /.*Thermostat.*/); # wird durch CUL_MAX neu gesetzt - $hash->{'.count'} = 0; # ToDo Kommentar - $hash->{'.sendToAddr'} = '-1'; # zu wem haben wird direkt gesendet ? - $hash->{'.sendToName'} = ''; - $hash->{'.timer'} = 300; - $hash->{SVN} = (qw($Id$))[2]; - $modules{MAX}{defptr}{$addr} = $hash; + Log3 $hash, 5, 'Max_define, '.$name.' '.$type.' with addr '.$addr; - #$hash->{internals}{interfaces} = $interfaces{$type}; # wozu ? + $hash->{type} = $type; + $hash->{devtype} = $devtype; + $hash->{addr} = $addr; + $hash->{TimeSlot} = -1 if ($type =~ /.*Thermostat.*/); # wird durch CUL_MAX neu gesetzt + $hash->{'.count'} = 0; # ToDo Kommentar + $hash->{'.sendToAddr'} = '-1'; # zu wem haben wird direkt gesendet ? + $hash->{'.sendToName'} = ''; + $hash->{'.timer'} = 300; + $hash->{SVN} = (qw($Id$))[2]; + $modules{MAX}{defptr}{$addr} = $hash; - AssignIoPort($hash); + #$hash->{internals}{interfaces} = $interfaces{$type}; # wozu ? - CommandAttr(undef,$name.' model '.$type); # Forum Stats werten nur attr model aus + AssignIoPort($hash); - if ($init_done == 1) - { + CommandAttr(undef,$name.' model '.$type); # Forum Stats werten nur attr model aus + + if ($init_done == 1) { #nur beim ersten define setzen: - if ((($hash->{devtype} > 0) && ($hash->{devtype} < 4)) || ($hash->{devtype} == 7)) - { - $attr{$name}{room} = "MAX" if( not defined( $attr{$name}{room} ) ); - MAX_ReadingsVal($hash,'groupid'); - MAX_ReadingsVal($hash,'windowOpenTemperature') if ($hash->{devtype} == 7); - readingsBeginUpdate($hash); - MAX_ParseWeekProfile($hash); - readingsEndUpdate($hash,0); + if (($hash->{devtype} < 4) || ($hash->{devtype} == 7)) { + $attr{$name}{room} = 'MAX' if( not defined( $attr{$name}{room} ) ); + MAX_ReadingsVal($hash,'groupid'); + MAX_ReadingsVal($hash,'windowOpenTemperature') if ($hash->{devtype} == 7); + readingsBeginUpdate($hash); + MAX_ParseWeekProfile($hash); + readingsEndUpdate($hash,0); + } } - } - RemoveInternalTimer($hash); - InternalTimer(gettimeofday()+5, "MAX_Timer", $hash, 0) if ($hash->{devtype} != 5); + RemoveInternalTimer($hash); + InternalTimer(gettimeofday()+5, 'MAX_Timer', $hash, 0) if ($hash->{devtype} != 5); - return; + return; } @@ -371,10 +371,10 @@ sub MAX_Undef sub MAX_TypeToTypeId { - my $id = shift; - foreach (keys %device_types) + my $type = shift; + foreach my $id (keys %device_types) { - return $_ if($id eq $device_types{$_}); + return $id if ($type eq $device_types{$id}); } return 0; } @@ -1167,6 +1167,7 @@ sub MAX_Set($@) foreach (keys %{$modules{MAX}{defptr}}) { next if (!$modules{MAX}{defptr}{$_}->{NAME}); + next if (!defined($modules{MAX}{defptr}{$_}->{devtype})); if ( ($modules{MAX}{defptr}{$_}->{devtype} > 0) # 1 - 4 && ($modules{MAX}{defptr}{$_}->{devtype} != 5) && !IsDummy ($modules{MAX}{defptr}{$_}->{NAME}) @@ -1186,6 +1187,7 @@ sub MAX_Set($@) foreach (keys %{$modules{MAX}{defptr}}) { next if (!$modules{MAX}{defptr}{$_}->{NAME}); + next if (!defined($modules{MAX}{defptr}{$_}->{devtype})); if ( ($modules{MAX}{defptr}{$_}->{devtype} > 0) # 1,2,4 && ($modules{MAX}{defptr}{$_}->{devtype} != 5) && ($modules{MAX}{defptr}{$_}->{devtype} != 3) @@ -1202,6 +1204,7 @@ sub MAX_Set($@) foreach ( keys %{$modules{MAX}{defptr}} ) { next if (!$modules{MAX}{defptr}{$_}->{NAME}); + next if (!defined($modules{MAX}{defptr}{$_}->{devtype})); if ( ($modules{MAX}{defptr}{$_}->{devtype} > 0) # 1 - 3 && ($modules{MAX}{defptr}{$_}->{devtype} < 4) && !IsDummy ($modules{MAX}{defptr}{$_}->{NAME}) @@ -1770,7 +1773,7 @@ sub MAX_Parse readingsBulkUpdate($shash, "maximumTemperature", MAX_SerializeTemperature($args[2])); readingsBulkUpdate($shash, "minimumTemperature", MAX_SerializeTemperature($args[3])); readingsBulkUpdate($shash, ".weekProfile", $args[4]); - Log3 $shash,1,$msgtype.' : '.$args[4]; + #Log3 $shash,1,$msgtype.' : '.$args[4]; readingsBulkUpdate($shash, 'lastcmd', $msgtype); if(@args > 5) @@ -2259,10 +2262,10 @@ sub MAX_today Set -
  • desiredTemperature [manual] <value> [until <date>]
    +
  • desiredTemperature [manual] <value> [until <date>]
    For devices of type HeatingThermostat only. <value> maybe one of