Diagramme in OpenHAB 2 erstellen

Einrichtung der openHAB Umgebung und allgemeine Konfigurationsthemen.

Moderatoren: seppy, udo1toni

SmartHomer
Beiträge: 51
Registriert: 17. Mai 2018 09:26

Diagramme in OpenHAB 2 erstellen

Beitrag von SmartHomer »

Hallo,

ich möchte gerne Diagramme in OpenHAB 2 erstellen. Dabei möchte ich mehrere Items, welchen einen bestimmten Wert gespeichert haben in einer Kurve darstellen. Das ganze soll eine Vorhersage graphisch darstellen, wobei auf der X-Achse die Zeit des berechneten Wert des jeweiligen Items angezeigt werden soll und auf der Y-Achse der tatsächlich berechnete Wert.

Ich möchte gerne die Diagramme über das Visualisierungstool Grafana abbilden, wenn es hier jedoch auch noch andere Alternativen gibt ist es auch in Ordnung.

Hat jemand hierfür eine Lösung?

Benutzeravatar
sihui
Beiträge: 1827
Registriert: 11. Apr 2018 19:03
Answers: 21

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von sihui »

SmartHomer hat geschrieben: 4. Jul 2018 08:12 Hat jemand hierfür eine Lösung?
Eine Komplettanleitung gibt es hier:

https://community.openhab.org/t/influxd ... hing/13761
openHAB3 mit Zwave, Alexa, ESPEasy, MQTT, Logitech Harmony, Philips HUE und ZigBee Hardware auf Proxmox VE.

SmartHomer
Beiträge: 51
Registriert: 17. Mai 2018 09:26

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von SmartHomer »

Die Seite ist mir bekannt. Grafana läuft auch auf meinem RPi3.

Ich möchte jedoch mehrere Items in einem Diagramm als eine Kurve graphisch darstellen. Ich möchte eine Prognose welche ich berechnet habe für die nächsten Tage abbilden?

Benutzeravatar
sihui
Beiträge: 1827
Registriert: 11. Apr 2018 19:03
Answers: 21

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von sihui »

SmartHomer hat geschrieben: 4. Jul 2018 09:47 Ich möchte jedoch mehrere Items in einem Diagramm als eine Kurve graphisch darstellen.
Wenn ich das richtig sehe ist genau das in dem ersten Post dargestellt:

Bild
openHAB3 mit Zwave, Alexa, ESPEasy, MQTT, Logitech Harmony, Philips HUE und ZigBee Hardware auf Proxmox VE.

SmartHomer
Beiträge: 51
Registriert: 17. Mai 2018 09:26

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von SmartHomer »

Ich glaube ich muss es nochmals anderst erklären. Ich möchte eine Prognose grapisch darstellen. Die Werte für die Prognose berechne ich in einer .rules Datei und speichere die jeweiligen Werte in Items. Diese Items möchte ich in einem Diagramm in einer Kurve darstellen und nicht in einem Diagramm mit mehreren Kurven.

Beispiel: Bild

Benutzeravatar
udo1toni
Beiträge: 13860
Registriert: 11. Apr 2018 18:05
Answers: 222
Wohnort: Darmstadt

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von udo1toni »

Du hast in Deinem Diagramm aber auch zwei Kurven... ;)

Ich vermute mal, dass Du mehrere Items hast, die für die unterschiedlichen Zeitpunkte stehen? Da wirst Du mit Bordmitteln kein Glück haben, denn Du kannst nur die y-Achse beeinflussen, die x-Achse ist fest der Zeit zugeordnet. Du müsstest also die Prognose in Echtzeit berechnen und auch in Echtzeit in Deine Items schreiben, z.B. einen Tag vorher. Dann kannst Du den Graphen der Prognose mit den Werten "von gestern" anzeigen lassen.
openHAB4.1.2 stable in einem Debian-Container (bookworm) (Proxmox 8.1.5, LXC), mit openHABian eingerichtet

SmartHomer
Beiträge: 51
Registriert: 17. Mai 2018 09:26

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von SmartHomer »

Ja genau, ich habe mehrere Items welche für die einzelnen Prognosewerte stehen. Also beispielsweise 12 Uhr, 13 Uhr, 14 Uhr usw.

Ich würde halt gerne zukünftige Werte grapisch darstellen. Gibt es hierfür Lösungen oder eher schwierig? Evtl. auch mit anderen Tools als Grafana.

Benutzeravatar
udo1toni
Beiträge: 13860
Registriert: 11. Apr 2018 18:05
Answers: 222
Wohnort: Darmstadt

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von udo1toni »

Das Problem dabei ist nicht die grafische Darstellung, sondern, wie Du die errechneten Daten korrekt in die Datenbank bekommst.
openHAB ist an dieser Stelle vielleicht nicht das geeignete Werkzeug. Wenn Du z.B. die Berechnungen in einem Script erledigst, welches die Daten anschließend selbständig in eine Datenbank schreibt, wobei es dann die passenden Zeitstempel selbst setzt und openHAB-konform in einer passenden Tabelle einträgt, wird openHAB nicht wissen, dass es diese Daten nicht selbst hinterlegt hat.

Um es beispielhaft zu beschreiben, nimmst Du ein Number Item meinePrognose und richtest einen Persistence Service für dieses Item ein. Dabei gibst Du aber keinen Trigger an, oder Du erstellst nur einen Trigger, der einmal täglich um 0 Uhr einen Wert einträgt (damit der Persistence Service zufrieden ist).
Der Persistence Service erzeugt in der zugehörigen Datenbank eine Tabelle (wenn Du auf InfluxDB zurück greifst ein Measurement). Dein Prognosescript wird zu einem Zeitpunkt x automatisch angestoßen, errechnet alle Werte für den folgenden Tag und schreibt sie mit den passenden Zeitstempeln in das passende Measurement (oder die passende Tabelle).
In openHAB richtest Du dann nur noch den View auf die Daten ein.
openHAB4.1.2 stable in einem Debian-Container (bookworm) (Proxmox 8.1.5, LXC), mit openHABian eingerichtet

SmartHomer
Beiträge: 51
Registriert: 17. Mai 2018 09:26

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von SmartHomer »

Ok ich habe für meine Prognose Items angelegt. Und zwar nach folgendem Schema:

Code: Alles auswählen

Number numItem_Prognose_PV_Leistung_0 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_1 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_2 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_3 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_4 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_5 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_6 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_7 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_8 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_9 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_10 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_11 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_12 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_13 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_14 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_15 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_16 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_17 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_18 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_19 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_20 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_21 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_22 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_23 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_24 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_25 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_26 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_27 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_28 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_29 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_30 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_31 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_32 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_33 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_34 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_35 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_36 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_37 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_38 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Number numItem_Prognose_PV_Leistung_39 "Prognose PV-Leistung [%.2f W]" <solarplant> (gPrognose_PV_Leistung)
Meine Berechnung der Prognose habe ich in einer .rules Datei folgendermaßen vorgenommen:

Code: Alles auswählen

rule "Berechnung Prognose PV-Leistung heute"
when
    Time cron "0 0/1 * * * ?"
then
    
    var Number Prognose_PV_Leistung_0
    
    if (Cosinus_Thetta_0 < 0) {
    Prognose_PV_Leistung_0 = 0
    }
    else { Prognose_PV_Leistung_0 = Strahlungsintensitaet_Sonne*Gesamtflaeche_PV_Module*Wirkungsgrad_PV_Anlage*Cosinus_Thetta_0*(1-(Bewoelkung_0/100))
    }
    // var Number Prognose_PV_Leistung_0 = Strahlungsintensitaet_Sonne*Gesamtflaeche_PV_Module*Wirkungsgrad_PV_Anlage*Cosinus_Thetta_0*(1-(Bewoelkung_0/100))
    
    var Number Prognose_PV_Leistung_1
    
    if (Cosinus_Thetta_1 < 0) {
    Prognose_PV_Leistung_1 = 0
    }
    else { Prognose_PV_Leistung_1 = Strahlungsintensitaet_Sonne*Gesamtflaeche_PV_Module*Wirkungsgrad_PV_Anlage*Cosinus_Thetta_1*(1-(Bewoelkung_1/100))
    }
.....
var Number Prognose_PV_Leistung_39
    
    if (Cosinus_Thetta_39 < 0) {
    Prognose_PV_Leistung_39 = 0
    }
    else { Prognose_PV_Leistung_39 = Strahlungsintensitaet_Sonne*Gesamtflaeche_PV_Module*Wirkungsgrad_PV_Anlage*Cosinus_Thetta_39*(1-(Bewoelkung_39/100))
    }
    
    // var Number Prognose_PV_Leistung_39 = Strahlungsintensitaet_Sonne*Gesamtflaeche_PV_Module*Wirkungsgrad_PV_Anlage*Cosinus_Thetta_39*(1-(Bewoelkung_39/100))
    
numItem_Prognose_PV_Leistung_0.postUpdate(Prognose_PV_Leistung_0)
    numItem_Prognose_PV_Leistung_1.postUpdate(Prognose_PV_Leistung_1)
    numItem_Prognose_PV_Leistung_2.postUpdate(Prognose_PV_Leistung_2)
    numItem_Prognose_PV_Leistung_3.postUpdate(Prognose_PV_Leistung_3)
    numItem_Prognose_PV_Leistung_4.postUpdate(Prognose_PV_Leistung_4)
    numItem_Prognose_PV_Leistung_5.postUpdate(Prognose_PV_Leistung_5)
    numItem_Prognose_PV_Leistung_6.postUpdate(Prognose_PV_Leistung_6)
    numItem_Prognose_PV_Leistung_7.postUpdate(Prognose_PV_Leistung_7)
    numItem_Prognose_PV_Leistung_8.postUpdate(Prognose_PV_Leistung_8)
    numItem_Prognose_PV_Leistung_9.postUpdate(Prognose_PV_Leistung_9)
    numItem_Prognose_PV_Leistung_10.postUpdate(Prognose_PV_Leistung_10)
    numItem_Prognose_PV_Leistung_11.postUpdate(Prognose_PV_Leistung_11)
    numItem_Prognose_PV_Leistung_12.postUpdate(Prognose_PV_Leistung_12)
    numItem_Prognose_PV_Leistung_13.postUpdate(Prognose_PV_Leistung_13)
    numItem_Prognose_PV_Leistung_14.postUpdate(Prognose_PV_Leistung_14)
    numItem_Prognose_PV_Leistung_15.postUpdate(Prognose_PV_Leistung_15)
    numItem_Prognose_PV_Leistung_16.postUpdate(Prognose_PV_Leistung_16)
    numItem_Prognose_PV_Leistung_17.postUpdate(Prognose_PV_Leistung_17)
    numItem_Prognose_PV_Leistung_18.postUpdate(Prognose_PV_Leistung_18)
    numItem_Prognose_PV_Leistung_19.postUpdate(Prognose_PV_Leistung_19)
    numItem_Prognose_PV_Leistung_20.postUpdate(Prognose_PV_Leistung_20)
    numItem_Prognose_PV_Leistung_21.postUpdate(Prognose_PV_Leistung_21)
    numItem_Prognose_PV_Leistung_22.postUpdate(Prognose_PV_Leistung_22)
    numItem_Prognose_PV_Leistung_23.postUpdate(Prognose_PV_Leistung_23)
    numItem_Prognose_PV_Leistung_24.postUpdate(Prognose_PV_Leistung_24)
    numItem_Prognose_PV_Leistung_25.postUpdate(Prognose_PV_Leistung_25)
    numItem_Prognose_PV_Leistung_26.postUpdate(Prognose_PV_Leistung_26)
    numItem_Prognose_PV_Leistung_27.postUpdate(Prognose_PV_Leistung_27)
    numItem_Prognose_PV_Leistung_28.postUpdate(Prognose_PV_Leistung_28)
    numItem_Prognose_PV_Leistung_29.postUpdate(Prognose_PV_Leistung_29)
    numItem_Prognose_PV_Leistung_30.postUpdate(Prognose_PV_Leistung_30)
    numItem_Prognose_PV_Leistung_31.postUpdate(Prognose_PV_Leistung_31)
    numItem_Prognose_PV_Leistung_32.postUpdate(Prognose_PV_Leistung_32)
    numItem_Prognose_PV_Leistung_33.postUpdate(Prognose_PV_Leistung_33)
    numItem_Prognose_PV_Leistung_34.postUpdate(Prognose_PV_Leistung_34)
    numItem_Prognose_PV_Leistung_35.postUpdate(Prognose_PV_Leistung_35)
    numItem_Prognose_PV_Leistung_36.postUpdate(Prognose_PV_Leistung_36)
    numItem_Prognose_PV_Leistung_37.postUpdate(Prognose_PV_Leistung_37)
    numItem_Prognose_PV_Leistung_38.postUpdate(Prognose_PV_Leistung_38)
    numItem_Prognose_PV_Leistung_39.postUpdate(Prognose_PV_Leistung_39)
end    
als persistence Datei habe ich dann die Items wie folgt angelegt:

Code: Alles auswählen

Strategies {

everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"

default = everyChange
}

Items {
		numItem_Prognose_PV_Leistung_0, numItem_Prognose_PV_Leistung_1, ..., numItem_Prognose_PV_Leistung_39: strategy = everyChange, everyUpdate, everyMinute, restoreOnStartup		
}
Wie bekomme ich nun die einzelnen Werte der Items über Grafana in einer Kurve angezeigt ? Ich bekomme bisher nach dieser Variante für jedes Item eine eigene Kurve aufgezeichnet. Ich möchte aber gerne alle 40 Werte als eine Kurve in einem Graphen darstellen.

Benutzeravatar
udo1toni
Beiträge: 13860
Registriert: 11. Apr 2018 18:05
Answers: 222
Wohnort: Darmstadt

Re: Diagramme in OpenHAB 2 erstellen

Beitrag von udo1toni »

Du hast meine voriga Antwort offenbar nicht richtig gelesen.

So, wie Du das machen möchtest, geht es schlicht nicht.

openHAB hat keine Möglichkeit, die Itemstatus in einer Zeitreihe frei einzutragen. Das geht nur außerhalb openHAB, also z.B. mit einem Python Script. Es ist aber wenig sinnvoll, die Berechnung in openHAB durchzuführen (mit zig Items), nur um diese dann über ein externes Script in eine Datenbank zu schreiben. Einfacher und schneller ist es, die Berechnung direkt im Script durchzuführen.
openHAB4.1.2 stable in einem Debian-Container (bookworm) (Proxmox 8.1.5, LXC), mit openHABian eingerichtet

Antworten