Hallo,
ich bin neu und habe meinen fhem Server am laufen. Ich möchte die Mobile Alerts Sensoren einbinden. Das geht mit httpmod
ich habe folgende regex:
attr SEN1 readingsRegex1 "t1": (\d?\d.\d)
attr SEN1 readingsRegex2 "h": (\d?\d.\d)
ich erhalte damit aber nur die erste Fundstelle des Ausdruck, nicht die letzte. Die letzte ist der aktuelle Wert, ich komme hier nicht weiter. Wie komme ich an den letzten gültigen Ausdruck?
Danke für Eure Hilfe.
Otis
HTTP/1.1 200 OK Cache-Control: no-cache Pragma: no-cache Content-Length: 10243 Content-Type: application/json; charset=utf-8 Expires: -1 Server: Microsoft-IIS/8.5 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Sun, 05 Jul 2015 14:26:15 GMT Connection: close { "success": true, "primarydomain": "www.data199.com", "phoneid": "xxxxx6793072", "result": { "devices": [ { "deviceid": "xxx25985DCE", "devicetypeid": 3, "name": "Wohnzimmer ", "lang": "de", "lastseen": 1436106019, "lowbattery": false, "alertwasactive": false, "settings": { "ts1loalarm": -10.0, "ts1loalarmactive": false, "ts1hialarm": 40.0, "ts1hialarmactive": false, "hloalarm": 20.0, "hloalarmactive": false, "hhialarm": 60.0, "hhialarmactive": false, "wotalarm": 0, "wctalarm": 0 }, "measurements": [ { "idx": 229262, "ts": 1436105905, "tx": 9152, "c": 1436106019, "t1": 29.1, "h": 62.0 }, { "idx": 229257, "ts": 1436105481, "tx": 9151, "c": 1436105597, "t1": 29.0, "h": 62.0 }, { "idx": 229251, "ts": 1436105058, "tx": 9150, "c": 1436105177, "t1": 28.9, "h": 62.0 }, { "idx": 229252, "ts": 1436105058, "tx": 9150, "c": 1436105177, "t1": 28.9, "h": 62.0 }, { "idx": 229237, "ts": 1436103788, "tx": 9147, "c": 1436103915, "t1": 28.6, "h": 62.0 }, { "idx": 229232, "ts": 1436103365, "tx": 9146, "c": 1436103494, "t1": 28.5, "h": 63.0 }, { "idx": 229227, "ts": 1436102943, "tx": 9145, "c": 1436103073, "t1": 28.4, "h": 63.0 }, { "idx": 229222, "ts": 1436102518, "tx": 9144, "c": 1436102652, "t1": 28.4, "h": 63.0 }, { "idx": 229214, "ts": 1436102096, "tx": 9143, "c": 1436102231, "t1": 28.4, "h": 63.0 }, { "idx": 229209, "ts": 1436101673, "tx": 9142, "c": 1436101810, "t1": 28.3, "h": 63.0 }, { "idx": 229203, "ts": 1436101251, "tx": 9141, "c": 1436101389, "t1": 28.3, "h": 63.0 }, { "idx": 229198, "ts": 1436100829, "tx": 9140, "c": 1436100968, "t1": 28.2, "h": 63.0 }, { "idx": 229192, "ts": 1436100407, "tx": 9139, "c": 1436100547, "t1": 28.1, "h": 63.0 }, { "idx": 229187, "ts": 1436099983, "tx": 9138, "c": 1436100127, "t1": 28.1, "h": 63.0 }, { "idx": 229183, "ts": 1436099561, "tx": 9137, "c": 1436099706, "t1": 28.0, "h": 63.0 }, { "idx": 229177, "ts": 1436099138, "tx": 9136, "c": 1436099286, "t1": 27.9, "h": 63.0 }, { "idx": 229171, "ts": 1436098715, "tx": 9135, "c": 1436098865, "t1": 27.8, "h": 63.0 }, { "idx": 229167, "ts": 1436098291, "tx": 9134, "c": 1436098444, "t1": 27.8, "h": 63.0 }, { "idx": 229164, "ts": 1436097867, "tx": 9133, "c": 1436098023, "t1": 27.8, "h": 63.0 }, { "idx": 229159, "ts": 1436097445, "tx": 9132, "c": 1436097603, "t1": 27.8, "h": 63.0 }, { "idx": 229155, "ts": 1436097021, "tx": 9131, "c": 1436097182, "t1": 27.8, "h": 63.0 }, { "idx": 229156, "ts": 1436097021, "tx": 9131, "c": 1436097182, "t1": 27.9, "h": 63.0 }, { "idx": 229145, "ts": 1436096175, "tx": 9129, "c": 1436096340, "t1": 27.8, "h": 63.0 }, { "idx": 229141, "ts": 1436095753, "tx": 9128, "c": 1436095918, "t1": 27.9, "h": 63.0 }, { "idx": 229136, "ts": 1436095332, "tx": 9127, "c": 1436095499, "t1": 27.9, "h": 63.0 }, { "idx": 229131, "ts": 1436094909, "tx": 9126, "c": 1436095078, "t1": 27.9, "h": 63.0 }, { "idx": 229126, "ts": 1436094484, "tx": 9125, "c": 1436094657, "t1": 27.9, "h": 63.0 }, { "idx": 229119, "ts": 1436094061, "tx": 9124, "c": 1436094236, "t1": 27.9, "h": 63.0 }, { "idx": 229116, "ts": 1436093638, "tx": 9123, "c": 1436093816, "t1": 27.9, "h": 63.0 }, { "idx": 229112, "ts": 1436093216, "tx": 9122, "c": 1436093394, "t1": 28.0, "h": 63.0 }, { "idx": 229108, "ts": 1436092793, "tx": 9121, "c": 1436092974, "t1": 28.0, "h": 63.0 }, { "idx": 229104, "ts": 1436092369, "tx": 9120, "c": 1436092553, "t1": 28.0, "h": 63.0 }, { "idx": 229098, "ts": 1436091946, "tx": 9119, "c": 1436092133, "t1": 28.0, "h": 63.0 }, { "idx": 229099, "ts": 1436091946, "tx": 9119, "c": 1436092133, "t1": 28.0, "h": 63.0 }, { "idx": 229087, "ts": 1436091101, "tx": 9117, "c": 1436091291, "t1": 28.0, "h": 63.0 }, { "idx": 229083, "ts": 1436090677, "tx": 9116, "c": 1436090870, "t1": 28.0, "h": 63.0 }, { "idx": 229079, "ts": 1436090256, "tx": 9115, "c": 1436090449, "t1": 28.0, "h": 63.0 }, { "idx": 229074, "ts": 1436089833, "tx": 9114, "c": 1436090029, "t1": 28.0, "h": 63.0 }, { "idx": 229069, "ts": 1436089408, "tx": 9113, "c": 1436089608, "t1": 28.0, "h": 63.0 }, { "idx": 229063, "ts": 1436088985, "tx": 9112, "c": 1436089187, "t1": 28.0, "h": 63.0 }, { "idx": 229059, "ts": 1436088563, "tx": 9111, "c": 1436088766, "t1": 28.0, "h": 63.0 }, { "idx": 229054, "ts": 1436088139, "tx": 9110, "c": 1436088345, "t1": 28.0, "h": 63.0 }, { "idx": 229048, "ts": 1436087715, "tx": 9109, "c": 1436087924, "t1": 28.0, "h": 63.0 }, { "idx": 229043, "ts": 1436087293, "tx": 9108, "c": 1436087504, "t1": 28.0, "h": 63.0 }, { "idx": 229039, "ts": 1436086871, "tx": 9107, "c": 1436087083, "t1": 28.0, "h": 63.0 }, { "idx": 229033, "ts": 1436086448, "tx": 9106, "c": 1436086663, "t1": 28.0, "h": 63.0 }, { "idx": 229029, "ts": 1436086024, "tx": 9105, "c": 1436086241, "t1": 28.1, "h": 63.0 }, { "idx": 229024, "ts": 1436085601, "tx": 9104, "c": 1436085821, "t1": 28.1, "h": 64.0 }, { "idx": 229018, "ts": 1436085178, "tx": 9103, "c": 1436085400, "t1": 28.0, "h": 64.0 }, { "idx": 229014, "ts": 1436084754, "tx": 9102, "c": 1436084980, "t1": 28.0, "h": 64.0 } ], "alertevents": [] } ] } }
Hallo Otis,
Du könntest zum Beispiel versuchen die Regex so zu erweitern dass nach der Zahl keine weitere geschweifte Klammer geöffnet wird, dafür aber eine eckige geschlossen wird ...
Gruß
Stefan
Hallo Otis,
bist Du Dir sicher, daß der letzte der aktuellste Wert ist?
Ich dachte, daß der Wert "ts" der Unix-Timestamp ist. Demnach wäre er erste Wert der neueste.
Oder wie hast Du die Werte interpetiert? Was ist mit "c" und "tx". "idx" denke ich müßte eine Index-Nummer sein.
Grüße
Reinhard
P.S. Timestamp rechne ich wie folgt um:
attr SEN1 readingsRegex3 "ts":(\d\d\d\d\d\d\d\d\d\d)
attr SEN1 readingsExpr3 {strftime "%d.%m.%Y %H:%M",localtime($val)}
Hallo Laffer,
ich habe den Timestamp nicht berechnet, ich habe einfach die aktuell gelieferten Werte mit den Werten der App verglichen. Aber ich habe das noch einmal kontrolliert und Dein Einwand ist korrekt. Ich erhalte den richtigen Wert mit der Regex (Glück), die anderen Werte sind wohl Zeitpunkt der Messung und übertragung an den Server tx kann ich auch nicht deuten. Ich weiß nicht wieso mir das nicht aufgefallen ist. Manchmal sieht man den Wald nicht...
Danke,
da kann ich jetzt ja mal weiter machen :)
hallo, bist du damit schon weiter?