Ankündigung

Einklappen
Keine Ankündigung bisher.

Timer Rules

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

    Timer Rules

    Hallo
    leider habe ich Probleme mit einer Timer Rule.
    Was ich möchte: wenn mein garagentor länger als z.b. 10 min offen steht eine meldung per telegramm erhalten.
    hier meine Rule

    var Timer myTimer = null //Am Anfang der rules Datei globale Variablen definieren
    rule "Nachricht Garagentor steht lange offen"
    when
    Item Contact EG_Garage_Tor changed to OPEN // Status geändert?
    then
    if (Contact EG_Garage_Tor.state == OPEN) // offen?
    if(myTimer === null) // läuft myTimer schon?
    myTimer = createTimer(now.plusSeconds(20), [ | // starte myTimer!
    if(Contact EG_Garage_Tor.state == OPEN) // immer noch offen?
    sendTelegram("bot1", "Garagentor offen ") // sende Nachricht!
    myTimer = null // setze myTimer wieder auf null!
    ])
    else { // geschlossen?
    myTimer.cancel // stoppe myTimer und
    myTimer = null // setze wieder auf null
    }
    end

    Das Log sagt folgendes

    2019-02-25 20:18:06.568 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'raspi_25_02-1018.rules' has errors, therefore ignoring it: [62,6]: no viable alternative at input 'EG_Garage_Tor'

    [64,17]: missing ')' at 'EG_Garage_Tor'

    [64,44]: mismatched input ')' expecting 'end'


    Kann mir vielleicht jemand helfen ?

    Danke




    #2
    Du hast Da den Itemtyp davor geschrieben. Das ist Quatsch. in den Rules ist eine Item ein Item.

    Wenn Du Code postest, wäre es schön, den als Code zu markieren.
    Code:
    var Timer myTimer = null //Am Anfang der rules Datei globale Variablen definieren
    
    rule "Nachricht Garagentor steht lange offen"
    when
        Item EG_Garage_Tor changed to OPEN                          // Status geändert?
    then
        if (EG_Garage_Tor.state == OPEN) {                          // offen?
            if(myTimer === null)                                    // läuft myTimer schon?
                myTimer = createTimer(now.plusMinutes(10), [ |      // starte myTimer!
                    if(EG_Garage_Tor.state == OPEN)                 // immer noch offen?
                        sendTelegram("bot1", "Garagentor offen ")   // sende Nachricht!
                    myTimer = null                                  // setze myTimer wieder auf null!
                ])
        } else {                                                    // geschlossen?
            myTimer.cancel                                          // stoppe myTimer und
            myTimer = null                                          // setze wieder auf null
        }
    end
    Weiterhin ist dein else hier zweideutig. das wird halt erst dann deutlich, wenn man den Code einrückt. Nach dem 1. if-Statement musst Du also auch klammern.
    Zuletzt geändert von udo1toni; 25.02.2019, 21:24.

    Kommentar


      #3
      Ok wie machte ich das mit dem Code?
      Ich will ja alles richtig machen aber bekomme es halt nicht hin....leider

      Kommentar


        #4
        leider geht es immer noch nicht müsste es 1zu1 übernommen haben
        Der Log

        2019-02-25 21:00:23.723 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'raspi_25_02-1018.rules' has errors, therefore ignoring it: [84,28]: missing ')' at 'EG_Garage_Tor'

        [84,55]: missing ']' at ')'

        [87,13]: mismatched input ']' expecting '}'

        ==> /var/log/openhab2/events.log <==

        2019-02-25 21:00:27.858 [vent.ItemStateChangedEvent] - EG_Garage_Tor changed from OPEN to CLOSED

        2019-02-25 21:00:31.112 [vent.ItemStateChangedEvent] - EG_Garage_Tor changed from CLOSED to OPEN

        Kommentar


          #5
          Zitat von Gerhard75 Beitrag anzeigen
          Ok wie machte ich das mit dem Code?
          1. Auf den [A] Button ("Zum erweiterten Editor wechseln) über den Textfeld klicken
          2. Mit dem Button [#] kannst Du dann einen Code-Block einfügen

          Kommentar


            #6
            leider geht es immer noch nicht...hier nochmals der log
            Code:
             
                   2019-02-25 21:12:40.000 [COLOR=orange][WARN ][/COLOR] [el.core.internal.ModelRepositoryImpl] - Configuration model 'raspi_25_02-1018.rules' has errors, therefore ignoring it: [84,28]: missing ')' at 'EG_Garage_Tor'
             
            [84,55]: missing ']' at ')'
             
            [87,13]: mismatched input ']' expecting '}'
             
            ==> /var/log/openhab2/events.log <==
             
            2019-02-25 21:12:51.180 [vent.ItemStateChangedEvent] - EG_Garage_Tor changed from OPEN to CLOSED
             
            2019-02-25 21:12:55.549 [vent.ItemStateChangedEvent] - EG_Garage_Tor changed from CLOSED to OPEN
            und nochmals der Timer dazu
            Code:
             [COLOR=#000000]rule "Nachricht Garagentor steht lange offen"[/COLOR]
             
              [COLOR=#000000]when[/COLOR]
              [COLOR=#000000]Item EG_Garage_Tor changed to OPEN // Status geändert?[/COLOR]
              [COLOR=#000000]then[/COLOR]
              [COLOR=#000000]if (EG_Garage_Tor.state == OPEN) {                                                         // offen?[/COLOR]
              [COLOR=#000000]if(myTimer === null)                                                                                    // läuft myTimer schon?[/COLOR]
              [COLOR=#000000]  myTimer = createTimer(now.plusMinutes(1), [ |                                       // starte myTimer![/COLOR]
              [COLOR=#000000]           if(Contact EG_Garage_Tor.state == OPEN)                                  // immer noch offen?[/COLOR]
              [COLOR=#000000]sendTelegram("bot1", "Garagentor offen ")                                               // sende Nachricht![/COLOR]
              [COLOR=#000000]myTimer = null                                                                                            // setze myTimer wieder auf null![/COLOR]
              [COLOR=#000000]])[/COLOR]
              [COLOR=#000000]} else {                                                                                                         // geschlossen?[/COLOR]
              [COLOR=#000000]myTimer.cancel                                                                                 // stoppe myTimer und[/COLOR]
              [COLOR=#000000]myTimer = null                                                                                            // setze wieder auf null[/COLOR]
              [COLOR=#000000]}[/COLOR]
              [COLOR=#000000]end[/COLOR]

            Kommentar


              #7
              Ich hab leider ein Contact übersehen... Ich korrigiere es oben.

              Kommentar


                #8
                Juhu es geht
                grossen dank an toni....
                leider sehe ich jetzt vor lauter bäumen den Wald nicht ...wo ist der unterschied?

                Kommentar


                  #9
                  Ich habs bei if.....

                  Kommentar

                  Lädt...
                  X