animierte windrose mit bordmittel möglich?

Begonnen von the ratman, 28 April 2016, 13:45:43

Vorheriges Thema - Nächstes Thema

franky08

Zitatbtw - deinen filter "myWS1080_nty" brauch ich eig. nur, wenn meine wetterstation andere werte als 0-360 liefern würde. hab ich das richtig verstanden?

Ja, meine Wetterstation liefert manchmal unsinnige Werte (schlechter Empfang, Störungen) aber den notify brauchst du, der triggert die sub, einfach den "Filter Teil" weglassen.

VG
Frank
Debian Bookworm auf HUNSN / Debian Bullseye auf 2.ter HUNSN F2F an 2x RaspiB
mit FHEM aktuell
22Zoll ViewSonic als Infodislay (WVC)
3xHMLAN mit vccu, raspmatic_rpi3, HMIP-HCU1

the ratman

#16
wow, ich hab richtig gedacht - is ne neuheit bei mir und fhem *g*
→do↑p!dnʇs↓shit←

the ratman

#17
so, jetzt hab ich meine erste ganz eigene lösung - gut, fleißig abgeschrieben von dir *g* - dafür so, dass ich mir selber helfen kann in nur einer einzigen readingsgroup.

noch weiß ich nicht, obs wirklich 100% rennt, aber schaun ma mal:
Internals:
   CFGFN
   DEF        Wetterstation:windDirection
   NAME       rg_Windrose
     valueFormat {
return "1" if( $VALUE > 0.1 && $VALUE < 45 );
return "2" if( $VALUE == 45 );
return "3" if( $VALUE > 45 && $VALUE < 90 );
return "4" if( $VALUE == 90 );
return "5" if( $VALUE > 90 && $VALUE < 135 );
return "6" if( $VALUE == 135 );
return "7" if( $VALUE > 135 && $VALUE < 180 );
return "8" if( $VALUE == 180 );
return "9" if( $VALUE > 180 && $VALUE < 225 );
return "a" if( $VALUE == 225 );
return "b" if( $VALUE > 225 && $VALUE < 270 );
return "c" if( $VALUE == 270 );
return "d" if( $VALUE > 270 && $VALUE < 315 );
return "e" if( $VALUE == 315 );
return "f" if( $VALUE > 315 && $VALUE < 360 );
return "g" if( $VALUE == 360 );
return "h" if( $VALUE == 0 );
}
     Positions:
       Wetterstation.windDirection 1:1
     Valueicon:
       windDirection.1 ws_NNO_kl.png
       windDirection.2 ws_NO_kl.png
       windDirection.3 ws_ONO_kl.png
       windDirection.4 ws_O_kl.png
       windDirection.5 ws_OSO_kl.png
       windDirection.6 ws_SO_kl.png
       windDirection.7 ws_SSO_kl.png
       windDirection.8 ws_S_kl.png
       windDirection.9 ws_SSW_kl.png
       windDirection.a ws_SW_kl.png
       windDirection.b ws_WSW_kl.png
       windDirection.c ws_W_kl.png4
       windDirection.d ws_WNW_kl.png
       windDirection.e ws_NW_kl.png
       windDirection.f ws_NNW_kl.png
       windDirection.g ws_N_kl.png
       windDirection.h ws_N_kl.png
Attributes:
   nonames    1
   notime     1
   room       Testgeräte
   valueFormat {
return "1" if( $VALUE > 0.1 && $VALUE < 45 );
return "2" if( $VALUE == 45 );
return "3" if( $VALUE > 45 && $VALUE < 90 );
return "4" if( $VALUE == 90 );
return "5" if( $VALUE > 90 && $VALUE < 135 );
return "6" if( $VALUE == 135 );
return "7" if( $VALUE > 135 && $VALUE < 180 );
return "8" if( $VALUE == 180 );
return "9" if( $VALUE > 180 && $VALUE < 225 );
return "a" if( $VALUE == 225 );
return "b" if( $VALUE > 225 && $VALUE < 270 );
return "c" if( $VALUE == 270 );
return "d" if( $VALUE > 270 && $VALUE < 315 );
return "e" if( $VALUE == 315 );
return "f" if( $VALUE > 315 && $VALUE < 360 );
return "g" if( $VALUE == 360 );
return "h" if( $VALUE == 0 );
}
   valueIcon  {
'windDirection.1'=>'ws_NNO_kl.png',
'windDirection.2'=>'ws_NO_kl.png',
'windDirection.3'=>'ws_ONO_kl.png',
'windDirection.4'=>'ws_O_kl.png',
'windDirection.5'=>'ws_OSO_kl.png',
'windDirection.6'=>'ws_SO_kl.png',
'windDirection.7'=>'ws_SSO_kl.png',
'windDirection.8'=>'ws_S_kl.png',
'windDirection.9'=>'ws_SSW_kl.png',
'windDirection.a'=>'ws_SW_kl.png',
'windDirection.b'=>'ws_WSW_kl.png',
'windDirection.c'=>'ws_W_kl.png4',
'windDirection.d'=>'ws_WNW_kl.png',
'windDirection.e'=>'ws_NW_kl.png',
'windDirection.f'=>'ws_NNW_kl.png',
'windDirection.g'=>'ws_N_kl.png',
'windDirection.h'=>'ws_N_kl.png'
}
→do↑p!dnʇs↓shit←

dieter114

Hallo Ratman,

kann es sein das in der Definition noch ein kleiner "Denkfehler" ist?
Z.B. die Pos 45 = 2 wird nur ausgegeben wenn es genau 45 Grad sind.
Diesen Wert wird es in der Realität nie geben.
Also wird immer dann die Pos 1 oder 3 ausgegeben.

Gruß Wolfdieter
Grüße WDS

RPi II+III+V,OWX, HM Zisterne, MAPLESDuino(adv), ESPEasy, Tasmota, MQTT2Server, WU-Upload, TabletUI, Poolsteuerung fhem, Fronius, BYD Solaranlage

the ratman

jo, wird so sein ... hab ich ja nur kopiert damals *g*
→do↑p!dnʇs↓shit←

dl9sec

Hallo zusammen,

ich weiß, dieses Thema ist schon ein paar Jahre alt, aber eventuell für den Einen oder Anderen doch noch interessant, da es hierzu recht wenig gibt.

Auch ich wollte eine Windrose zur Anzeige der Windrichtung von meiner Bresser 5-in-1 Wetterstaion in der Webansicht haben, aber da Perl für mich der absolute Graus ist, musste da eine andere Lösung her.

Irgendwie bin ich über SVG-Grafiken gestolpert und die Möglichkeit, einer SVG-Datei in einem HTML-Aufruf Parameter zu übergeben (https://www.w3.org/TR/SVGParamPrimer/ und https://www.w3.org/TR/SVGParamPrimer/param.js). Copilot hat mir freundlicherweise eine schöne Windrose generiert, der ich dann noch einen dickern Windrichtungspfeil spendiert habe (siehe Anhang). In der SVG-Datei steckt neben den eigentlichen Grafikfunktionen noch ein JS-Anteil, der recht universell und auf mehrere Weisen Parameter entgegen nimmt und in der SVG dann entsprechende Ersetzungen vornimmt.

Einige Tage Experimentieren hat es gebraucht, aber die Lösung ist am Ende recht einfach:

Die Datei "myWindRose1.svg" ins Verzeichnis "/opt/fhem/www/images/default" legen (oder entsprechendes Verzeichnis, je nach Installation) und die fhem.cfg um folgenden Eintrag (der natürlich je nach dem woher der Windrichtungswert kommt und je nach gewünschten Attributen angepasst werden muss) ergänzen:

# SVG-Windrose mit Template myWindRose1.svg
define weblink_BR5IN1_WindRose weblink htmlCode {\
  my $wddeg = ReadingsVal("BR5IN1","windDirectionDegree",0);;\
  return "<div><object type=\"image/svg+xml\" data=\"/fhem/images/default/myWindRose1.svg?windDir=rotate($wddeg)\"></object></div>">
}

Die Variable $wddeg hält die Windrichtung in Grad. Diese Variable wird dann dem SVG-Objekt als Parameter "windDir" mit samt dem Rotationsbefehl übergeben.

Funktioniert soweit prima bei mir.

Zum JS-Code ist folgendes zu beachten: "The script may be used as is, and is released under a CC license, but it is not intended as production code. Content authors are encouraged to experiment with this code, and to comment to the SVG WG at www-svg@w3.org with suggestions and critiques of the specification based on experience."
Unter welcher CC-Lizenz der JS-Code tatsächlich steht ist nirgends vermerkt.
Da die Windrose KI-generiert ist, ist sie frei verwendbar (mein eigener Beitrag hierzu ist nicht nennenswert).

Viel Spaß damit ;D

Gruß, Thorsten