From 09d22b971ce1804d959dc8bf3652001a3db9c69d Mon Sep 17 00:00:00 2001 From: hapege <> Date: Wed, 2 Feb 2022 21:39:07 +0000 Subject: [PATCH] 70_ESCVP21net.pm: loglevel optimized, added standard port git-svn-id: https://svn.fhem.de/fhem/trunk@25620 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/70_ESCVP21net.pm | 50 ++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/fhem/FHEM/70_ESCVP21net.pm b/fhem/FHEM/70_ESCVP21net.pm index aa43966bc..220860d22 100755 --- a/fhem/FHEM/70_ESCVP21net.pm +++ b/fhem/FHEM/70_ESCVP21net.pm @@ -16,6 +16,9 @@ # adding debug attr # 1.01.03 rename to 70_ESCVP21net, clean up and prepare for fhem trunk # 1.01.04 small bug fix, DevIo log messages moved to loglevel 5 +# 1.01.05 socket log messages moved to loglevel 5 +# prevent DevIO from overwriting STATE ($hash->{devioNoSTATE} = 1) +# set port 3629 as default # # ######################################################################################## @@ -228,24 +231,38 @@ sub ESCVP21net_Define { my ($hash, $def) = @_; my @param = split('[ \t]+', $def); - if(int(@param) < 4) { - return "too few parameters: define ESCVP21net "; + if(int(@param) < 3) { + return "too few parameters: define ESCVP21net [] []"; } - + my $port = "3629"; + my $model = "default"; $hash->{NAME} = $param[0]; $hash->{IP_Address} = $param[2]; - $hash->{port} = $param[3]; - if (!$param[4]) { - $param[4] = "default"; + if ($param[3]){ + if ($param[3] =~ m/^\d+$/){ + # param3 is number + $port = $param[3]; + } + else{ + # param3 is not a number, so must be "model" + $model = $param[3]; + } } - $hash->{model} = $param[4]; - $hash->{DeviceName} = $param[2].":".$param[3]; + if ($param[4]) { + # 4 params given, last is model + $model = $param[4]; + } + $hash->{port} = $port; + $hash->{model} = $model; + $hash->{DeviceName} = $param[2].":".$port; return "Cannot define device. Please install perl modules $missingModul (e.g. sudo apt-get install libjson-perl or sudo cpan install JSON)." if ($missingModul); # prevent "reappeared" messages in loglevel 1 - $hash->{devioLoglevel} = 3; + $hash->{devioLoglevel} = 5; + # prevent DevIO from setting "STATE" at connect/disconnect + $hash->{devioNoSTATE} = 1; # subscribe only to notify from global and self $hash->{NOTIFYDEV} = "global,TYPE=ESCVP21net"; @@ -321,7 +338,7 @@ sub ESCVP21net_Notify($$) { my $next; if(IsDisabled($name)){ - main::Log3 $name, 5, "[$name]: Notify: $name is disabled by framework!"; + main::Log3 $name, 3, "[$name]: Notify: $name has been set to disabled!"; return; } @@ -629,7 +646,7 @@ sub ESCVP21net_Set { } if(IsDisabled($name)){ - main::Log3 $name, 5, "[$name]: Set: $name is disabled by framework!"; + main::Log3 $name, 3, "[$name]: Set: $name is disabled by framework!"; return; } @@ -755,7 +772,7 @@ sub ESCVP21net_setValue($){ else { # calcResult will get nicer text from ESCVP21net_calcResult $result = ESCVP21net_calcResult($hash, $result, $cmd, $datakey, $volfactor); - main::Log3 $name, 5, "[$name]: result of $cmd is $result"; + main::Log3 $name, 3, "[$name]: result of $cmd is $result"; # constructing returnval string - triples separated by ":"; if ($returnval eq ""){ @@ -811,6 +828,7 @@ sub ESCVP21net_setValue($){ else { # we got neither "ERR" nor ":" but an interpretable value $result = ESCVP21net_calcResult($hash, $result, $cmd, $datakey, $volfactor); + main::Log3 $name, 3, "[$name]: result of $cmd is $result"; } $returnval = "$name|$cmd|$result"; } @@ -933,7 +951,7 @@ sub ESCVP21net_openSocket($){ Timout => 5 ); if (defined ($sock)){ - main::Log3 $name, 3, "[$name]: Socket opened to $remote on port $port"; + main::Log3 $name, 5, "[$name]: Socket opened to $remote on port $port"; } else{ main::Log3 $name, 3, "[$name]: NO socket opened to $remote on port $port"; @@ -963,7 +981,7 @@ sub ESCVP21net_initialize ($$) { $status = "init_ok"; } else{ - main::Log3 $name, 5, "[$name]: initializate gave wrong answer $result, expected $initans"; + main::Log3 $name, 3, "[$name]: initializate gave wrong answer $result, expected $initans"; $status = "init_error"; } } @@ -1148,7 +1166,7 @@ sub ESCVP21net_restoreJson { Define
    - define <name> ESCVP21net <IP_Address> <port> <[model]> + define <name> ESCVP21net <IP_Address> <[port]> <[model]>

    This module controls Epson Seiko Devices via TCP, using VP.net and ESC/VP21 commands.
    For the time being, only Epson initilization is implemented (needs a special initialization string "ESC/VP.net"). @@ -1156,7 +1174,7 @@ sub ESCVP21net_restoreJson {
    • IP_Address - the IP Address of the projector
    • -
    • port - ... guess? Yes, the port (Epson standard is 3629) +
    • port - ... guess? Yes, the port. If not given, Epson standard port 3629 is used.
    • model - defines your type of projector. It is used for loading a suitable pre-defined command set.
      No parameter or default will provide you with a limit "set" (PWR, MUTE, LMP, KEY, GetAll).