neues Modul Astro.pm

Begonnen von Prof. Dr. Peter Henning, 05 Juli 2017, 21:39:21

Vorheriges Thema - Nächstes Thema

Prof. Dr. Peter Henning


moonsorrox

welches ist denn momentan die richtige 99_myUtils_Astro.pm, da ich das mit dem Mond nicht zum laufen bekomme..?

so sieht meine aktuelle aus:
##########################################################################################################################
# $Id: 99_myUtils_Astro.pm 0011 2017-07-15 00:00:00Z Fhemmike $
#


package main;

use strict;
use warnings;
use POSIX;


sub myUtils_Astro_Initialize($$)
{
  my ($hash) = @_;
}

sub moon_pics($)
{
my ($name)    = @_;
my $picNo     = ReadingsVal("Astro","MoonAge",0);
my $picOrd    = "/fhem/www/images/phasenbilder/";
my $picPath   = "";


  if(  $picNo < 180 ){
    $picNo = int($picNo/180*49+51);
  }else{
    $picNo = int(($picNo/180-1)*49+1);
  }

$picPath =  $picOrd.$picNo.".png";

return $picPath
}


sub Moon_to_html($)
{
   my($hash) = @_;
   $hash = $defs{$hash} if( ref($hash) ne 'HASH' );
   return undef if( !$hash );

   my $name = $hash->{NAME};
   my $scale = "100";
   my $state = $hash->{STATE};
   my $pathToPictures = ReadingsVal("Astro", "ftui", "");
   my $ret;

   $ret .= "<div style='width:".$scale."px; text-align: center;'>";
   $ret .= "<img src='$pathToPictures$\' width='$scale' height='$scale'>";
   $ret .= "</div>";

   $hash->{fhem}->{cached} = $ret;

   return $ret;
}

1;
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

Michael

Moin moonsorrox

Ich habe diese beiden Einträge in der .pm

Und mit define Moon_weblink weblink htmlCode { Moon_to_html("myAstro") } bekomme ich das Mondbild.

Im Forum findet am das ganze unter : https://forum.fhem.de/index.php/topic,73951.msg660570.html#msg660570

########################################################################
### MondPhasenBilder

sub moon_pics($)
{
my ($name)    = @_;
my $picNo     = ReadingsVal("myAstro","MoonAge",0);
my $picOrd    = "/fhem/www/phasenbilder/";
my $picPath   = "";


#-- moonage 0 - 180 => 51 - 100
  if(  $picNo < 180 ){
    $picNo = int($picNo/180*49+51);
#-- moonage 180 - 360 => 1 - 50
  }else{
    $picNo = int(($picNo/180-1)*49+1);
  }

$picPath =  $picOrd.$picNo.".png";

return $picPath;
}

########################################################################
### Mond HTML

sub Moon_to_html($)
{
   my($hash) = @_;
   $hash = $defs{$hash} if( ref($hash) ne 'HASH' );
   return undef if( !$hash );

   my $name           = $hash->{NAME};
   my $scale          = "25";
   my $state          = $hash->{STATE};
   my $pathToPictures = ReadingsVal("myAstro", "ftuiMoon", "");
   my $ret;

   $ret .= "<div style='width:".$scale."px; text-align: center;'>";
   $ret .= "<img src='$pathToPictures$\' width='$scale' height='$scale'>";
   $ret .= "</div>";

   $hash->{fhem}->{cached} = $ret;

   return $ret;
}


PS. Bitte auf die Pfade achten.
Gruß, Michael

FHEM 6.0 auf RPi 3
CUL V3 868 Mhz | JeeLink LaCrosse & PCA301 | CCU3
BMP085(180) | 14x TX29DTH-IT | 5x PCA 301 | SMA Peripheries | MobileAlerts MA-10(100,120PRO,200,251,410,650,660,800) | HM IP

moonsorrox

#408
das habe ich alles so und die Links sind ja klar anzupassen, habe ich auch und den weblink ebenfalls, aber keine Anzeige.
bei mir liegen die Bilder eigentlich auf dem Standardpfad als png, sicher viel zu viele weil ich hier aus dem Forum irgendwo 100 hatte, aber das kann ich später immer noch anpassen.
Dazu muss es erst mal laufen
/fhem/www/images/phasenbilder

was ich noch geändert habe, ist denke ich für ftui, da heißt das bei mir "myAstro:ftui"
("myAstro", "ftui", "");


hab jetzt nochmal geschaut und bekomme diese Meldungen im log:
2021.01.05 01:19:45 3: eval: { Moon_to_html("myAstro") }
2021.01.05 01:19:45 1: PERL WARNING: Use of uninitialized value $\ in concatenation (.) or string at ./FHEM/99_myUtils_Astro.pm line 62.
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

Michael

Moin

Den Pfad habe ich ins Astro Modul mit einem userRaeding ftuiMoon {moon_pics("myAstro") } angelegt.

Das ist die erste sub moon_pics($) in der .pm.
Die zweite sub Moon_to_html($) generiert das Bild.
Gruß, Michael

FHEM 6.0 auf RPi 3
CUL V3 868 Mhz | JeeLink LaCrosse & PCA301 | CCU3
BMP085(180) | 14x TX29DTH-IT | 5x PCA 301 | SMA Peripheries | MobileAlerts MA-10(100,120PRO,200,251,410,650,660,800) | HM IP

khk123

Ich hab das ohne 99_myUtils gelöst.

Unter /opt/fhem/www/images/phasenbilder/ sind meine Mondphasenbilder entpackt von https://www.stilkunst.de/c62_stockgrafics/phases_of_moon/phases_of_moon.php abgelegt.
Mein Astro-Device:

attr Astro DbLogExclude .*
attr Astro DbLogInclude MoonAge,Mondbild,MoonPhaseN,MoonPhasePic
attr Astro devStateIcon { '<div><img src='.ReadingsVal($name,"MoonPhasePic","0").' height="100" width="100">' }
attr Astro icon weather_moon_phases_8
attr Astro interval 3600
attr Astro room Wetter
attr Astro userReadings MoonPhasePic { my $pb = sprintf "%03d",int(ReadingsVal($name,"MoonAge",0));;;;\
              ("/fhem_live/www/images/phasenbilder/stilkunst_moon_".$pb.".png")\
     }
attr Astro verbose 0


Die Anzeige in FHEM siehe anh. Screenshot.

Ist vom Volumen der Bildern her vieleicht etwas aufwändig, aber nett anzusehen. :-)

Viele Grüße
Karlheinz




FHEM6.2, RasPi4, RasPi Zero W,
CUL V3, HM, ZWave, IT, vcontrol, owntracks, alexa

moonsorrox

das ist doch die Datenbank von Fhem wenn ich mich nicht täusche, oder
DbLogExclude .*

damit arbeite ich leider nicht, oder zumindest habe ich mich damit noch nie beschäftigt.
Ich werde es mir aber trotzdem mal anschauen.
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

moonsorrox

Zitat von: Michael am 05 Januar 2021, 10:02:54
Moin

Den Pfad habe ich ins Astro Modul mit einem userRaeding ftuiMoon {moon_pics("myAstro") } angelegt.

Das ist die erste sub moon_pics($) in der .pm.
Die zweite sub Moon_to_html($) generiert das Bild.

irgend etwas läuft hier schief... ich muss mal suchen... das sind die Meldungen im log
2021.01.05 12:46:22 3: eval: { Moon_to_html("myAstro") }
2021.01.05 12:46:22 1: PERL WARNING: Use of uninitialized value $\ in concatenation (.) or string at ./FHEM/99_myUtils_Astro.pm line 62.


das steht im angemeckerten Pfad in der Astro, sollte etwas mit dem Pfad nicht stimmen, aber der ist bei mir richtig eingetragen, oder sehe ich nicht durch  :-\ :-\
  $ret .= "<img src='$pathToPictures$\' width='$scale' height='$scale'>";

Das hier ist meine Astro Utils
##########################################################################################################################
# $Id: 99_myUtils_Astro.pm 0011 2017-07-15 00:00:00Z Fhemmike $
#


package main;

use strict;
use warnings;
use POSIX;


sub myUtils_Astro_Initialize($$)
{
  my ($hash) = @_;
}



########################################################################
### MondPhasenBilder

sub moon_pics($)
{
my ($name)    = @_;
my $picNo     = ReadingsVal("myAstro","MoonAge",0);
my $picOrd    = "/fhem/www/images/phasenbilder/";
my $picPath   = "";


#-- moonage 0 - 180 => 51 - 100
  if(  $picNo < 180 ){
    $picNo = int($picNo/180*49+51);
#-- moonage 180 - 360 => 1 - 50
  }else{
    $picNo = int(($picNo/180-1)*49+1);
  }

$picPath =  $picOrd.$picNo.".png";

return $picPath;
}


########################################################################
### Mond HTML


sub Moon_to_html($)
{
   my($hash) = @_;
   $hash = $defs{$hash} if( ref($hash) ne 'HASH' );
   return undef if( !$hash );

   my $name           = $hash->{NAME};
   my $scale          = "25";
   my $state          = $hash->{STATE};
   my $pathToPictures = ReadingsVal("myAstro", "ftui", "");
   my $ret;

   $ret .= "<div style='width:".$scale."px; text-align: center;'>";
   $ret .= "<img src='$pathToPictures$\' width='$scale' height='$scale'>";
   $ret .= "</div>";

   $hash->{fhem}->{cached} = $ret;

   return $ret;
}


1;


EDIT://
ich sehe gerade etwas, ich habe kein userReading angelegt  :-\
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

moonsorrox

OK, das wars... mit dem userreading  :-\ :-\

Ist jetzt zwar sehr klein, der Mond aber das kann man sicher noch verändern...
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

Michael

ZitatIst jetzt zwar sehr klein, der Mond aber das kann man sicher noch verändern...
Ja, in der sub Moon_to_html($) unter my $scale = "25";
Gruß, Michael

FHEM 6.0 auf RPi 3
CUL V3 868 Mhz | JeeLink LaCrosse & PCA301 | CCU3
BMP085(180) | 14x TX29DTH-IT | 5x PCA 301 | SMA Peripheries | MobileAlerts MA-10(100,120PRO,200,251,410,650,660,800) | HM IP

moonsorrox

Zitat von: Michael am 05 Januar 2021, 15:43:27
Ja, in der sub Moon_to_html($) unter my $scale = "25";

jou vielen Dank, hat ja alles etwas gedauert.
In Fhem ist es mir nicht so wichtig, aber in meinem FTUI sieht der Mond mal richtig geil aus  ;)
Ich habe die png mit dem gelebn Kontrast... Super  :D
Intel-NUC i5: FHEM-Server 6.1 :: Perl v5.18.2

Homematic: HM-USB-CFG2,HM-CFG-LAN Adapter, HM-LC-BL1-FM, HM-LC-Sw1PBU-FM, HM-LC-Sw1-PI-2, HM-WDS10-TH-O, HM-CC-TC, HM-LC-SW2-FM

khk123

#416
Zitat von: moonsorrox am 05 Januar 2021, 12:50:33
das ist doch die Datenbank von Fhem wenn ich mich nicht täusche, oder
DbLogExclude .*

damit arbeite ich leider nicht, oder zumindest habe ich mich damit noch nie beschäftigt.
Ich werde es mir aber trotzdem mal anschauen.

Das ist nur eine Anweisung was in meine Datenbank geloggt werden soll oder auch nicht. Die Zeile einfach löschen, das hat nichts mit den restl. Definitionen zu tun.
FHEM6.2, RasPi4, RasPi Zero W,
CUL V3, HM, ZWave, IT, vcontrol, owntracks, alexa

MDietrich

Hallo,
auf Wunsch meiner Regierung habe ich mir im Modul Astro.pm die Readings für SunSign und SunSignN angesehen. Nach dem Tierkreis ist der Wassermann das 11. Tierkreiszeichen und Fische das 12. Das Reading SunSign passt zum Datum.
Nach etwas Nachdenken habe ich dann einmal das Datum 22.03. verwendet - und siehe da, SunSignN = 0 für Widder.
Ist dies Absicht? Aus meiner Sicht wäre es "logisch" das Zählen mit 1 zu beginnen.

okay: wichtig=> nein, dringend=> nein, schön:ja  :)

Gruß
Matthias
FB 6591 Cable / Raspberry 3b+ (Bookworm) / 4xECHO DOT 4/ Homematic Thermostate, Fenster- und Fenster-Sensoren / Philips HUE / CUL-HM /  Zigbee Schalter und Lampen / Shelly 1

Prof. Dr. Peter Henning

ZitatAus meiner Sicht wäre es "logisch" das Zählen mit 1 zu beginnen
Aus meiner Sicht nicht. In Perl ist das anders, und darum bleibt es auch hier so.

LG

pah

MDietrich

Guten Abend,
wie gesagt, ich kann damit leben. Ist abhängig von der Blickrichtung ja "nur" ein +1 bzw. -1

Danke für das Modul, ist super!!
FB 6591 Cable / Raspberry 3b+ (Bookworm) / 4xECHO DOT 4/ Homematic Thermostate, Fenster- und Fenster-Sensoren / Philips HUE / CUL-HM /  Zigbee Schalter und Lampen / Shelly 1