Script in Modul "umwandeln"

Begonnen von fhainz, 14 Dezember 2013, 12:43:23

Vorheriges Thema - Nächstes Thema

justme1968

ja wenn du per ssh oder telnet verbunden bist.

die zeile ist in dem start script.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

Alles klar. Jetzt hab ich es überissen ;)

Wenn ich fhem so starte bekomm ich gleich jede menge Fehlermeldungen
Useless use of private variable in void context at ./FHEM/33_readingsGroup.pm line 525, <> line 8.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in substitution (s///) at ./FHEM/01_FHEMWEB.pm line 1824.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Use of uninitialized value $name in hash element at ./FHEM/01_FHEMWEB.pm line 1826.
Undefined subroutine &main::currentCalculator_Get called at fhem.pl line 2636


Undefined subroutine kam direkt nachdem ich das define in der eingabezeile abgesetzt hab. Der rest gleich nach dem starten.
Eigenartig das der Fehler aussagt das ich keine currentCalculator_Get habe. Das hab ich ja mit $hash->{GetFn}   = "currentCalculator_Get"; definiert oder?

grüße

justme1968

du muss sie auch schreiben. nicht nur deklarieren.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

OK das hat jetzt geklappt aber nachdem die detail Seite angezeigt wurde hat sich fhem mit dem Fehler
ZitatCan't use string ("wzDeckenfluter") as a HASH ref while "strict refs" in use at ./FHEM/60_currentCalculator.pm line 96.
wieder aufgehängt ;)

Zeile 96:
$hash->{ON} = ReadingsVal( $hash->{DEVICE}, "on", "0" );

grüße

justme1968

du übergibst beim aufruf von currentCalculator_Berechnen nicht $hash sondern $hash->{DEVICE}. das ist falsch. jedenfalls dann wenn du in currentCalculator_Berechnen einen $hash erwartest...

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

Kannst du mir ein Beispiel schreiben wie es richtig ist?
Wie gesagt ist mein erstes Modul und eigentlich hab ich, durch mangel an developer einsteiger infos, keinen Plan was ich da mache ;)

grüße

justme1968

versuch es mal nur mit $hash. aber es ist dein modul und ich kann nicht in deinen kopf schauen. es gibt kein einziges richtig sonder sehr viele möglichkeiten.


gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

justme1968

vielleicht allgemein: es ist wichtig das du dein device (meistens $hash) und das device an das du dich dran hängst nicht durcheinander bringst.

du willst in fast allen routinen dein device übergeben und da einen link zum device das überwacht werden soll drine haben.

gruss
   andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

Sry ich versteh's nicht.
Ich weiß nicht mal was was dieses $hash ist bzw. was es macht oder wie bzw. wann ich es einsetze

Soll ich anstatt $hash->{} "normale" variablen verwenden so wie in dem script das ich in der 99_myUtils.pm hatte?

#-------------------------     Stromverbrauch nach Laufzeit ermitteln     ---------------#
#-----     Stromverbrauch -----#

sub stromverbrauch($$) {
my $device           = shift;
my $watt             = shift;
my $on               = "";
my $off              = 0;
my $onLast           = 0;
my $consumptionLast  = 0;
my $onTotal          = 0;
my $consumptionTotal = 0;

#----- Untoggle Fix-----#
if ( Value($device) eq "toggle" ) {
if ( OldValue($device) eq "off" ) {
fhem("set $device on");
}
else {
fhem("set $device off");
}
}

if ( Value($device) eq "on" ) {
$on = int( time() );

setReading( $device, "on", $on );
setReading( $device, "power", $watt );
}
elsif ( Value($device) eq "off" ) {
stromverbrauchBerechnen( $device, $watt );
}
else {
Log3 $device, 3, "Untoggle Problem";
}
}

#-----     Stromverbrauch berechnen     -----#
sub stromverbrauchBerechnen($$) {
$device = shift;
$watt   = shift;

$on = ReadingsVal( $device, "on", "0" );
$off = int( time() );

$onLast = $off - $on;

$onTotal          = ReadingsVal( $device, "onTotal",          "0" );
$consumptionTotal = ReadingsVal( $device, "consumptionTotal", "" );
$onTotal          = int( $onTotal + $onLast );

$consumptionLast  = $onLast * $watt / 1000 / 3600;
$consumptionTotal = $consumptionTotal + $consumptionLast;

$consumptionTotal = sprintf "%.2f", $consumptionTotal;

if ( $on > 0 ) {
setReading( $device, "on",               0 );
setReading( $device, "off",              $off );
setReading( $device, "onLast",           $onLast );
setReading( $device, "onTotal",          $onTotal );
setReading( $device, "power",            "0" );
setReading( $device, "consumptionTotal", $consumptionTotal );
}
else {
Log3 $device, 3, "Keine Startzeit ermittelt";
}
}

#-----     setReading     -----#
sub setReading($$$) {
my $device       = shift;
my $readingsName = shift;
my $readingsWert = shift;

readingsBeginUpdate( $main::defs{$device} );
readingsBulkUpdate( $main::defs{$device}, $readingsName, $readingsWert );
readingsBulkUpdate( $main::defs{$device}, $readingsName, $readingsWert );
readingsEndUpdate( $main::defs{$device}, 1 );
}


Grüße


fhainz

Ich hab jetzt das Modul nochmals umgebaut und es funktioniert schon so halbwegs.
Mein Problem ist jetzt, dass das die currentCalculator_NotifyFn sich in einer endlosschleife andauernd aufruft.
Schaff ich es irgendwie das sich das notifyFn nur aufruft wenn das entsprechende device on ist und sich solang alle interval Sekunden wiederholt bis das device off ist?

Hier mein Code:
package main;

use strict;
use warnings;
use Time::HiRes qw(gettimeofday sleep);

sub currentCalculator_Initialize($) {
my ($hash) = @_;

$hash->{GetFn}   = "currentCalculator_Get";
$hash->{SetFn}   = "currentCalculator_Set";
$hash->{DefFn}   = "currentCalculator_Define";
$hash->{UndefFn} = "currentCalculator_Undefine";
$hash->{NotifyFn} = "currentCalculator_NotifyFn";
}

#####################################

sub currentCalculator_Define($$) {
my ( $hash, $def ) = @_;

my @a = split( "[ \t][ \t]*", $def );
return "Usage: define <name> currentCalculator [device] [watt] [invterval]"
if ( @a < 4 || @a > 5 );

my $name   = $a[0];
my $device = $a[2];
my $watt   = $a[3];

my $interval = 60;
$interval = $a[4] if ( $interval < 60 );

$hash->{NAME}     = $name;
$hash->{DEVICE}   = $device;
$hash->{STATE}    = "Active";
$hash->{INTERVAL} = $interval;
$hash->{WATT}     = $watt;
Log3 $name, 3, "cc: Zeile 38";
 
return undef;
}

sub currentCalculator_Set() {}
sub currentCalculator_Get() {}
sub currentCalculator_Undefine($) {
my ($hash) = @_;
RemoveInternalTimer($hash->{NAME});

return undef;
}

sub currentCalculator_NotifyFn($) {
my ($hash) = @_;
my $name   = $hash->{NAME};
my $device = $hash->{DEVICE};
my $watt = $hash->{WATT};

#----- Untoggle Fix-----#
if ( Value( $device ) eq "toggle" ) {
if ( OldValue( $device ) eq "off" ) {
fhem("set $device on");
}
else {
fhem("set $device off");
}
}
Log3 $name, 3, "cc: Zeile 67";

my $on = "";

if( Value($device) eq "on" ) {
$on = int( time() );
Log3 $name, 3, "cc: Zeile 73";
setReading( $device, "on",    $on );
setReading( $device, "power", $watt );
Log3 $name, 3, "cc: Zeile 76";
}
elsif ( Value($device) eq "off" ) {
currentCalculator_Berechnen( $hash, $device, $watt );
}
else {
Log3 $name, 3, "Untoggle Problem";
}
Log3 $name, 3, "cc: Zeile 84";
return undef;

RemoveInternalTimer($hash->{NAME});
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "currentCalculator_NotifyFn",$hash, 0);
}

#-----     Stromverbrauch berechnen     -----#
sub currentCalculator_Berechnen($$$) {
my ($hash) = @_;
my $device = shift;
my $watt = shift;

Log3 $device, 3, "cc: Zeile 98";

my $on               = "";
my $off              = 0;
my $onLast           = 0;
my $consumptionLast  = 0;
my $onTotal          = 0;
my $consumptionTotal = 0;

$on = ReadingsVal( $device, "on", "0" );
$off = int( time() );

$onLast = $off - $on;

$onTotal          = ReadingsVal( $device, "onTotal",          "0" );
$consumptionTotal = ReadingsVal( $device, "consumptionTotal", "0" );
$onTotal          = int( $onTotal + $onLast );

$consumptionLast  = $onLast * $watt / 1000 / 3600;
$consumptionTotal = $consumptionTotal + $consumptionLast;

$consumptionTotal = sprintf "%.2f", $consumptionTotal;

Log3 $device, 3, "cc: Zeile 121";
Log3 $device, 3, "Device:".$device.", On:".$on.", Off:".$off;

if ( $on > 0 ) {
setReading( $device, "on",      0 );
setReading( $device, "off",     $off );
setReading( $device, "onLast",  $onLast );
setReading( $device, "onTotal", $onTotal );
setReading( $device, "power",   "0" );
setReading( $device, "consumptionTotal", $consumptionTotal );
}
else {
Log3 $device, 3, "Keine Startzeit ermittelt";
}
Log3 $device, 3, "cc: Zeile 134";
}

#-----     setReading     -----#
sub setReading($$$) {
my $device       = shift;
my $readingsName = shift;
my $readingsWert = shift;

Log3 $device, 3, "cc: Zeile 143";
readingsBeginUpdate($main::defs{$device});
readingsBulkUpdate( $main::defs{$device}, $readingsName, $readingsWert );
readingsEndUpdate( $main::defs{$device}, 1 );
}

1;



Log:
2013.12.29 18:43:48.089 3: Device:HASH(0x21e21f8), On:0, Off:1388339028
2013.12.29 18:43:48.089 3: Keine Startzeit ermittelt
2013.12.29 18:43:48.090 3: cc: Zeile 134
2013.12.29 18:43:48.091 3: cc: Zeile 84
2013.12.29 18:43:48.484 3: cc: Zeile 67
2013.12.29 18:43:48.485 3: cc: Zeile 98
2013.12.29 18:43:48.488 3: cc: Zeile 121
2013.12.29 18:43:48.489 3: Device:HASH(0x21e21f8), On:0, Off:1388339028
2013.12.29 18:43:48.490 3: Keine Startzeit ermittelt
2013.12.29 18:43:48.491 3: cc: Zeile 134
2013.12.29 18:43:48.492 3: cc: Zeile 84
2013.12.29 18:43:48.883 3: cc: Zeile 67
2013.12.29 18:43:48.884 3: cc: Zeile 98
2013.12.29 18:43:48.887 3: cc: Zeile 121
2013.12.29 18:43:48.888 3: Device:HASH(0x21e21f8), On:0, Off:1388339028
2013.12.29 18:43:48.889 3: Keine Startzeit ermittelt
2013.12.29 18:43:48.890 3: cc: Zeile 134
2013.12.29 18:43:48.891 3: cc: Zeile 84
2013.12.29 18:43:55.097 3: cc: Zeile 67
2013.12.29 18:43:55.098 3: cc: Zeile 98
2013.12.29 18:43:55.101 3: cc: Zeile 121



Grüße

justme1968

du solltest für notify und für den timer zwei unterschiedliche funktionen verwenden. und am besten noch eine update funktion die die werte aktualisiert.


currentCalculator_NotifyFn nur um festzustellen ob dein device den zustand gewechselt hat und eine andere funktion die regelnässig aufgerufen wird solange dein device an ist. also sobald das überwachte device auf on geht die timer funktion ein mal aufrufen. in der timer funktion die update aufrufen und das RemoveInternalTimer / InternalTimer und wenn dein device auf off geht ein mal ein RemoveInternalTimer und update.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

ok ich hab jetzt noch eine Funktion run. Die Funktion setzt die startzeit und ruft per timer die berechnen() auf, diese wiederum die setReading().
Leider immer noch in einer endlosschleife und nun wird auch $device nicht mehr an die Funktion setReading übergeben. :(

Code:
package main;

use strict;
use warnings;
use Time::HiRes qw(gettimeofday sleep);

sub currentCalculator_Initialize($) {
my ($hash) = @_;

$hash->{GetFn}   = "currentCalculator_Get";
$hash->{SetFn}   = "currentCalculator_Set";
$hash->{DefFn}   = "currentCalculator_Define";
$hash->{UndefFn} = "currentCalculator_Undefine";
$hash->{NotifyFn} = "currentCalculator_NotifyFn";
}

#####################################

sub currentCalculator_Define($$) {
my ( $hash, $def ) = @_;

my @a = split( "[ \t][ \t]*", $def );
return "Usage: define <name> currentCalculator [device] [watt] [invterval]"
if ( @a < 4 || @a > 5 );

my $name   = $a[0];
my $device = $a[2];
my $watt   = $a[3];

my $interval = 60;
$interval = $a[4] if ( $interval < 60 );

$hash->{NAME}     = $name;
$hash->{DEVICE}   = $device;
$hash->{STATE}    = "Active";
$hash->{INTERVAL} = $interval;
$hash->{WATT}     = $watt;
Log3 $name, 3, "cc: Zeile 38";
 
return undef;
}

sub currentCalculator_Set() {}
sub currentCalculator_Get() {}
sub currentCalculator_Undefine($) {
my ($hash) = @_;
RemoveInternalTimer($hash->{NAME});

return undef;
}

sub currentCalculator_NotifyFn($) {
my ($hash) = @_;
my $name   = $hash->{NAME};
my $device = $hash->{DEVICE};
my $watt = $hash->{WATT};

#----- Untoggle Fix-----#
if ( Value( $device ) eq "toggle" ) {
if ( OldValue( $device ) eq "off" ) {
fhem("set $device on");
}
else {
fhem("set $device off");
}
}

my $on = "";

if( Value($device) eq "on" ) {
currentCalculator_Run($hash,$device,$watt);
}
elsif ( Value($device) eq "off" ) {
currentCalculator_Berechnen( $hash, $device, $watt );
setReading( $device, "on", 0 );
RemoveInternalTimer($hash->{NAME});
}
else {
Log3 $name, 3, "Untoggle Problem";
}
return undef;
}

#-----     Stromverbrauch Startzeit setzen     -----#
sub currentCalculator_Run($$$){
my ($hash) = @_;
my $device = shift;
my $watt = shift;

my $on = int( time() );

setReading( $device, "on",    $on );
setReading( $device, "power", $watt );

currentCalculator_Berechnen($hash,$device,$watt);

RemoveInternalTimer($hash->{NAME});
InternalTimer(gettimeofday()+$hash->{INTERVAL}, "currentCalculator_Berechnen",$hash, 0);
}

#-----     Stromverbrauch berechnen     -----#
sub currentCalculator_Berechnen($$$) {
my ($hash) = @_;
my $device = shift;
my $watt = shift;

my $on               = "";
my $off              = 0;
my $onLast           = 0;
my $consumptionLast  = 0;
my $onTotal          = 0;
my $consumptionTotal = 0;

$on = ReadingsVal( $device, "on", "0" );
$off = int( time() );

$onLast = $off - $on;

$onTotal          = ReadingsVal( $device, "onTotal",          "0" );
$consumptionTotal = ReadingsVal( $device, "consumptionTotal", "0" );
$onTotal          = int( $onTotal + $onLast );

$consumptionLast  = $onLast * $watt / 1000 / 3600;
$consumptionTotal = $consumptionTotal + $consumptionLast;

$consumptionTotal = sprintf "%.2f", $consumptionTotal;

Log3 $device, 3, "Device:".$device.", On:".$on.", Off:".$off;

setReading( $device, "on",      $on );
setReading( $device, "off",     $off );
setReading( $device, "onLast",  $onLast );
setReading( $device, "onTotal", $onTotal );
setReading( $device, "power",   "0" );
setReading( $device, "consumptionTotal", $consumptionTotal );
}

#-----     setReading     -----#
sub setReading($$$) {
my $device       = shift;
my $readingsName = shift;
my $readingsWert = shift;

Log3 $device, 3, "cc: Zeile 143";
readingsBeginUpdate($main::defs{$device});
readingsBulkUpdate( $main::defs{$device}, $readingsName, $readingsWert );
readingsEndUpdate( $main::defs{$device}, 1 );
}

1;


Log:
2013.12.29 19:40:50.541 3: cc: Zeile 38
2013.12.29 19:40:59.913 3: Device:HASH(0x18b23e0), On:0, Off:1388342459
2013.12.29 19:40:59.914 3: cc: Zeile 143
2013.12.29 19:40:59.918 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.922 3: cc: Zeile 143
2013.12.29 19:40:59.926 1: readingsUpdate(,off,1388342459) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.929 3: cc: Zeile 143
2013.12.29 19:40:59.933 1: readingsUpdate(,onLast,1388342459) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.936 3: cc: Zeile 143
2013.12.29 19:40:59.939 1: readingsUpdate(,onTotal,1388342459) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.942 3: cc: Zeile 143
2013.12.29 19:40:59.945 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.948 3: cc: Zeile 143
2013.12.29 19:40:59.952 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:40:59.954 3: cc: Zeile 143
2013.12.29 19:41:00.139 3: Device:HASH(0x18b23e0), On:0, Off:1388342460
2013.12.29 19:41:00.140 3: cc: Zeile 143
2013.12.29 19:41:00.143 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.146 3: cc: Zeile 143
2013.12.29 19:41:00.150 1: readingsUpdate(,off,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.154 3: cc: Zeile 143
2013.12.29 19:41:00.158 1: readingsUpdate(,onLast,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.163 3: cc: Zeile 143
2013.12.29 19:41:00.167 1: readingsUpdate(,onTotal,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.171 3: cc: Zeile 143
2013.12.29 19:41:00.175 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.179 3: cc: Zeile 143
2013.12.29 19:41:00.183 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.187 3: cc: Zeile 143
2013.12.29 19:41:00.259 3: Device:HASH(0x18b23e0), On:0, Off:1388342460
2013.12.29 19:41:00.260 3: cc: Zeile 143
2013.12.29 19:41:00.263 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.267 3: cc: Zeile 143
2013.12.29 19:41:00.271 1: readingsUpdate(,off,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.274 3: cc: Zeile 143
2013.12.29 19:41:00.278 1: readingsUpdate(,onLast,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.281 3: cc: Zeile 143
2013.12.29 19:41:00.284 1: readingsUpdate(,onTotal,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.288 3: cc: Zeile 143
2013.12.29 19:41:00.292 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.295 3: cc: Zeile 143
2013.12.29 19:41:00.299 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.303 3: cc: Zeile 143
2013.12.29 19:41:00.382 3: Device:HASH(0x18b23e0), On:0, Off:1388342460
2013.12.29 19:41:00.383 3: cc: Zeile 143
2013.12.29 19:41:00.386 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.390 3: cc: Zeile 143
2013.12.29 19:41:00.393 1: readingsUpdate(,off,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.397 3: cc: Zeile 143
2013.12.29 19:41:00.400 1: readingsUpdate(,onLast,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.404 3: cc: Zeile 143
2013.12.29 19:41:00.408 1: readingsUpdate(,onTotal,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.411 3: cc: Zeile 143
2013.12.29 19:41:00.415 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.418 3: cc: Zeile 143
2013.12.29 19:41:00.422 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.426 3: cc: Zeile 143
2013.12.29 19:41:00.583 3: Device:HASH(0x18b23e0), On:0, Off:1388342460
2013.12.29 19:41:00.585 3: cc: Zeile 143
2013.12.29 19:41:00.588 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.591 3: cc: Zeile 143
2013.12.29 19:41:00.595 1: readingsUpdate(,off,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.598 3: cc: Zeile 143
2013.12.29 19:41:00.602 1: readingsUpdate(,onLast,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.605 3: cc: Zeile 143
2013.12.29 19:41:00.609 1: readingsUpdate(,onTotal,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.613 3: cc: Zeile 143
2013.12.29 19:41:00.616 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.620 3: cc: Zeile 143
2013.12.29 19:41:00.623 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.627 3: cc: Zeile 143
2013.12.29 19:41:00.694 3: Device:HASH(0x18b23e0), On:0, Off:1388342460
2013.12.29 19:41:00.695 3: cc: Zeile 143
2013.12.29 19:41:00.698 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.702 3: cc: Zeile 143
2013.12.29 19:41:00.705 1: readingsUpdate(,off,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.709 3: cc: Zeile 143
2013.12.29 19:41:00.713 1: readingsUpdate(,onLast,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.716 3: cc: Zeile 143
2013.12.29 19:41:00.720 1: readingsUpdate(,onTotal,1388342460) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.723 3: cc: Zeile 143
2013.12.29 19:41:00.727 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.731 3: cc: Zeile 143
2013.12.29 19:41:00.734 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:00.738 3: cc: Zeile 143
2013.12.29 19:41:03.419 3: Device:HASH(0x18b23e0), On:0, Off:1388342463
2013.12.29 19:41:03.420 3: cc: Zeile 143
2013.12.29 19:41:03.424 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.427 3: cc: Zeile 143
2013.12.29 19:41:03.430 1: readingsUpdate(,off,1388342463) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.434 3: cc: Zeile 143
2013.12.29 19:41:03.436 1: readingsUpdate(,onLast,1388342463) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.439 3: cc: Zeile 143
2013.12.29 19:41:03.442 1: readingsUpdate(,onTotal,1388342463) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.444 3: cc: Zeile 143
2013.12.29 19:41:03.447 1: readingsUpdate(,power,0) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.450 3: cc: Zeile 143
2013.12.29 19:41:03.453 1: readingsUpdate(,consumptionTotal,0.00) missed to call readingsBeginUpdate first.
2013.12.29 19:41:03.455 3: cc: Zeile 143
2013.12.29 19:41:03.627 3: Device:HASH(0x18b23e0), On:0, Off:1388342463
2013.12.29 19:41:03.628 3: cc: Zeile 143
2013.12.29 19:41:03.632 1: readingsUpdate(,on,0) missed to call readingsBeginUpdate first.


Ich raff es nicht...  :(

Grüße

justme1968

die NotifyFn wird für jedes event in fhem aufgerufen.

du darfst nur darauf reagieren wenn es auch dein device betrifft. und nur auf on und off und delete.

sonst hat du ein run für wirklich jedes event das in fhem passiert getriggert.

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968

fhainz

Zitat von: justme1968 am 29 Dezember 2013, 19:59:16
du darfst nur darauf reagieren wenn es auch dein device betrifft. und nur auf on und off und delete.

ich hab mir jetzt ein paar module mit einer notifyfn angesehen. Meinst du sowas wie
return if($dev->{NAME} eq $name);
in deiner readingsGroup.pm?

Ich komm nicht drauf..


Grüße

justme1968

so ähnlich aber das alleine reicht nicht. das ignoriert nur notifys die für den currentCalculator. du willst aber alles ignorieren bis auf die notifys für das device an dem der currentCalculator hängt. also eher so:return if($dev->{NAME} ne $hash->{DEVICE});

gruss
  andre
hue, tradfri, alexa-fhem, homebridge-fhem, LightScene, readingsGroup, ...

https://github.com/sponsors/justme-1968