FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: holle75 am 10 Mai 2023, 15:46:35

Titel: notify regex negieren
Beitrag von: holle75 am 10 Mai 2023, 15:46:35
Hello!

Jetzt muss ich mal eine Anfängerfrage stellen. RegEx, (m)ein ewiges Leid.

Ich habe ein notify (bin eher der DOIF-Nutzer, vergebt mir etwähige Fehler)

EatonUSV:ups.status:OB.* {Log 1, "EatonUSV:Verbleibende-Minuten ".ReadingsVal("EatonUSV", "Verbleibende-Minuten", "");Log 1, "EatonUSV:ups.status ".ReadingsVal("EatonUSV", "ups.status", "");}
und möchte das OB.* negieren. Also alles ausser OB.*
Habe mich mal in das Lookaround ein bißchen eingelesen, aber das macht das Komplizierte ja noch komplizierter.

Jemand RegEx/notify Profi?

Danke und Gruß
H.

Titel: Aw: notify regex negieren
Beitrag von: Jamo am 10 Mai 2023, 15:55:12
das notify attribut ignoreRegexp ist dein Freund:
attr ignoreRegexp regexp
It is hard to create a regexp which is _not_ matching something, this attribute helps in this case, as the event is ignored if it matches the argument. The syntax is the same as for the original regexp.
Titel: Aw: notify regex negieren
Beitrag von: holle75 am 10 Mai 2023, 16:13:07
Danke Jamo, wie nutze ich das in einem notify wo die regex im DEF eingebaut ist?

define EatonUSV_Stromausfall_LOG1 EatonUSV:ups.status:.* {Log 1, "EatonUSV:Verbleibende-Minuten ".ReadingsVal("EatonUSV", "Verbleibende-Minuten", "");Log 1, "EatonUSV:ups.status ".ReadingsVal("EatonUSV", "ups.status", "");}
attr EatonUSV_Stromausfall_LOG1 ignoreRegexp OL

In der DEF alles aufmachen und das OL wäre dann in diesem Fall die Negierung von allem anderen?

Titel: Aw: notify regex negieren
Beitrag von: Jamo am 10 Mai 2023, 16:43:29
Ja, Du würdest im notify alles aufmachen, und mit ignoreRegexp OB ignorieren.
Allerdings hast Du das notify vergessen, und im attribute keine regexp definiert, ich denke das muss so aussehen:define EatonUSV_Stromausfall_LOG1 notify       EatonUSV:ups.status:.* {Log 1, "EatonUSV:Verbleibende-Minuten ".ReadingsVal("EatonUSV", "Verbleibende-Minuten", "");Log 1, "EatonUSV:ups.status ".ReadingsVal("EatonUSV", "ups.status", "");}
attr   EatonUSV_Stromausfall_LOG1 ignoreRegexp EatonUSV:ups.status:OB.*
Titel: Aw: notify regex negieren
Beitrag von: betateilchen am 10 Mai 2023, 16:44:07
Warum willst Du eigentlich über ein notify loggen und nicht über FileLog?
Titel: Aw: notify regex negieren
Beitrag von: holle75 am 10 Mai 2023, 16:52:38
@Jamo, ak ok, verstehe (fehlendes notify war ein copy+paste Fehler). Dankeschön
@Betateilchen Ich hoffe, dass bei der USV im Status was anderes als OL nur seltenst vorkommt. Aber ja, könnte ich auch in ein FileLog schreiben. Will sagen, es gibt nicht wirklich einen Sinn warum das jetzt ins fhem log geht ;)
Titel: Aw: notify regex negieren
Beitrag von: betateilchen am 10 Mai 2023, 17:34:34
Zitat von: holle75 am 10 Mai 2023, 16:52:38@Betateilchen Ich hoffe, dass bei der USV im Status was anderes als OL nur seltenst vorkommt. Aber ja, könnte ich auch in ein FileLog schreiben. Will sagen, es gibt nicht wirklich einen Sinn warum das jetzt ins fhem log geht

*achselzuck* das habe ich nicht verstanden.
Aber es ist mir ja eigentlich auch wurscht.
Titel: Aw: notify regex negieren
Beitrag von: holle75 am 10 Mai 2023, 19:11:16
Vielleicht habe ich dich auch ncht richtig verstanden?

Deine Frage war, warum ich die Events nicht in ein separates FileLog schreibe anstatt ins fhem Log?
Titel: Aw: notify regex negieren
Beitrag von: betateilchen am 10 Mai 2023, 19:37:10
Nein. Meine Frage war, warum Du ein notify-device verwendest anstatt ein FileLog-device.

Egal, Du hast eine Lösung gefunden, mit der Du leben kannst, das ist die Hauptsache.
Titel: Aw: notify regex negieren
Beitrag von: holle75 am 10 Mai 2023, 19:43:23
Ich finds ja noch spannend andere Ansätze zu hören. Ein FileLog device schreibt, meines Wissens nach, in einen definierten File und nicht ins fhem Log. Über ein Notify ist der mir einzig bekannte Weg ins fhem Log zu schreiben. Kennst du noch einen anderen?
Titel: Aw: notify regex negieren
Beitrag von: betateilchen am 10 Mai 2023, 20:02:58
Zitat von: holle75 am 10 Mai 2023, 19:43:23Ein FileLog device schreibt, meines Wissens nach, in einen definierten File

Völlig korrekt. Es steht aber nirgends, dass Du nicht in einem von Dir angelegten FileLog-device das gleiche file verwenden darfst wie FHEM selbst.

Zitat von: holle75 am 10 Mai 2023, 19:43:23Über ein Notify ist der mir einzig bekannte Weg ins fhem Log zu schreiben

Naja, Du hast halt Deinen Gedanken oben nicht weit genug gedacht.

Zitat von: holle75 am 10 Mai 2023, 19:43:23Kennst du noch einen anderen?

Siehe oben.

defmod test_Log FileLog %L/fhem-%Y-%m-%d_%H.log <irgendeinDevice>.*
wobei "%L/fhem-%Y-%m-%d_%H.log" die gleiche Namensangabe ist wie im FHEM-Logfile (das ist ja auch nur ein FileLog-device!) selbst:

defmod Logfile FileLog %L/fhem-%Y-%m-%d_%H.log fakelog
Titel: Aw: notify regex negieren
Beitrag von: holle75 am 11 Mai 2023, 21:43:58
Sehr schön, ich danke dir ...