diff --git a/fhem/FHEM/59_PROPLANTA.pm b/fhem/FHEM/59_PROPLANTA.pm index df62a3ce5..865b8d6bc 100644 --- a/fhem/FHEM/59_PROPLANTA.pm +++ b/fhem/FHEM/59_PROPLANTA.pm @@ -1,11 +1,32 @@ -# $Id: $ #################################################################################################### +# $Id: $ # -# 23_PROPLANTA.pm +# 59_PROPLANTA.pm +# +# (c) 2014 Torsten Poitzsch < torsten . poitzsch at gmx . de > # # Weather forecast values for next 4 days are captured from http://www.proplanta.de/Wetter/-Wetter.html # inspired by 23_KOSTALPIKO.pm # +# Copyright notice +# +# This script is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# The GNU General Public License can be found at +# http://www.gnu.org/copyleft/gpl.html. +# A copy is found in the text file GPL.txt and important notices to the license +# from the author is found in LICENSE.txt distributed with these scripts. +# +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# This copyright notice MUST APPEAR in all copies of the script! +# #################################################################################################### ############################################### @@ -21,28 +42,6 @@ my $curCol = 0; my $curTextPos = 0; my $curReadingType = 0; - my %url_start =( "de" => "http://www.proplanta.de/Wetter/" - , "at" => "http://www.proplanta.de/Agrarwetter-Oesterreich/" - , "ch" => "http://www.proplanta.de/Agrarwetter-Schweiz/" - , "fr" => "http://www.proplanta.de/Agrarwetter-Frankreich/" - , "it" => "http://www.proplanta.de/Agrarwetter-Italien/" - ); - my %url_end = ( "de" => "-Wetter.html" - , "at" => "/" - , "ch" => "/" - , "fr" => "/" - , "it" => "/" - ); - - my %intensity = ( "keine" => 0 - ,"nein" => 0 - ,"gering" => 1 - ,"leicht" => 1 - ,"ja" => 1 - ,"mäßig" => 2 - ,"stark" => 3 - ); - # 1 = Span Text, 2 = readingName, 3 = Tag-Type # Tag-Types: # 1 = Number Col 3 @@ -51,6 +50,7 @@ my $curReadingType = 0; # 4 = Intensity-Text Col 2-5 # 5 = Time Col 2-5 # 6 = Time Col 3 + # 7 = Image Col 2-5 my @knownNoneIDs = ( ["Temperatur", "temperature", 1] ,["relative Feuchte", "humidity", 1] ,["Sichtweite", "visibility", 1] @@ -61,16 +61,21 @@ my $curReadingType = 0; ); # 1 = Tag-ID, 2 = readingName, 3 = Tag-Type (see above) - my @knownIDs = ( ["GS", "rad", 3] - ,["UV", "uv", 2] - ,["SD", "sun", 2] - ,["TMAX", "tempMaxC", 2] + my @knownIDs = ( + ["TMAX", "tempMaxC", 2] ,["TMIN", "tempMinC", 2] + ,["NW", "chOfRainDay", 2] + ,["NW_Nacht", "chOfRainNight", 2] + ,["BF", "frost", 4] ,["VERDUNST", "evapor", 4] ,["TAUBILDUNG", "dew", 4] - ,["BF", "frost", 4] - ,["MA", "moonRise", 5] - ,["MU", "moonSet", 5] + ,["SD", "sun", 2] + ,["UV", "uv", 2] + ,["GS", "rad", 3] + ,["WETTER_ID_MORGENS", "weatherMorning", 7] + ,["WETTER_ID_TAGSUEBER", "weatherDay", 7] + ,["WETTER_ID_ABENDS", "weatherEvening", 7] + ,["WETTER_ID_NACHT", "weatherNight", 7] ,["T_0", "temp00C", 2] ,["T_3", "temp03C", 2] ,["T_6", "temp06C", 2] @@ -87,8 +92,33 @@ my $curReadingType = 0; ,["BD_15", "cloud15", 2] ,["BD_18", "cloud18", 2] ,["BD_21", "cloud21", 2] + ,["MA", "moonRise", 5] + ,["MU", "moonSet", 5] ); + my %intensity = ( "keine" => 0 + ,"nein" => 0 + ,"gering" => 1 + ,"leicht" => 1 + ,"ja" => 1 + ,"mäßig" => 2 + ,"stark" => 3 + ); + + my %url_start =( "de" => "http://www.proplanta.de/Wetter/" + , "at" => "http://www.proplanta.de/Agrarwetter-Oesterreich/" + , "ch" => "http://www.proplanta.de/Agrarwetter-Schweiz/" + , "fr" => "http://www.proplanta.de/Agrarwetter-Frankreich/" + , "it" => "http://www.proplanta.de/Agrarwetter-Italien/" + ); + + my %url_end = ( "de" => "-Wetter.html" + , "at" => "/" + , "ch" => "/" + , "fr" => "/" + , "it" => "/" + ); + # here HTML::text/start/end are overridden sub text { @@ -151,7 +181,7 @@ sub text # Tag-Type 3 = Number Col 2|4|6|8 elsif ($curReadingType == 3) { - if ( 1 < $curCol && $curCol <= 5 ) + if ( 2 <= $curCol && $curCol <= 5 ) { if ( $curTextPos % 2 == 1 ) { @@ -164,7 +194,7 @@ sub text # Tag-Type 4 = Intensity-Text Col 2-5 elsif ($curReadingType == 4) { - if ( 1 < $curCol && $curCol <= 5 ) + if ( 2 <= $curCol && $curCol <= 5 ) { $readingName = "fc".($curCol-2)."_".$curReadingName; $text = $intensity{$text} if defined $intensity{$text}; @@ -225,11 +255,30 @@ sub start } } } - }; - if ($tagname eq "td") { + } + elsif ($tagname eq "td") + { $curCol++; $curTextPos = 0; - }; + } + #wetterstate and icon + elsif ($tagname eq "img" && $curReadingType == 7) + { + if ( 2 <= $curCol && $curCol <= 5 ) + { + # Alternative text + $readingName = "fc".($curCol-2)."_".$curReadingName; + $text = $attr->{alt}; + $text =~ s/Wetterzustand: //; + $text =~ s/ö/oe/; + $text =~ s/ä/ae/; + $text =~ s/ü/ue/; + $text =~ s/ß/ss/; + push( @texte, $readingName . "|" . $text ); + # Image URL + push( @texte, $readingName."Icon" . "|" . $attr->{src} ); + } + } } sub end @@ -257,7 +306,7 @@ use vars qw($readingFnAttributes); use vars qw(%defs); my $MODUL = "PROPLANTA"; -my $PROPLANTA_VERSION = "1.01"; +my $modulVersion = "1.01"; ######################################## @@ -304,6 +353,7 @@ sub PROPLANTA_Define($$) $hash->{STATE} = "Initializing"; $hash->{LOCAL} = 0; $hash->{INTERVAL} = 3600; + $hash->{fhem}{modulVersion} = $modulVersion; RemoveInternalTimer($hash); @@ -502,7 +552,7 @@ sub PROPLANTA_Aborted($)

PROPLANTA

- =end html @@ -580,21 +633,21 @@ sub PROPLANTA_Aborted($)

PROPLANTA

-
    +
      Define

        - define <Name> PROPLANTA [Stadt] [Ländercode] + define <Name> PROPLANTA [Stadt] [Ländercode]
        Das Modul extrahiert bestimmte Wetterdaten von der website www.proplanta.de.

        • [Stadt] (optional)
          - Die Stadt muss auf www.proplanta.de auswählbar sein. Wichtig!! Auf die gro&szig;en Anfangsbuchstaben achten.
        • + Die Stadt muss auf www.proplanta.de auswählbar sein. Wichtig!! Auf die gro&szig;en Anfangsbuchstaben achten.
          -
        • [Ländercode] (optional) +
        • [Ländercode] (optional)
          Mögliche Werte: de (Standard), at, ch, fr, it

        • @@ -605,13 +658,10 @@ sub PROPLANTA_Aborted($) Set
            - -
            - set <name> update -
            -
              - List die Wetterdaten sofort von der Webseite aus. -

            +
          • set <name> update +
            + Liest die Wetterdaten sofort von der Webseite aus. +

          @@ -622,7 +672,8 @@ sub PROPLANTA_Aborted($) Abfrageinterval in Sekunden (Standard 3600 = 1 Stunde)
        • URL <Internetadresse> -
          Internetadresse, von der die Daten ausgelesen werden (überschreibt die Werte im 'define'-Term
        • +
          + Internetadresse, von der die Daten ausgelesen werden (überschreibt die Werte im 'define'-Term
        • readingFnAttributes
        @@ -631,6 +682,8 @@ sub PROPLANTA_Aborted($) Vorhersagewerte

          +
        • fc0_chOfRainDay15C - Niederschlagsrisiko tagsüber heute in %
        • +
        • fc0_chOfRainNight15C - Niederschlagsrisiko nachts heute in %
        • fc0_cloud15C - Wolkenbedeckungsgrad 15:00 Uhr heute in %
        • fc0_dew - Taubildung heute (0=keine, 1=leicht, 2=mä&szig;ig, 3=stark)
        • fc0_evapor - Verdunstung heute (0=keine, 1=gering, 2=mä&szig;ig, 3=stark)
        • @@ -643,11 +696,12 @@ sub PROPLANTA_Aborted($)
        • fc0_tempMaxC - Minimaltemperatur heute in °C
        • fc0_temp15C - Temperatur 15:00 Uhr heute in °C
        • fc0_uv - UV-Index heute
        • +
        • fc0_weatherDay - Wetterzustand tagsüber heute
        • +
        • fc0_weatherDayIcon - Icon Wetterzustand tagsüber heute
        • etc.
        • -
        -

        - +
      +

    =end html_DE -=cut +=cut \ No newline at end of file