SVG-Plot auf Display ausgeben

Begonnen von Peter H., 17 Februar 2019, 19:31:47

Vorheriges Thema - Nächstes Thema

Peter H.

Hallo zusammen,

ich verwende das Display von Locutus und möchte darauf ein SVG-Plot als Bild anzeigen. Das SVG-Plot (oder heißt es den SVG-Plot?) habe ich definiert und es wird mir in der fhem-Oberfläche angezeigt.

Sobald ich in der layout-Datei für das Display die folgende Zeile einfüge
img 0 32 0.2 png data { plotAsPng("SVG_FileLog_Puffer_1") } # Zahl vor png ist der Zoom, plotsize auf 800,220 eingestellt

wird das Bild auf dem Display angezeigt.

Wenn ich dann aber fhem herunterfahre und neu starte, "hängt sich fhem auf".

Im Logfile sind dann folgende Einträge vorhanden:
(process:412): GdkPixbuf-CRITICAL **: gdk_pixbuf_save_to_callbackv: assertion 'GDK_IS_PIXBUF (pixbuf)' failed
wrong signature
Image data is corrupt?
2019.02.17 19:02:07 1: Including fhem.cfg
2019.02.17 19:02:11 3: WEB: port 8083 opened
2019.02.17 19:02:12 2: eventTypes: loaded 589 events from ./log/eventTypes.txt
2019.02.17 19:02:12 3: Opening CUL868 device /dev/ttyAMA0
2019.02.17 19:02:12 3: Setting CUL868 serial parameters to 38400,8,N,1
2019.02.17 19:02:12 3: CUL868: Possible commands: BbCFiAIZEOGMUYRTVWXefltux
2019.02.17 19:02:12 3: CUL868 device opened
2019.02.17 19:02:12 2: Switched CUL868 rfmode to HomeMatic
2019.02.17 19:02:12 3: Opening CUL_433 device /dev/ttyACM0
2019.02.17 19:02:12 3: Setting CUL_433 serial parameters to 9600,8,N,1
2019.02.17 19:02:13 3: CUL_433: Possible commands: BCFiAZEGMKURTVWXefmltux
2019.02.17 19:02:13 3: CUL_433 device opened
2019.02.17 19:02:23 1: PERL WARNING: Use of uninitialized value $pm in pattern match (m//) at ./FHEM/98_SVG.pm line 1098.
2019.02.17 19:02:23 3: eval: { plotAsPng("SVG_FileLog_Puffer_1") }
2019.02.17 19:02:23 1: PERL WARNING: Use of uninitialized value $pm in string eq at ./FHEM/98_SVG.pm line 1151.
2019.02.17 19:02:23 3: eval: { plotAsPng("SVG_FileLog_Puffer_1") }
2019.02.17 19:02:23 1: PERL WARNING: Use of uninitialized value $svgdata in substitution (s///) at ./FHEM/98_SVG.pm line 2430.
2019.02.17 19:02:23 3: eval: { plotAsPng("SVG_FileLog_Puffer_1") }
2019.02.17 19:02:23 1: PERL WARNING: Use of uninitialized value $svgdata in substitution (s///) at ./FHEM/98_SVG.pm line 2431.
2019.02.17 19:02:23 3: eval: { plotAsPng("SVG_FileLog_Puffer_1") }
2019.02.17 19:02:23 1: PERL WARNING: Use of uninitialized value in subroutine entry at /usr/lib/arm-linux-gnueabihf/perl5/5.24/Image/LibRSVG.pm line 78.
2019.02.17 19:02:23 3: eval: { plotAsPng("SVG_FileLog_Puffer_1") }


Update von fhem habe ich durchgeführt.

Kommentiere ich die o.g. Codezeile in der layout-Datei für das Display wieder aus, fährt fhem hoch und funktioniert wieder. Allerdings sind in der Logdatei dann einige Warnungen enthalten, die ich nicht verstehe:
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_addExtension redefined at ./FHEM/02_RSS.pm line 42, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Initialize redefined at ./FHEM/02_RSS.pm line 54, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_readLayout redefined at ./FHEM/02_RSS.pm line 69, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Define redefined at ./FHEM/02_RSS.pm line 88, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Undefine redefined at ./FHEM/02_RSS.pm line 127, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Notify redefined at ./FHEM/02_RSS.pm line 136, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Set redefined at ./FHEM/02_RSS.pm line 151, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_getURL redefined at ./FHEM/02_RSS.pm line 169, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_Overview redefined at ./FHEM/02_RSS.pm line 204, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_splitRequest redefined at ./FHEM/02_RSS.pm line 230, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_returnRSS redefined at ./FHEM/02_RSS.pm line 254, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_getScript redefined at ./FHEM/02_RSS.pm line 271, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_HTMLHead redefined at ./FHEM/02_RSS.pm line 288, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_HTMLTail redefined at ./FHEM/02_RSS.pm line 306, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_returnHTML redefined at ./FHEM/02_RSS.pm line 310, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_xy redefined at ./FHEM/02_RSS.pm line 344, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_color redefined at ./FHEM/02_RSS.pm line 356, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemText redefined at ./FHEM/02_RSS.pm line 368, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemTextBox redefined at ./FHEM/02_RSS.pm line 389, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemTime redefined at ./FHEM/02_RSS.pm line 419, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemSeconds redefined at ./FHEM/02_RSS.pm line 426, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemDate redefined at ./FHEM/02_RSS.pm line 438, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemImg redefined at ./FHEM/02_RSS.pm line 447, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemLine redefined at ./FHEM/02_RSS.pm line 542, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_itemRect redefined at ./FHEM/02_RSS.pm line 548, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_cleanLayout redefined at ./FHEM/02_RSS.pm line 563, <$fh> line 543.
2019.02.17 19:15:12 1: PERL WARNING: Subroutine RSS_analyzePerl redefined at ./FHEM/02_RSS.pm line 585, <$fh> line 543.
2019.02.17 19:15:13 1: PERL WARNING: Subroutine RSS_evalLayout redefined at ./FHEM/02_RSS.pm line 590, <$fh> line 543.
2019.02.17 19:15:13 1: PERL WARNING: Subroutine RSS_returnIMG redefined at ./FHEM/02_RSS.pm line 887, <$fh> line 543.
2019.02.17 19:15:13 1: PERL WARNING: Subroutine RSS_CGI redefined at ./FHEM/02_RSS.pm line 1047, <$fh> line 543.
2019.02.17 19:15:13 1: PERL WARNING: Subroutine plotFromUrl redefined at ./FHEM/02_RSS.pm line 1088, <$fh> line 543.
2019.02.17 19:15:13 1: Including ./log/fhem.save
2019.02.17 19:15:14 3: Device Fenster_Bad added to ActionDetector with 028:00 time
2019.02.17 19:15:14 3: Device Fenster_GWC added to ActionDetector with 028:00 time
2019.02.17 19:15:14 3: Device Steckdose_HM added to ActionDetector with 001:00 time
2019.02.17 19:15:15 3: Device TempSensorHZ added to ActionDetector with 012:00 time
2019.02.17 19:15:15 3: Device Zisterne added to ActionDetector with 028:00 time
2019.02.17 19:15:15 3: Device fh_Bad added to ActionDetector with 001:00 time
2019.02.17 19:15:16 3: Device hk_Bad added to ActionDetector with 001:00 time
2019.02.17 19:15:16 3: Device hk_GaesteWC added to ActionDetector with 001:00 time
2019.02.17 19:15:16 3: Device hk_Kellerflur added to ActionDetector with 001:00 time
2019.02.17 19:15:17 0: Featurelevel: 5.9
2019.02.17 19:15:17 0: Server started with 99 defined entities (fhem.pl:18497/2019-02-05 perl:5.024001 os:linux user:fhem pid:543)


Was mache ich falsch?

Es wäre nett, wenn sich jemand meiner annehmen  könnte - vielen Dank schonmal und viele Grüße

Peter

Deudi

Ich gehe mal davon aus, dass du das RSS Modul verwendest.
Den Plot erzeugen bei Aufruf der Seite (plotAsPng) ist Mist. Das kann sehr lange Blockieren, wenn der Plot aufwendiger ist. Besser ist es die png-Datei einfach regelmäßig im Hintergrund (!) zu erzeugen und diese lokale Datei einzubinden. Ich mache das mittels at so:


#
# Plot der Jahresprognose um 00:00:01
#
sub Plot_Strom_Prognose {
  # FORK
  my  $pid = fork();
  if (!defined $pid) {
    # Unable to fork
    Log 3, "Plot_Strom_Prognose: Fork fehlgeschlagen!";
  } elsif ($pid == 0) {
    # Child
    #
    # Schreibe Plot Prognose
    #
    # nice 10 setzen
    setpriority(0,0,10);
    open FILE, "> /opt/fhem_plots/stromsensor_prog.png";
    binmode FILE;
    print FILE plotAsPng("SVG_FileLog_Stromsensor_2");
    close FILE;
    exit 0;
  }
}


Schau dir mal Infopanel an.
Gigabyte Brix, Ubuntu 16.04.3 LTS, Homematic, Z-Wave, EnOcean, Shelly@MQTT, SIGNALduino, JeeLink DAVIS-Sketch

betateilchen

Mit InfoPanel anstatt RSS könntest Du direkt die SVG Ausgabe verwenden, ohne erst konvertieren zu müssen.

Zitat von: Deudi am 17 Februar 2019, 22:18:03
Den Plot erzeugen bei Aufruf der Seite (plotAsPng) ist Mist. Das kann sehr lange Blockieren, wenn der Plot aufwendiger ist.

Abgesehen davon, dass diese Aussage so pauschal nicht stimmt, geben die oben zitierten Logmeldungen keinerlei Hinweise darauf, dass die Ursache in dieser Richtung liegen könnte.

@Peter H.

Bau doch mal in Deine Layout Datei vor die img Zeile eine condition ein:

condition $init_done
-----------------------
Formuliere die Aufgabe möglichst einfach und
setze die Lösung richtig um - dann wird es auch funktionieren.
-----------------------
Lesen gefährdet die Unwissenheit!

Peter H.

@Deudi: Ich kann Deinen Lösungsvorschlag leider nicht umsetzen, da ich ihn nicht verstehe

@betateilchen: Ich habe die Codezeile 1:1 übernommen, bringt aber keine Änderung

Gibts zu InfoPanel auch so einen schönen Workshop wie Du ihn mal für die Nutzung des RSS-Moduls eingestellt hast?
https://forum.fhem.de/index.php/topic,22520.0.html

Deudi

#4
Ich will jetzt betateilchen nicht vorgreifen, ist ja irgendwie seine Baustelle.
Gibt mal in der FHEM Befehlszeile "list Name_deiner_RSS_definition" z.B. "list myrss" (ohne die "") ein und poste hier das Ergebnis.
Wie lange dauert das Erstellen des Plots, wenn du ihn mittels FHEM Weboberfläche aufrufst?

Edit: Typos
Gigabyte Brix, Ubuntu 16.04.3 LTS, Homematic, Z-Wave, EnOcean, Shelly@MQTT, SIGNALduino, JeeLink DAVIS-Sketch

Peter H.

Das erstellen des Plots geht schnell, hat auch nur zwei Temperaturwerte "im Bauch"
Hier das Ergebnis von "list"

Internals:
   DEF        jpg 192.168.178.26 /opt/fhem/FHEM/display.layout
   FUUID      5c521f8e-f33f-205b-842f-40ecf70cdd60327a
   LAYOUTFILE /opt/fhem/FHEM/display.layout
   NAME       FrameRSS
   NOTIFYDEV  global
   NR         162
   NTFY_ORDER 50-FrameRSS
   STATE      defined
   TYPE       RSS
   fhem:
     filename   /opt/fhem/FHEM/display.layout
     hostname   192.168.178.26
     layout     ### RSS Layout ###
font /usr/share/fonts/truetype/freefont/FreeMono.ttf # TrueType Schriftart
pt 25 # Schriftgroesse
time 0.12 0.16 # Uhrzeit
line 5 30 123 30 # Linie
condition $init_done
#img 0 32 0.2 png data { plotAsPng("SVG_FileLog_Puffer_1") } # Zahl vor png ist der Zoom, plotsize auf 800,220 eingestellt
pt 18 # Schriftgroesse
text 0.22 0.68 { ReadingsVal("CUL_TX_107","temperature","0"). " &deg;C" } # Temperatur Aussenfühler
pt 12 # Schriftgroesse
#text 0.19 0.79 { ReadingsVal("Pressure","pressure-nn","0"). " hPa" } # Luftdruck
text 0.65 0.79 { ReadingsVal("Zisterne","level","0"). " %" } # Füllstand Zisterne
text 0.01 0.79 "Zisterne"
text 0.01 0.88 "Puffer"
text 0.52 0.88 { ReadingsVal("TempPuffer_T1","temperature","0"). "&deg;C" } # Temp.Puffer
line 5 147 123 147 # Linie
pt 7 # Schriftgroesse
#text 0.20 0.98 { trim(getip()) } # IP-Adresse
     style      jpg
     useTextAlign 1
     useTextWrap 1
Attributes:
   size       128x160
   tmin       10