FHEM Forum

FHEM => Anfängerfragen => Thema gestartet von: _hndrk am 23 Oktober 2018, 23:36:39

Titel: Integration von JSONRohdaten als Zeitreihe+Datenpunkt (Energieverbrauch in kWh)
Beitrag von: _hndrk am 23 Oktober 2018, 23:36:39
Liebe Foristen,

ich hoffe das Anfängerforum ist der richtige Ort für diese Frage. Ich möchte Daten eines externen Dienstes einbinden, die ich als JSON regelmäßig abfragen kann. Ich finde jedoch keinen guten Ansatzpunkt für die Integration in FHEM.

Bei den Daten handelt es sich um den Energieverbrauch, den ich in verschiedenen Granularitäten abfragen kann: Pro halbe Stunde, pro Tag, pro Monat. Die Daten bekomme ich von "ENEDIS" (Stromnetzbetreiber in Frankreich) und kann sie z.B. über das folgende Skript abfragen: https://github.com/Asdepique777/jeedom_linky


Die Rohdaten sehen folgendermaßen aus:

[{"time": "00:00", "conso": 0.164}, {"time": "00:30", "conso": 0.124}, {"time": "01:00", "conso": 0.124}, {"time": "01:30", "conso": 0.04}, {"time": "02:00", "conso": 0.082}, {"time": "02:30", "conso": 0.04}, {"time": "03:00", "conso": 0.082}, {"time": "03:30", "conso": 0.078}, {"time": "04:00", "conso": 0.038}, {"time": "04:30", "conso": 0.08}, {"time": "05:00", "conso": 0.04}, {"time": "05:30", "conso": 0.08}, {"time": "06:00", "conso": 0.082}, {"time": "06:30", "conso": 0.042}, {"time": "07:00", "conso": 0.036}, {"time": "07:30", "conso": 0.038}, {"time": "08:00", "conso": 0.036}, {"time": "08:30", "conso": 0.038}, {"time": "09:00", "conso": 0.04}, {"time": "09:30", "conso": 0.038}, {"time": "10:00", "conso": 0.04}, {"time": "10:30", "conso": 0.034}, {"time": "11:00", "conso": 0.038}, {"time": "11:30", "conso": 0.038}, {"time": "12:00", "conso": 0.04}, {"time": "12:30", "conso": 0.038}, {"time": "13:00", "conso": 0.04}, {"time": "13:30", "conso": 0.04}, {"time": "14:00", "conso": 0.038}, {"time": "14:30", "conso": 0.04}, {"time": "15:00", "conso": 0.04}, {"time": "15:30", "conso": 0.04}, {"time": "16:00", "conso": 0.04}, {"time": "16:30", "conso": 0.038}, {"time": "17:00", "conso": 0.04}, {"time": "17:30", "conso": 0.04}, {"time": "18:00", "conso": 0.038}, {"time": "18:30", "conso": 0.042}, {"time": "19:00", "conso": 0.04}, {"time": "19:30", "conso": 0.038}, {"time": "20:00", "conso": 0.038}, {"time": "20:30", "conso": 0.036}, {"time": "21:00", "conso": 0.04}, {"time": "21:30", "conso": 0.04}, {"time": "22:00", "conso": 0.038}, {"time": "22:30", "conso": 0.04}, {"time": "23:00", "conso": 0.04}, {"time": "23:30", "conso": 0.038}]

oder

[{"time": "22 Sep", "conso": 9.92}, {"time": "23 Sep", "conso": 3.265}, {"time": "24 Sep", "conso": 4.521}, {"time": "25 Sep", "conso": 3.627}, {"time": "26 Sep", "conso": 2.342}, {"time": "27 Sep", "conso": 4.833}, {"time": "28 Sep", "conso": 2.96}, {"time": "29 Sep", "conso": 3.682}, {"time": "30 Sep", "conso": 2.939}, {"time": "01 Oct", "conso": 3.733}, {"time": "02 Oct", "conso": 2.83}, {"time": "03 Oct", "conso": 2.936}, {"time": "04 Oct", "conso": 2.691}, {"time": "05 Oct", "conso": 2.917}, {"time": "06 Oct", "conso": 2.349}, {"time": "07 Oct", "conso": 3.392}, {"time": "08 Oct", "conso": 3.466}, {"time": "09 Oct", "conso": 3.363}, {"time": "10 Oct", "conso": 3.694}, {"time": "11 Oct", "conso": 3.683}, {"time": "12 Oct", "conso": 3.464}, {"time": "13 Oct", "conso": 3.288}, {"time": "14 Oct", "conso": 1.669}, {"time": "15 Oct", "conso": 1.517}, {"time": "16 Oct", "conso": 1.522}, {"time": "17 Oct", "conso": 1.53}, {"time": "18 Oct", "conso": 3.339}, {"time": "19 Oct", "conso": 2.976}, {"time": "20 Oct", "conso": 1.509}, {"time": "21 Oct", "conso": 1.485}, {"time": "22 Oct", "conso": 1.207}]


Wie könnte ich die Daten am geschicktesten in FHEM integrieren? Der pragmatischste Hack wäre bspw. eine Summenbildung ab Mitternacht, die man dann per "setreading" als tagesaktuellen Gesamtwert aktualisiert. Daraus könnte man dann innerhalb FHEM wiederum einen Graphen machen. Damit würde ich mir auch eine Evaluierung des JSON in fhem sparen.

Habt ihr andere Ideen? Sehe ich eine einfache(re) Lösung nicht?

Lieben Dank für Anregungen, Tipps und Tricks! :-)
Hendrik
Titel: Antw:Integration von JSONRohdaten als Zeitreihe+Datenpunkt (Energieverbrauch in kWh)
Beitrag von: JoWiemann am 24 Oktober 2018, 07:19:20
Hast Du Dir schon mal httpmod angesehen?


Gesendet von iPhone mit Tapatalk

Grüße Jörg
Titel: Antw:Integration von JSONRohdaten als Zeitreihe+Datenpunkt (Energieverbrauch in kWh)
Beitrag von: _hndrk am 24 Oktober 2018, 13:07:33
Hallo jörg,

Ich nutze httpmod an anderer Stelle — mir geht es aber nicht um den Anruf der Daten sondern darum, wie ich die Daten am sinnvollsten in FHEM abbilde. D.h. ob ein je Tag aggregierter Wert sinnvoll ist, usw.
ich hoffe das war verständlich, sonst hole ich noch einmal weiter aus..

Viele Grüße
Hendrik
Titel: Antw:Integration von JSONRohdaten als Zeitreihe+Datenpunkt (Energieverbrauch in kWh)
Beitrag von: JoWiemann am 24 Oktober 2018, 14:02:53
Hallo Hendrik,

ich würde die Daten immer in der sinnvoll feinsten Auflösung abholen. Für Strom wären das 15 Minuten. Deine 30 Minuten sind aber auch noch ok. Alles andere kannst Du dann mit dem Statistikmodul erreichen.

Grüße Jörg