PERL in notify mit mehreren FHEM-Befehlen

Begonnen von NeuFehm, 05 Januar 2016, 15:17:55

Vorheriges Thema - Nächstes Thema

NeuFehm

Ich bekomme es einfach nicht hin. :(

Sieht jemand gleich einen Fehler?
Relais1,2 ist für hoch und runter, hier zum Test mit Dummy-Lampen
t100 = Zeit zum vollständigen schließen


Rollo1.* {
my $Relais = "";
my $Relais1 = "Testlicht1";
my $Relais2 = "Testlicht2";
my $t100 = 10;
my $Status = ReadingsVal("Rollo1", "alterWert", 0);
my $Ziel = $EVENT;
my $Diff = ($Ziel-$Status);
my $AbsDiff = abs($Diff);
my $Laufzeit = $AbsDiff/100*$t100;
if ($Ziel == 100 || $Ziel == 0) {$Laufzeit=$t100}
if ($Diff < 0){
    $Relais = $Relais1;
    } else {
    $Relais = $Relais2;
    }
fhem "set $Relais on";
fhem "sleep $Laufzeit";
fhem "set $Relais off";
fhem "setreading Rollo1 alterWert $EVENT"
}
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

masterray57

Semikolon fehlt nach letztem Befehl. Gruss

NeuFehm

#2
Danke.... jetzt arbeitet schon mal was ;)
Allerdings nicht so, wie ich mag.
Ich vermute meine Befehle werden gleichzeitig ausgeführt,
und auch wieder nicht??? ;)
Hier der Eventmonitor mit meinen Kommentaren in Klammer
2016-01-05 15:33:36 ECMDDevice Testlicht2 on (richtig)
2016-01-05 15:33:38 ECMDDevice Testlicht2 off (sehr gut)
2016-01-05 15:33:38 dummy Rollo1 75 (der kommt zu spät)
2016-01-05 15:33:38 dummy Rollo1 alterWert: 75 (der richtig)
2016-01-05 15:33:38 ECMDDevice Testlicht2 on (das ist falsch)


Und hier nochmal die aktuelle Definition mit Semikolon ;)

Rollo1.* {
my $Relais = "";
my $Relais1 = "Testlicht1";
my $Relais2 = "Testlicht2";
my $t100 = 10;
my $Status = ReadingsVal("Rollo1", "alterWert", 0);
my $Ziel = $EVENT;
my $Diff = ($Ziel-$Status);
my $AbsDiff = abs($Diff);
my $Laufzeit = $AbsDiff/100*$t100;
if ($Ziel == 100 || $Ziel == 0) {$Laufzeit=$t100}
if ($Diff < 0){
    $Relais = $Relais1;
    } else {
    $Relais = $Relais2;
    }
fhem "set $Relais on";
fhem "sleep $Laufzeit";
fhem "set $Relais off";
fhem "setreading Rollo1 alterWert $EVENT";
}


Hier noch ein Hinweis aus dem Log:
WARNING: sleep without additional commands is deprecated and blocks FHEM

Offensichtlich stimmt was mit dem sleep nicht?
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul

NeuFehm

Hurra, hier das funktionierende notify:
Rollo1.* {
my $Relais = "";
my $Relais1 = "Testlicht1";
my $Relais2 = "Testlicht2";
my $t100 = 10;
my $Status = ReadingsVal("Rollo1", "alterWert", 0);
my $Ziel = $EVENT;
my $Diff = ($Ziel-$Status);
my $AbsDiff = abs($Diff);
my $Laufzeit = $AbsDiff/100*$t100;
if ($Ziel == 100 || $Ziel == 0) {$Laufzeit=$t100}
if ($Diff < 0){
    $Relais = $Relais1;
    } else {
    $Relais = $Relais2;
    }
fhem "set $Relais on";
fhem "sleep $Laufzeit; set $Relais off";
fhem "setreading Rollo1 alterWert $EVENT";
}
Raspberry Pi B+
RS 485 Schnittstellen: DIGITUS DA-70157, LINKSPTITE RS485/GPIO Shield for Raspberry Pi
RS485 Geräte: Ultraschallsensor für Zisternenfüllstand (Eigenbau), 4x8 Relais-M-Mastermodule (Eigenbau), 6 T-Module (Schalter und 3 analoge Eingänge) (Eigenbau)
sonstige Hardware: 2 Relay Modul