WeekdayTimer erkennt Condition nicht richtig

Begonnen von Achim, 20 Januar 2016, 10:35:23

Vorheriges Thema - Nächstes Thema

Achim

Hallo,

ich habe das Problem, das seit dem Update am 08.01. eine Definition des Weekdaytimers bei mir nicht mehr richtig funktioniert. Auf meine erste Anfrage http://forum.fhem.de/index.php/topic,47055.msg387942.html#msg387942 gab es leider keine Antwort. Das Problem besteht aber trotz weiterer Updates des Moduls weiterhin.

Ich habe jetzt versucht den Fehler im Modul zu finden. Und ich denke das ich fündig geworden bin. Meine Definition:
define Rohrheizung_EinAus_WT2 WeekdayTimer Rohrheizung 07:30|on 09:30|off (Value("Urlaub") eq 0 && ($we || Value("Feiertag") eq 1))

Die Ursache kommt meines Erachtens aus dem Codeblock (Zeile 451+)my @t = split(/\|/, $element);
    my $anzahl = @t;
    if ( $anzahl >= 2 && $anzahl <= 3) {

Dort wird geprüft, wie viele "|" Zeichen in einem Teil der Definition enthalten sind. Bei 2 oder 3 "|" wird davon ausgegangen, das es ein Profil ist. Leider hat meine Condition ebenfalls durch die Oder-Bedingung auch 2 "|" und der Teil wird dann als Profil erkannt. Bei der Auswertung wird dann später festgestellt, das dies kein gültiges Profil ist. Ich weiß leider nicht, wie man dies im Programmcode besser abfragen kann.

Viele Grüße
Achim
1x RPi V1, COC, 6x FHT, 1x S300TH, 2x DS18B20, 1x KS300
1x Arduino Nano mit Firmata, 2x DS2423old, 4x DS18B20, HIH5030, verschiedene Ein/Ausgangsschaltungen am Arduino
Mysensors-Seriell Gateway, Si7021, BH1750, Relais

marvin78

Es könnte auch sein, dass die Ursache darin liegt, dass du einen Stringvergleich auf einen numerischen Wert machst und ihn auch nicht als String behandelst.

Dietmar63

Setze bitte mal vervose auf 5 - dann kannst du im log erkennen wieder "Parser" so zu parst.
Sollte verständlich sein.
Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

Achim

#3
Hallo Dietmar,

über "Verbose 5" bin ich erst auf den Fehler gekommen. Log habe ich in meiner Mail vergessen.
Zitat2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] 07:30|on  - trying to accept as a switchtime
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] 07:30|on - Anzahl 2
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] 07:30|on - accepted
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] 09:30|off  - trying to accept as a switchtime
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] 09:30|off - Anzahl 2
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] 09:30|off - accepted
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub")  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub")  - unbalanced brackets ():1
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq  - unbalanced brackets ():1
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0  - unbalanced brackets ():1
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 &&  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 &&  - unbalanced brackets ():1
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we  - unbalanced brackets ():2
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we ||  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we ||  - unbalanced brackets ():2
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag")  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag")  - unbalanced brackets ():2
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq  - trying to accept as a switchtime
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq  - unbalanced brackets ():2
2016.01.20 10:11:02 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1))  - trying to accept as a switchtime
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1)) - Anzahl 3
2016.01.20 10:11:02 4: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1)) - accepted
2016.01.20 10:11:03 1: [Rohrheizung_EinAus_WT2] invalid daylist in Rohrheizung_EinAus_WT2 <(Value("Urlaub") eq 0 && (
$we > use one of 012345678 or (so|mo|di|mi|do|fr|sa|$we|!$we)
2016.01.20 10:11:03 1: [Rohrheizung_EinAus_WT2] invalid daylist in Rohrheizung_EinAus_WT2 <(Value("Urlaub") eq 0 && (
$we > use one of 012345678 or (so|mo|di|mi|do|fr|sa|$we|!$we)
2016.01.20 10:11:03 1: [Rohrheizung_EinAus_WT2] invalid time <> HH:MM[:SS]
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:31:02 17:36:37 Mittwoch
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 0: Sonntag)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 1: Montag)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 2: Dienstag)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 3: Mittwoch)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 4: Donnerstag)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 5: Freitag)
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 6: Samstag)
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] removing Timer: Rohrheizung_EinAus_WT2_SetTimerOfDay
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] setting  Timer: Rohrheizung_EinAus_WT2_SetTimerOfDay 2016-01-21 00:00:05
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] device type FRM_OUT: recognized, setModifier:
2016.01.20 10:11:03 4: [Rohrheizung_EinAus_WT2] no switch in the yesterdays because of the devices type(Rohrheizung is not recognized as heating) - use attr switchInThePast
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}(0,1,2,3,4,5,6);;;;( 1 && (defined $days->{$wday}))}
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] result of condition:1
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}(0,1,2,3,4,5,6);;;;( 1 && (defined $days->{$wday}))}
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] result of condition:1
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}();;;;( 1 && (defined $days->{$wday}))}
2016.01.20 10:11:03 5: [Rohrheizung_EinAus_WT2] result of condition:

Die Zeile mit "Anzahl 3" kommt von mir, da habe ich eine weitere Logzeile
Zitatmy @t = split(/\|/, $element);
    my $anzahl = @t;
    Log3 $hash, 4, "[$name] $element - Anzahl $anzahl";
    if ( $anzahl >= 2 && $anzahl <= 3) {
      Log3 $hash, 4, "[$name] $element - accepted";
eingebaut.

Viele Grüße
Achim
1x RPi V1, COC, 6x FHT, 1x S300TH, 2x DS18B20, 1x KS300
1x Arduino Nano mit Firmata, 2x DS2423old, 4x DS18B20, HIH5030, verschiedene Ein/Ausgangsschaltungen am Arduino
Mysensors-Seriell Gateway, Si7021, BH1750, Relais

Dietmar63

Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

Dietmar63

ich habe noch keine endgültige Lösung für das Problem - denke nach.
Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

Dietmar63

vielleicht baue ich das if so um, dann sollte || kein Problem mehr sein:


    if ( ($anzahl == 2 || $anzahl == 3) && $t[0] gt "" && $t[1] gt "" ) {
      Log3 $hash, 4, "[$name] $element - accepted";
      push(@switchingtimes, $element);
    } else {
      Log3 $hash, 4, "[$name] $element - NOT accepted, must be command or condition";
      unshift @$a, @restoreElements;
      last;
    }
Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

Achim

Hallo Dietmar,

ich habe das mal testweise bei mir eingebaut. Die Condition wird jetzt erkannt. Allerdings taucht sie im Log am Ende (vorletzte Zeile) unter Condition nicht auf.
Zitat2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] removing Timer: Rohrheizung_EinAus_WT2_1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] removing Timer: Rohrheizung_EinAus_WT2_2
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] 07:30|on  - trying to accept as a switchtime
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30|on - Anzahl 2 -- 07:30 -.- on
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30|on - accepted
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] 09:30|off  - trying to accept as a switchtime
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 09:30|off - Anzahl 2 -- 09:30 -.- off
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 09:30|off - accepted
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub")  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub")  - unbalanced brackets ():1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq  - unbalanced brackets ():1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0  - unbalanced brackets ():1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 &&  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 &&  - unbalanced brackets ():1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we  - unbalanced brackets ():2
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we ||  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we ||  - unbalanced brackets ():2
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag")  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag")  - unbalanced brackets ():2
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq  - trying to accept as a switchtime
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq  - unbalanced brackets ():2
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1))  - trying to accept as a switchtime
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1)) - Anzahl 3 -- (Value("Urlaub") eq 0 && (
$we  -.-
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1)) - NOT accepted, must be command or condition
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:10 17:38:02 Donnerstag
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 0: Sonntag)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 1: Montag)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 2: Dienstag)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 3: Mittwoch)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 4: Donnerstag)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 5: Freitag)
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] 07:30:00 on, 09:30:00 off (Profil 6: Samstag)
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] removing Timer: Rohrheizung_EinAus_WT2_SetTimerOfDay
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] setting  Timer: Rohrheizung_EinAus_WT2_SetTimerOfDay 2016-01-22 00:00:05
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] device type FRM_OUT: recognized, setModifier:
2016.01.21 09:55:33 4: [Rohrheizung_EinAus_WT2] no switch in the yesterdays because of the devices type(Rohrheizung is not recognized as heating) - use attr switchInThePast
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}(0,1,2,3,4,5,6);;;;( 1 && (defined $days->{$wday}))}
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] result of condition:1
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}(0,1,2,3,4,5,6);;;;( 1 && (defined $days->{$wday}))}
2016.01.21 09:55:33 5: [Rohrheizung_EinAus_WT2] result of condition:1

Bei Ausführen zu der vorgegebenen Zeit kommt im Logfile ein Fehler. die Condition wird wohl nicht als Condition sondern als Command erkannt.
Zitat2016.01.21 10:05:00 5: [Rohrheizung_EinAus_WT2] delayedExecutionCond:0
2016.01.21 10:05:00 5: [Rohrheizung_EinAus_WT2] result of delayedExecutionCond:0
2016.01.21 10:05:00 5: [Rohrheizung_EinAus_WT2] list of window sensors found: 'Rohrheizung_EinAus_WT2'
2016.01.21 10:05:00 5: [Rohrheizung_EinAus_WT2] condition: {my $days={};;map{$days->{$_}=1}(0,1,2,3,4,5,6);;;;( 1 && (defined $days->{$wday}))}
2016.01.21 10:05:00 5: [Rohrheizung_EinAus_WT2] result of condition:1
2016.01.21 10:05:00 4: [Rohrheizung_EinAus_WT2] Update   - timer seems to be active today: 0123456|10:05|on
2016.01.21 10:05:00 4: [Rohrheizung_EinAus_WT2] device type FRM_OUT: recognized, setModifier:
2016.01.21 10:05:00 4: [Rohrheizung_EinAus_WT2] aktParam: newParam:on - is  not disabled
2016.01.21 10:05:00 4: [Rohrheizung_EinAus_WT2] command: (Value("Urlaub") eq 0 && (
$we || Value("Feiertag") eq 1)) executed
2016.01.21 10:05:00 3: Unknown command (Value("Urlaub"), try help.

Mit der Regular Expression in Ziele 164
Zitatm/^\(.*\)$/g)
muss ich allerdings passen.

Viele Grüße
Achim
1x RPi V1, COC, 6x FHT, 1x S300TH, 2x DS18B20, 1x KS300
1x Arduino Nano mit Firmata, 2x DS2423old, 4x DS18B20, HIH5030, verschiedene Ein/Ausgangsschaltungen am Arduino
Mysensors-Seriell Gateway, Si7021, BH1750, Relais

Achim

Hallo,

ich habe jetzt den Fehler aus dem letzten Posting gefunden. Da war noch ein Zeilenumbruch in meiner Condition. Die Änderung if ( ($anzahl == 2 || $anzahl == 3) && $t[0] gt "" && $t[1] gt "" ) { funktioniert bei mir. Zumindest ist bis jetzt bei den Tests kein weiteres Problem aufgetaucht.

Viele Grüße
Achim
1x RPi V1, COC, 6x FHT, 1x S300TH, 2x DS18B20, 1x KS300
1x Arduino Nano mit Firmata, 2x DS2423old, 4x DS18B20, HIH5030, verschiedene Ein/Ausgangsschaltungen am Arduino
Mysensors-Seriell Gateway, Si7021, BH1750, Relais

Dietmar63

Gruß Dietmar
FB7390, CUL, 2 FHT, FS20
modules: 98_WOL.pm, 98_Heating_Control.pm,   98_WeekdayTimer.pm, 98_RandomTimer.pm, 59_Twilight.pm

Achim

Hallo Dietmar,

vielen Dank.

Viele Grüße
Achim
1x RPi V1, COC, 6x FHT, 1x S300TH, 2x DS18B20, 1x KS300
1x Arduino Nano mit Firmata, 2x DS2423old, 4x DS18B20, HIH5030, verschiedene Ein/Ausgangsschaltungen am Arduino
Mysensors-Seriell Gateway, Si7021, BH1750, Relais