Modul funktioniert aber blockiert fhem beim Start

Begonnen von Sailor, 17 September 2017, 20:57:23

Vorheriges Thema - Nächstes Thema

Sailor

Ein nicht mehr ganz so herzerfrischendes "Moin" vom "hintern Deich" vorweg

Ich bin absolut ratlos was hier läuft bzw. falsch läuft.

Ich habe mir ein Modul (73_UpsPico.pm) geschrieben, welches die Werte der RasPi-UPS von pimodules per ssh auslesen soll.

Das Modul funktionert tadellos nachdem man es im bereits laufendem fhem - Betrieb definiert.
Der Witz: Sobald man einen Neustart von fhem durchführt kommt fhem nur bis zu dem Punkt, bis scheinbar das Modul versucht zu laden.
Kein FhemWEB, keine weiteren Module ... Null Komma Nix.

Das Schlimmst an allem: Trotz verbose = 5 im entsprechenden Modul, gibts keine Fehlermeldungen im Log.  :o

Ich bin mit meinem Latein am Ende!  :(

Wenn es nicht allzu viel verlangt ist, könnte sich mal einer das Modul anschauen und mir einen Tipp geben, was ich da verbockt habe?

Gruss
    Sailor
                der sich jetzt lieber den rest vom Tatort anschaut.
******************************
Man wird immer besser...

viegener

Ich vermute mal, dass der Hänger nichtz beim Laden kommt, sondern eigentlich beim define?
Denn normalerweise würde fhem genau da das Modul laden.

Ich habe mir den define mal angeschaut. Wenn Du nicht weiter kommst, würde ich einfach dasmeiste vom define in eine Routine auslagern, die erst nach einiger Zeit gestartet wird (genauso wie Du das mit dem checkConnection) machst. Am besten wäre es sogar damit zu warten, bis init_done (global) gesetzt.

Dann kannst Du das Stück für Stück ausschliessen. Ausserdem kannst Du den define ja auch mit Log-Meldungen pflastern bist Du den Schuldigen identifiziert hast.

Was ich mir an Deiner Stelle aber auch anschauen würde ist das Ändern von Readings (per readingssingleupdate) direkt im define.


Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

Thorsten Pferdekaemper

Hi,
ich habe da auch das ReadinsSingleUpdate unter Verdacht. Mach das mal raus und probier, ob's dann geht.
Bei mir gab es auch noch an anderen Stellen Probleme mit Updates von Readings, so dass ich das in "meinem" Modul jetzt prinzipiell asynchron mache.
Z.B. steht bei mir in der Define-Funktion:

HM485_ReadingUpdate($hash, 'configStatus', 'PENDING');

...was so definiert ist:

sub HM485_ReadingUpdate($$$) {
my ($hash, $name, $value) = @_;

    if($name){  # do it later
InternalTimer(gettimeofday(),'HM485_ReadingUpdate',[$hash,$name, $value],0);
}else{ # this is the "later" call
    ($hash, $name, $value) = @$hash;
readingsSingleUpdate($hash, $name, $value, 1);
}
}

D.h. bei einem normalen Aufruf verschiebt sich die Funktion sozusagen selbst um 0 Sekunden in die Zukunft.
Gruß,
   Thorsten
FUIP

rudolfkoenig

Ich wuerde FHEM mit attr global verbose 5 starten, und schauen, was als Letztes kommt.
Wenn es an readingsSingleUpdate liegt, dann ist ein notify/DOIF/etc, der fuer den Haenger zustaendig ist, und das wuerde man im Log sehen.

Thorsten Pferdekaemper

...also mein Favorit für solche Sachen ist perldebug, auch wenn Rudi keine Debugger mag.
Gruß,
   Thorsten
FUIP

Sailor

Moin zusammen

OK, habe fhem jetzt mit verbose = 5 gestartet.

Dabei habe ich festgestellt, dass nach dem Laden des Moduls 73_UpsPico.pm, fhem ausschliesslich dieses Modul abarbeitet.
Der UPS wird fleissig im vorgegebenen Takt abgerufen.

Irgendwie habe ich es geschafft, dass dieses Modul fhem während des Startups komplett für sich beansprucht und kein weiteres nachladen weiterer Module erlaubt.
Daher werden die FhemWeb - Module auch nicht geladen mit denen ich noch Zugang zu fhem hätte kriegen können.

Aus diesem Grunde muss das Problem in dem Code bis zu diesem Punkt liegen


package main;

use strict;
use warnings;

use Net::SSH::Perl;
use Data::Dumper qw(Dumper);
use Math::Expression::Evaluator;

use constant false => 0;
use constant true  => 1;

sub UpsPico_Define($$);
sub UpsPico_Undefine($$);

###START###### Initialize module ##############################################################################START####
sub UpsPico_Initialize($)
{
    my ($hash)  = @_;

    $hash->{STATE}           = "Init";
    $hash->{DefFn}           = "UpsPico_Define";
    $hash->{UndefFn}         = "UpsPico_Undefine";
    $hash->{SetFn}           = "UpsPico_Set";
    $hash->{GetFn}           = "UpsPico_Get";
    $hash->{AttrFn}          = "UpsPico_Attr";
$hash->{DbLog_splitFn}   = "UpsPico_DbLog_splitFn";

    $hash->{AttrList}        = "do_not_notify:1,0 " .
   "header " .
   "Port " .
   "WriteCritical:0,1 " .
   "disable:1,0 " .
       "loglevel:0,1,2,3,4,5 " .
       "PollingIntervalAllData " .
       $readingFnAttributes;
}
####END####### Initialize module ###############################################################################END#####


###START######  Activate module after module has been used via fhem command "define" ##########################START####
sub UpsPico_Define($$)
{
my ($hash, $def)            = @_;
my @a = split("[ \t][ \t]*", $def);
my $name = $a[0];
#$a[1] just contains the "UpsPico" module name and we already know that! :-)
my $url = $a[2];
my $RemotePiUser = $a[3];
my $RemotePiPass = $a[4];

$hash->{NAME} = $name;
$hash->{STATE}              = "define";

Log3 $name, 4, $name. " : UpsPico - Starting to define module";

###START###### Reset fullResponse error message ############################################################START####
readingsSingleUpdate( $hash, "fullResponse", "Initialising...", 1);
####END####### Reset fullResponse error message #############################################################END#####

### Stop the current timer if one exists errornous
RemoveInternalTimer($hash);
Log3 $name, 4, $name. " : UpsPico - InternalTimer has been removed.";

    ###START### Check whether all variables are available #####################################################START####
if (int(@a) == 5)
{
###START### Check whether IPv4 address is valid
if ($url =~ m/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/)
{
Log3 $name, 4, $name. " : UpsPico - IPv4-address is valid                  : " . $url;
}
else
{
return $name .": Error - IPv4 address is not valid \n Please use \"define <devicename> UpsPico <IPv4-address> <interval/[s]> <GatewayPassword> <PrivatePassword>\" instead";
}
####END#### Check whether IPv4 address is valid
}
else
{
    return $name .": UpsPico - Error - Not enough parameter provided." . "\n" . "Gateway IPv4 address, Gateway and Private Passwords must be provided" ."\n". "Please use \"define <devicename> UpsPico <IPv4-address> <GatewayPassword> <PrivatePassword>\" instead";
}
####END#### Check whether all variables are available ######################################################END#####
 
###START###### Provide basic Information for all register #################################################START####
my %RegisterInfo;

$RegisterInfo{"mode"}            = {RegisterBlockName => "Status",  RegisterAddress => 0x00, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x01 => "RPI_MODE", 0x02 => "BAT_MODE", Default => "ERROR"} };
$RegisterInfo{"batlevel"}        = {RegisterBlockName => "Status",  RegisterAddress => 0x08, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"rpilevel"}        = {RegisterBlockName => "Status",  RegisterAddress => 0x0a, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"eprlevel"}        = {RegisterBlockName => "Status",  RegisterAddress => 0x0c, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"aEXT0level"}      = {RegisterBlockName => "Status",  RegisterAddress => 0x14, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"aEXT1level"}      = {RegisterBlockName => "Status",  RegisterAddress => 0x16, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"aEXT2level"}      = {RegisterBlockName => "Status",  RegisterAddress => 0x18, DataType => "WordBCD",  Writeable => false, Reset => false, Critical => false, Factor => 0.01,  Unit => "V",      SelectionList => undef };
$RegisterInfo{"key"}             = {RegisterBlockName => "Status",  RegisterAddress => 0x1a, DataType => "Byte",     Writeable => true,  Reset => true,  Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "No Key pressed", 0x01 => "Key A pressed", 0x02 => "Key B pressed", 0x03 => "Key C pressed", Default => "ERROR"} };
$RegisterInfo{"ntc"}             = {RegisterBlockName => "Status",  RegisterAddress => 0x1b, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "&deg;C", SelectionList => undef };
$RegisterInfo{"TO92"}            = {RegisterBlockName => "Status",  RegisterAddress => 0x1c, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "&deg;C", SelectionList => undef };
$RegisterInfo{"charger"}         = {RegisterBlockName => "Status",  RegisterAddress => 0x20, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Charger OFF", 0x01 => "Charging Batt", Default => "ERROR"} };
$RegisterInfo{"pico_is_running"} = {RegisterBlockName => "Status",  RegisterAddress => 0x22, DataType => "WordHex",  Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "ms",     SelectionList => undef };
$RegisterInfo{"pv"}              = {RegisterBlockName => "Status",  RegisterAddress => 0x24, DataType => "ASCII",    Writeable => false, Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => undef };
$RegisterInfo{"bv"}              = {RegisterBlockName => "Status",  RegisterAddress => 0x25, DataType => "ASCII",    Writeable => false, Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => undef };
$RegisterInfo{"fv"}              = {RegisterBlockName => "Status",  RegisterAddress => 0x26, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => undef };
$RegisterInfo{"RTC_seconds"}     = {RegisterBlockName => "RTC",     RegisterAddress => 0x00, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "s",      SelectionList => undef };
$RegisterInfo{"RTC_minutes"}     = {RegisterBlockName => "RTC",     RegisterAddress => 0x01, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "min",    SelectionList => undef };
$RegisterInfo{"RTC_hours"}       = {RegisterBlockName => "RTC",     RegisterAddress => 0x02, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => "h",      SelectionList => undef };
$RegisterInfo{"RTC_wday"}        = {RegisterBlockName => "RTC",     RegisterAddress => 0x03, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => " ",      SelectionList => undef };
$RegisterInfo{"RTC_mday"}        = {RegisterBlockName => "RTC",     RegisterAddress => 0x04, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => " ",      SelectionList => undef };
$RegisterInfo{"RTC_month"}       = {RegisterBlockName => "RTC",     RegisterAddress => 0x05, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => " ",      SelectionList => undef };
$RegisterInfo{"RTC_year"}        = {RegisterBlockName => "RTC",     RegisterAddress => 0x06, DataType => "Byte",     Writeable => false, Reset => false, Critical => false, Factor => 1.00,  Unit => " ",      SelectionList => undef };
$RegisterInfo{"pico_state"}      = {RegisterBlockName => "Command", RegisterAddress => 0x00, DataType => "Byte",     Writeable => true,  Reset => false, Critical => true,  Factor => undef, Unit => undef,    SelectionList => {0x00 => "OK", 0x80 => "OK", 0xcc => "Shutdown", 0xdd => "Factory Reset", 0xee => "CPU Reset", 0xff => "Bootloader", 0xa0 => "DEFAULT", 0xa1 => "NO_RTC", 0xa2 => "ALTERNATE", Default => "ERROR"}};
$RegisterInfo{"bat_run_time"}    = {RegisterBlockName => "Command", RegisterAddress => 0x01, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "s",      SelectionList => {0xff => "BattLive", Default => "Function: 60+RegisterValue*60"} };
$RegisterInfo{"rs232_rate"}      = {RegisterBlockName => "Command", RegisterAddress => 0x02, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Disabled", 0x01 => "4800bps", 0x02 => "9600bps", 0x03 => "19200bps", 0x04 => "34600bps", 0x05 => "57600bps", 0x0f => "115200bps",Default => "ERROR"} };
$RegisterInfo{"STA_timer"}       = {RegisterBlockName => "Command", RegisterAddress => 0x05, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "s",      SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
$RegisterInfo{"enable5V"}        = {RegisterBlockName => "Command", RegisterAddress => 0x06, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Disabled", 0x01 => "Enabled", Default => "ERROR"} };
$RegisterInfo{"battype"}         = {RegisterBlockName => "Command", RegisterAddress => 0x07, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x46 => "LiFePO4 - F", 0x51 => "LiFePO4 - Q", 0x53 => "LiPO - S", 0x50 => "LiPO - P", Default => "ERROR"} };
$RegisterInfo{"setA_D"}          = {RegisterBlockName => "Command", RegisterAddress => 0x08, DataType => "Byte",     Writeable => true,  Reset => false, Critical => true,  Factor => undef, Unit => undef,    SelectionList => {0x00 => "AEXT1: 05.2V; AEXT2: 05.2V;", 0x01 => "AEXT1: 05.2V; AEXT2: 10.0V;", 0x02 => "AEXT1: 05.2V; AEXT2: 20.0V;", 0x03 => "AEXT1: 05.2V; AEXT2: 30.0V;", 0x10 => "AEXT1: 10.0V; AEXT2: 05.2V;", 0x11 => "AEXT1: 10.0V; AEXT2: 10.0V;", 0x12 => "AEXT1: 10.0V; AEXT2: 20.0V;", 0x13 => "AEXT1: 10.0V; AEXT2: 30.0V;", 0x20 => "AEXT1: 20.0V; AEXT2: 05.2V;", 0x21 => "AEXT1: 20.0V; AEXT2: 10.0V;", 0x22 => "AEXT1: 20.0V; AEXT2: 20.0V;", 0x23 => "AEXT1: 20.0V; AEXT2: 30.0V;", 0x30 => "AEXT1: 30.0V; AEXT2: 05.2V;", 0x31 => "AEXT1: 30.0V; AEXT2: 10.0V;", 0x32 => "AEXT1: 30.0V; AEXT2: 20.0V;", 0x33 => "AEXT1: 30.0V; AEXT2: 30.0V;", Default => "ERROR"} };
$RegisterInfo{"User_LED_Orange"} = {RegisterBlockName => "Command", RegisterAddress => 0x09, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "OFF", 0x01 => "ON", Default => "ERROR"} };
$RegisterInfo{"User_LED_Green"}  = {RegisterBlockName => "Command", RegisterAddress => 0x0a, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "OFF", 0x01 => "ON", Default => "ERROR"} };
$RegisterInfo{"User_LED_Blue"}   = {RegisterBlockName => "Command", RegisterAddress => 0x0b, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "OFF", 0x01 => "ON", Default => "ERROR"} };
$RegisterInfo{"brelay"}          = {RegisterBlockName => "Command", RegisterAddress => 0x0c, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Reset", 0x01 => "Set", Default => "ERROR"} };
$RegisterInfo{"bmode"}           = {RegisterBlockName => "Command", RegisterAddress => 0x0d, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Disabled", 0x01 => "Enabled", Default => "ERROR"} };
$RegisterInfo{"bfreq"}           = {RegisterBlockName => "Command", RegisterAddress => 0x0e, DataType => "WordBCD",  Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "Hz",     SelectionList => undef };
$RegisterInfo{"bdur"}            = {RegisterBlockName => "Command", RegisterAddress => 0x10, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 10,    Unit => "ms",     SelectionList => undef };
$RegisterInfo{"fmode"}           = {RegisterBlockName => "Command", RegisterAddress => 0x11, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Disabled", 0x01 => "Enabled", 0x02 => "Auto", Default => "ERROR"} };
$RegisterInfo{"fspeed"}          = {RegisterBlockName => "Command", RegisterAddress => 0x12, DataType => "Hex",      Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "%",      SelectionList => undef };
$RegisterInfo{"fstat"}           = {RegisterBlockName => "Command", RegisterAddress => 0x13, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "OFF", 0x01 => "ON", Default => "ERROR"} };
$RegisterInfo{"fttemp"}          = {RegisterBlockName => "Command", RegisterAddress => 0x14, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "&deg;C", SelectionList => undef };
$RegisterInfo{"LED_OFF"}         = {RegisterBlockName => "Command", RegisterAddress => 0x15, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "All LEDs forced OFF", 0x01 => "All LED manual", Default => "ERROR"} };
$RegisterInfo{"STS_active"}      = {RegisterBlockName => "StartTS", RegisterAddress => 0x00, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => {0x00 => "Inactive", 0xff => "Active", Default => "ERROR"} };
$RegisterInfo{"STS_minute"}      = {RegisterBlockName => "StartTS", RegisterAddress => 0x01, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "min",    SelectionList => undef };
$RegisterInfo{"STS_hour"}        = {RegisterBlockName => "StartTS", RegisterAddress => 0x02, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "h",      SelectionList => undef };
$RegisterInfo{"STS_mday"}        = {RegisterBlockName => "StartTS", RegisterAddress => 0x03, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "d",    SelectionList => undef };
$RegisterInfo{"STS_month"}       = {RegisterBlockName => "StartTS", RegisterAddress => 0x04, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "m",    SelectionList => undef };
$RegisterInfo{"STS_year"}        = {RegisterBlockName => "StartTS", RegisterAddress => 0x05, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "y",    SelectionList => undef };
$RegisterInfo{"D_repetition"}    = {RegisterBlockName => "RunTS",   RegisterAddress => 0x00, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "d",      SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
$RegisterInfo{"H_repetition"}    = {RegisterBlockName => "RunTS",   RegisterAddress => 0x01, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "h",      SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
$RegisterInfo{"M_repetition"}    = {RegisterBlockName => "RunTS",   RegisterAddress => 0x02, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "min",    SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
$RegisterInfo{"H_duration"}      = {RegisterBlockName => "RunTS",   RegisterAddress => 0x03, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "h",      SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
$RegisterInfo{"M_duration"}      = {RegisterBlockName => "RunTS",   RegisterAddress => 0x04, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => 1.00,  Unit => "min",    SelectionList => {0xff => "Disabled", Default => "Function: RegisterValue"} };
# $RegisterInfo{"??????????"}      = {RegisterBlockName => "EventS",  RegisterAddress => 0x00, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => undef };
# $RegisterInfo{"??????????"}      = {RegisterBlockName => "ActionS", RegisterAddress => 0x00, DataType => "Byte",     Writeable => true,  Reset => false, Critical => false, Factor => undef, Unit => undef,    SelectionList => undef };
####END####### Provide basic Information for all register ##################################################END#####

###START###### Provide charging information for batteries #################################################START####
my %BattChargingInfo;
$BattChargingInfo{"LiFePO4 - F"} = {Volt0Percent => 2.9, Volt100Percent => 3.7};
$BattChargingInfo{"LiFePO4 - Q"} = {Volt0Percent => 2.9, Volt100Percent => 3.7};
$BattChargingInfo{"LiPO - S"}    = {Volt0Percent => 3.4, Volt100Percent => 4.3};
$BattChargingInfo{"LiPO - P"}    = {Volt0Percent => 3.4, Volt100Percent => 4.3};
####END####### Provide charging information for batteries ##################################################END#####

###START###### Writing values to global hash ##############################################################START####
$hash->{NAME} = $name;
$hash->{URL} = $url;
$hash->{temp}{FIRSTTIME} = true;
$hash->{temp}{RemotePiUser} = $RemotePiUser;
$hash->{temp}{RemotePiPass} = $RemotePiPass;
%{$hash->{temp}{RegisterInfo}} = %RegisterInfo;
%{$hash->{temp}{BattChargingInfo}}  = %BattChargingInfo;
####END####### Writing values to global hash ###############################################################END#####

###START###### For Debugging purpose only #################################################################START#### 
Log3 $name, 4, $name. " : UpsPico - Define Hash                            : "   . $hash;
Log3 $name, 4, $name. " : UpsPico - Define Def                             : "   . $def;
Log3 $name, 4, $name. " : UpsPico - Define Array                           : "   . @a;
Log3 $name, 4, $name. " : UpsPico - Define Name                            : "   . $name;
Log3 $name, 4, $name. " : UpsPico - Define Address                         : "   . $url;
Log3 $name, 5, $name. " : UpsPico ------------------------------------------------";
Log3 $name, 5, $name. " : UpsPico - RegisterInfo in fhem-hash              : \n" . Dumper \%$hash;
Log3 $name, 5, $name. " : UpsPico ------------------------------------------------";
####END####### For Debugging purpose only ##################################################################END#####

###Initiate the timer for first check of connection towards RasPi with UpsPico but wait 300s
InternalTimer(gettimeofday()+300, "UpsPico_CheckConnection", $hash, 1);

return undef;
}
####END####### Activate module after module has been used via fhem command "define" ############################END#####



Ich bin mir daher nicht sicher, ob "wait for init_done" daher helfen würde da das Modul ja weiterhin arbeitet. Nur eben der Rest von fhem nicht.
Nichts desto trotz, wie würde ich diese Abfrage am geschicktesten einsetzen?

Die fhem Log-Datei bis zum Zeitpunkt des Aufrufs des internen Timers habe ich angehängt.
Ab da funktioniert das Modul fleissig weiter aber der Rest von fhem nicht.

Danke

Gruss
    Sailor
******************************
Man wird immer besser...

viegener

Ich muss zugeben, dass ich mit den über 5000 Zeilen log-file nichts anfangen kann, aber wie ich sehe hast Du das ReadingsUpdate weiterhin drin, hast Du das ausprobiert?

Hört der Logfile denn an der letzten Zeile auf? Oder geht es weiter?
Wenn er da aufhört liegt vermutlich irgendwo eine Endlosschleife an anderer Stelle im Modul vor, denn am Ende vom define geht die Kontrolle an FHEM über und dann wird vermutlich etwas abgearbeitet mit endlosschleife.

Vielleiht ist ja die UPS-Abfrage die Endlosschleife
Für mich ist CheckConnection ein Kandidat, denn da sieht es nach Blockingcalls aus. Hier werden ja wieder internalTimer gesetzt.

Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

Sailor

#7
Halli viegener

Zitat von: viegener am 20 September 2017, 09:40:14
Ich muss zugeben, dass ich mit den über 5000 Zeilen log-file nichts anfangen kann, aber wie ich sehe hast Du das ReadingsUpdate weiterhin drin, hast Du das ausprobiert?

Hört der Logfile denn an der letzten Zeile auf? Oder geht es weiter?
Wenn er da aufhört liegt vermutlich irgendwo eine Endlosschleife an anderer Stelle im Modul vor, denn am Ende vom define geht die Kontrolle an FHEM über und dann wird vermutlich etwas abgearbeitet mit endlosschleife.

Vielleiht ist ja die UPS-Abfrage die Endlosschleife
Für mich ist CheckConnection ein Kandidat, denn da sieht es nach Blockingcalls aus. Hier werden ja wieder internalTimer gesetzt.

Touche, Hätte ich ein wenig besser kommentieren sollen.
Das meiste ist nur der normale fhem-Start.
Entscheidend sind nur die Zeilen ab Zeile 4809. Ab da wird das Modul geladen.

Danach kommen nur noch Log-Einträge des Moduls. Nichts mehr vom restlichen fhem.

Meinst du diese Zeile?
readingsSingleUpdate( $hash, "fullResponse", "Initialising...", 1)

Ich habe jetzt mal die Zeile InternalTimer(gettimeofday()+300, "UpsPico_CheckConnection", $hash, 1); auskommentiert.

Das bedeutet, das Modul dürfte nur die define durchlaufen und dann nichts mehr.
Und siehe da, fhem startet wieder ganz normal...

Was ich nicht verstehe ist die Tatsache, dass der InternalTimer erst noch 300s wartet bevor er in "CheckConnection" springt.
Aber bereits ab diesem Aufruf funktioniert es nicht mehr.

Und das auch nur beim startup.
Nach einem Define bei laufendem fhem funktioniert eben alles normal...

Gruss
   Sailor
******************************
Man wird immer besser...

Markus Bloch

Lies Dir hier mal bitte die Beschreibung zu dem letzten Parameter zu InternalTimer() durch: https://wiki.fhem.de/wiki/DevelopmentModuleAPI#InternalTimer

Den hast Du nämlich auf 1 gesetzt, wahrscheinlich ohne zu wissen, was er bedeutet.

Gruß
Markus
Developer für Module: YAMAHA_AVR, YAMAHA_BD, FB_CALLMONITOR, FB_CALLLIST, PRESENCE, Pushsafer, LGTV_IP12, version

aktives Mitglied des FHEM e.V. (Technik)

viegener

Guter Punkt, den hatte ich voll übersehen - das klingt nach einem Treffer versenkt ;)

Kein Support über PM - Anfragen gerne im Forum - Damit auch andere profitieren und helfen können

CoolTux

Diesen Fehler hatte ich versehentlich auch schon gemacht. Das blockiert in der Tat sehr. Allerdings ist dies nur wärend des defined blockierend.
Du musst nicht wissen wie es geht! Du musst nur wissen wo es steht, wie es geht.
Support me to buy new test hardware for development: https://www.paypal.com/paypalme/MOldenburg
My FHEM Git: https://git.cooltux.net/FHEM/
Das TuxNet Wiki:
https://www.cooltux.net

Markus Bloch

Zitat von: CoolTux am 20 September 2017, 12:08:08
Allerdings ist dies nur wärend des defined blockierend.
Während des defined wenn FHEM startet oder rereadcfg macht ($init_done == 0). Ansonsten funktioniert es normal ohne Blockierung.
Developer für Module: YAMAHA_AVR, YAMAHA_BD, FB_CALLMONITOR, FB_CALLLIST, PRESENCE, Pushsafer, LGTV_IP12, version

aktives Mitglied des FHEM e.V. (Technik)

Sailor

Moin zusammen!

Auhauerhauerha, das war es!!!!!
Wer lesen kann ist klar im Vorteil!

DANKE!!!!!!!!!!!!!!  :D

Ihr seid spitze! (Wie immer!)

Gruss
    Sailor
******************************
Man wird immer besser...