Ankündigung

Einklappen
Keine Ankündigung bisher.

Rule mag nicht...

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

    Rule mag nicht...

    Hallo zusammen!

    Ich habe gerade versucht eine Rule mit einer Zeitschaltung zu machen, es gibt hier zur Treppenhausfunktion ja ein Muster.

    Ich habe mich auch daran gehalten, nur leider geht es nicht.

    Sieht hier wer den Fehler?

    Danke im Voraus...


    rule"Test"
    when
    ItemLight_EG_Buero received command
    then
    if(receivedCommand==ON) {
    if(timer==null) {
    // first ON command, so create a timer to turn the light off again
    timer = createTimer(now.plusSeconds(10)) [sendCommand(Light_EG_Buero, OFF)
    ]
    } else {
    // subsequent ON command, so reschedule the existing timer
    timer.reschedule(now.plusSeconds(10))
    }
    } elseif(receivedCommand==OFF) {
    // remove any previously scheduled timer
    if(timer!=null) {
    timer.cancel
    timer =null
    }
    }
    end


    #2
    Du musst den Timer außerhalb der Rule definieren.
    Code:
    var Timer timer = null
    
    rule"Test"
    when
        ItemLight_EG_Buero received command
    then
        if(receivedCommand==ON) {
            if(timer === null) {
                // first ON command, so create a timer to turn the light off again
                timer = createTimer(now.plusSeconds(10)) [
                    sendCommand(Light_EG_Buero, OFF)
                ]
            } else {
                // subsequent ON command, so reschedule the existing timer
                timer.reschedule(now.plusSeconds(10))
            }
        } else {  //die Regel triggert auf received command, es gibt nur zwei Möglichkeiten, eine weitere if Anweisung ist daher unnötig
            // remove any previously scheduled timer
            if(timer !== null) {
                timer.cancel
                timer = null
            }
        }
    end

    Kommentar


      #3
      Das wars, vielen Dank!
      Komisch, dass in der Anleitung im Forum das nicht so drin war...

      Kommentar

      Lädt...
      X