#################################################################################################### # # 77_UWZ.pm # # (c) 2015 Tobias D. Oestreicher # # Special thanks goes to comitters: # - Marko Oldenburg (leongaultier at gmail dot com) # # Storm warnings from unwetterzentrale.de # inspired by 59_PROPLANTA.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! # # # # $Id$ # #################################################################################################### # also a thanks goes to hexenmeister ############################################## package main; use strict; use feature qw/say switch/; use warnings; no if $] >= 5.017011, warnings => 'experimental::lexical_subs','experimental::smartmatch'; my $missingModul; eval "use LWP::UserAgent;1" or $missingModul .= "LWP::UserAgent "; eval "use LWP::Simple;1" or $missingModul .= "LWP::Simple "; eval "use HTTP::Request;1" or $missingModul .= "HTTP::Request "; eval "use HTML::Parser;1" or $missingModul .= "HTML::Parser "; eval "use JSON;1" or $missingModul .= "JSON "; eval "use Encode::Guess;1" or $missingModul .= "Encode::Guess "; eval "use Text::Iconv;1" or $missingModul .= "Text::Iconv "; require 'Blocking.pm'; require 'HttpUtils.pm'; use vars qw($readingFnAttributes); use vars qw(%defs); my $MODUL = "UWZ"; my $version = "1.0.1"; my $countrycode = "DE"; my $plz = "77777"; my $uwz_alert_url = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=getWarning&language=de&areaID=UWZ" . $countrycode . $plz; ######################################## sub UWZ_Log($$$) { my ( $hash, $loglevel, $text ) = @_; my $xline = ( caller(0) )[2]; my $xsubroutine = ( caller(1) )[3]; my $sub = ( split( ':', $xsubroutine ) )[2]; $sub =~ s/UWZ_//; my $instName = ( ref($hash) eq "HASH" ) ? $hash->{NAME} : $hash; Log3 $instName, $loglevel, "$MODUL $instName: $sub.$xline " . $text; } ######################################## sub UWZ_Map2Image($$) { my $uwz_de_url = "http://www.unwetterzentrale.de/images/map/"; my $uwz_at_url = "http://unwetter.wetteralarm.at/images/map/"; my ( $hash, $smap ) = @_; my $lmap; $smap=lc($smap); $lmap->{'europa'}=$uwz_de_url.'europe_index.png'; $lmap->{'deutschland'}=$uwz_de_url.'deutschland_index.png'; $lmap->{'deutschland-small'}=$uwz_de_url.'deutschland_preview.png'; $lmap->{'niedersachsen'}=$uwz_de_url.'niedersachsen_index.png'; $lmap->{'bremen'}=$uwz_de_url.'niedersachsen_index.png'; $lmap->{'bayern'}=$uwz_de_url.'bayern_index.png'; $lmap->{'schleswig-holstein'}=$uwz_de_url.'schleswig_index.png'; $lmap->{'hamburg'}=$uwz_de_url.'schleswig_index.png'; $lmap->{'mecklenburg-vorpommern'}=$uwz_de_url.'meckpom_index.png'; $lmap->{'sachsen'}=$uwz_de_url.'sachsen_index.png'; $lmap->{'sachsen-anhalt'}=$uwz_de_url.'sachsenanhalt_index.png'; $lmap->{'nordrhein-westfalen'}=$uwz_de_url.'nrw_index.png'; $lmap->{'thueringen'}=$uwz_de_url.'thueringen_index.png'; $lmap->{'rheinland-pfalz'}=$uwz_de_url.'rlp_index.png'; $lmap->{'saarland'}=$uwz_de_url.'rlp_index.png'; $lmap->{'baden-wuerttemberg'}=$uwz_de_url.'badenwuerttemberg_index.png'; $lmap->{'hessen'}=$uwz_de_url.'hessen_index.png'; $lmap->{'brandenburg'}=$uwz_de_url.'brandenburg_index.png'; $lmap->{'berlin'}=$uwz_de_url.'brandenburg_index.png'; $lmap->{'oesterreich'}=$uwz_at_url.'oesterreich_index.png'; $lmap->{'burgenland'}=$uwz_at_url.'burgenland_index.png'; $lmap->{'kaernten'}=$uwz_at_url.'kaernten_index.png'; $lmap->{'niederoesterreich'}=$uwz_at_url.'niederoesterreich_index.png'; $lmap->{'oberoesterreich'}=$uwz_at_url.'oberoesterreich_index.png'; $lmap->{'salzburg'}=$uwz_at_url.'salzburg_index.png'; $lmap->{'steiermark'}=$uwz_at_url.'steiermark_index.png'; $lmap->{'tirol'}=$uwz_at_url.'tirol_index.png'; $lmap->{'vorarlberg'}=$uwz_at_url.'vorarlberg_index.png'; $lmap->{'wien'}=$uwz_at_url.'wien_index.png'; $lmap->{'isobaren1'}="http://www.unwetterzentrale.de/images/icons/UWZ_ISO_00.jpg"; $lmap->{'isobaren2'}="http://www.wetteralarm.at/uploads/pics/UWZ_EURO_ISO_GER_00.jpg"; return $lmap->{$smap}; } ################################### sub UWZ_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "UWZ_Define"; $hash->{UndefFn} = "UWZ_Undef"; $hash->{SetFn} = "UWZ_Set"; $hash->{GetFn} = "UWZ_Get"; $hash->{AttrList} = "INTERVAL ". "URL ". "PLZ ". "download:0,1 ". "savepath ". "maps ". "humanreadable:0,1 ". $readingFnAttributes; foreach my $d(sort keys %{$modules{UWZ}{defptr}}) { my $hash = $modules{UWZ}{defptr}{$d}; $hash->{VERSION} = $version; } } ################################### sub UWZ_Define($$) { my ( $hash, $def ) = @_; my $name = $hash->{NAME}; my $lang = ""; my @a = split( "[ \t][ \t]*", $def ); return "Error: Perl moduls ".$missingModul."are missing on this system" if( $missingModul ); return "Wrong syntax: use define UWZ [CountryCode] [PLZ] [Interval] " if int(@a) > 6; $hash->{STATE} = "Initializing"; $hash->{CountryCode} = $a[2]; $hash->{PLZ} = $a[3]; $hash->{URL} = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=getWarning&language=de&areaID=UWZ" . $a[2] . $a[3]; $hash->{fhem}{LOCAL} = 0; $hash->{INTERVAL} = $a[4]; $hash->{VERSION} = $version; RemoveInternalTimer($hash); #Get first data after 12 seconds InternalTimer( gettimeofday() + 12, "UWZ_Start", $hash, 0 ); return undef; } ##################################### sub UWZ_Undef($$) { my ( $hash, $arg ) = @_; RemoveInternalTimer( $hash ); BlockingKill( $hash->{helper}{RUNNING_PID} ) if ( defined( $hash->{helper}{RUNNING_PID} ) ); return undef; } ##################################### sub UWZ_Set($@) { my ( $hash, @a ) = @_; my $name = $hash->{NAME}; my $reUINT = '^([\\+]?\\d+)$'; my $usage = "Unknown argument $a[1], choose one of update:noArg "; return $usage if ( @a < 2 ); my $cmd = lc( $a[1] ); given ($cmd) { when ("?") { return $usage; } when ("update") { UWZ_Log $hash, 4, "set command: " . $a[1]; $hash->{fhem}{LOCAL} = 1; UWZ_Start($hash); $hash->{fhem}{LOCAL} = 0; } default { return $usage; } } return; } ##################################### sub UWZ_Get($@) { my ( $hash, @a ) = @_; my $name = $hash->{NAME}; my $usage = "Unknown argument $a[1], choose one of Sturm:noArg Schneefall:noArg Regen:noArg Extremfrost:noArg Waldbrand:noArg Gewitter:noArg Glaette:noArg Hitze:noArg Glatteisregen:noArg Bodenfrost:noArg Hagel:noArg "; return $usage if ( @a < 2 ); if ($a[1] =~ /^Sturm/) { UWZ_GetCurrent($hash,2); } elsif ($a[1] =~ /^Schneefall/) { UWZ_GetCurrent($hash,3); } elsif ($a[1] =~ /^Regen/) { UWZ_GetCurrent($hash,4); } elsif ($a[1] =~ /^Extremfrost/) { UWZ_GetCurrent($hash,5); } elsif ($a[1] =~ /^Waldbrand/) { UWZ_GetCurrent($hash,6); } elsif ($a[1] =~ /^Gewitter/) { UWZ_GetCurrent($hash,7); } elsif ($a[1] =~ /^Glaette/) { UWZ_GetCurrent($hash,8); } elsif ($a[1] =~ /^Hitze/) { UWZ_GetCurrent($hash,9); } elsif ($a[1] =~ /^Glatteisregen/) { UWZ_GetCurrent($hash,10); } elsif ($a[1] =~ /^Bodenfrost/) { UWZ_GetCurrent($hash,11); } elsif ($a[1] =~ /^Hagel/) { UWZ_GetCurrentHail($hash); } else { return $usage; } } ##################################### sub UWZ_GetCurrent($@) { my ( $hash, @a ) = @_; my $name = $hash->{NAME}; my $out; my $curTimestamp = time(); if ( ReadingsVal($name,"WarnCount", 0) eq 0 ) { $out = "inactive"; } else { for(my $i= 0;$i < ReadingsVal($name,"WarnCount", 0);$i++) { if ( (ReadingsVal($name,"Warn_".$i."_Start","") le $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_End","") ge $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_Type","") eq $a[0]) ) { $out= "active"; last; } else { $out = "inactive"; } } } return $out; } ##################################### sub UWZ_GetCurrentHail($) { my ( $hash ) = @_; my $name = $hash->{NAME}; my $out; my $curTimestamp = time(); if ( ReadingsVal($name,"WarnCount", 0) eq 0 ) { $out = "inactive"; } else { for(my $i= 0;$i < ReadingsVal($name,"WarnCount", 0);$i++) { if ( (ReadingsVal($name,"Warn_".$i."_Start","") le $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_End","") ge $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_Hail","") eq 1) ) { $out= "active"; last; } else { $out= "inactive"; } } } return $out; } ##################################### sub UWZ_JSONAcquire($$) { my ($hash, $URL) = @_; my $name = $hash->{NAME}; return unless (defined($hash->{NAME})); UWZ_Log $hash, 4, "Start capturing of $URL"; my $err_log = ""; my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 ); my $request = HTTP::Request->new( GET => $URL ); my $response = $agent->request($request); $err_log = "Can't get $URL -- " . $response->status_line unless( $response->is_success ); if ( $err_log ne "" ) { readingsSingleUpdate($hash, "lastConnection", $response->status_line, 1); UWZ_Log $hash, 1, "Error: $err_log"; return "Error|Error " . $response->status_line; } UWZ_Log $hash, 4, length($response->content)." characters captured"; return $response->content; } ##################################### sub UWZ_Start($) { my ($hash) = @_; my $name = $hash->{NAME}; return unless (defined($hash->{NAME})); $hash->{INTERVAL} = AttrVal( $name, "INTERVAL", $hash->{INTERVAL} ); if(!$hash->{fhem}{LOCAL} && $hash->{INTERVAL} > 0) { # set up timer if automatically call RemoveInternalTimer( $hash ); InternalTimer(gettimeofday() + $hash->{INTERVAL}, "UWZ_Start", $hash, 1 ); return undef if( AttrVal($name, "disable", 0 ) == 1 ); } if ( AttrVal( $name, 'URL', '') eq '' && not defined( $hash->{URL} ) ) { UWZ_Log $hash, 3, "missing URL"; return; } $hash->{helper}{RUNNING_PID} = BlockingCall( "UWZ_Run", # callback worker task $name, # name of the device "UWZ_Done", # callback result method 120, # timeout seconds "UWZ_Aborted", # callback for abortion $hash ); # parameter for abortion } ##################################### sub UWZ_Aborted($) { my ($hash) = @_; delete( $hash->{helper}{RUNNING_PID} ); } ##################################### # asyncronous callback by blocking sub UWZ_Done($) { my ($string) = @_; return unless ( defined($string) ); # all term are separated by "|" , the first is the name of the instance my ( $name, %values ) = split( "\\|", $string ); my $hash = $defs{$name}; return unless ( defined($hash->{NAME}) ); # delete the marker for RUNNING_PID process delete( $hash->{helper}{RUNNING_PID} ); ## alter Code sollte gelöscht werden # # fhem("deletereading ".$hash->{NAME}." .*"); # # foreach my $skey (grep /^(Warn_?_|WarnCount)/ ,sort keys %{ $hash->{READINGS} }) { # UWZ_Log $hash, 3, "Delete Reading:$skey"; # delete $hash->{READINGS}{$skey}; # } UWZ_Log $hash, 4, "Delete old Readings"; CommandDeleteReading(undef, "$hash->{NAME} Warn_?_.*"); # UnWetterdaten speichern readingsBeginUpdate($hash); if ( defined $values{Error} ) { readingsBulkUpdate( $hash, "lastConnection", $values{Error} ); } else { while (my ($rName, $rValue) = each(%values) ) { readingsBulkUpdate( $hash, $rName, $rValue ); UWZ_Log $hash, 5, "reading:$rName value:$rValue"; } if (keys %values > 0) { my $newState; if (defined $values{WarnCount}) { $newState = "Warnungen: " . $values{WarnCount}; } else { $newState = "Error: Could not capture all data. Please check CountryCode and PLZ."; } readingsBulkUpdate($hash, "state", $newState); readingsBulkUpdate( $hash, "lastConnection", keys( %values )." values captured in ".$values{durationFetchReadings}." s" ); UWZ_Log $hash, 4, keys( %values )." values captured"; } else { readingsBulkUpdate( $hash, "lastConnection", "no data found" ); UWZ_Log $hash, 1, "No data found. Check city name or URL."; } } readingsEndUpdate( $hash, 1 ); } ##################################### sub UWZ_Run($) { my ($name) = @_; my $ptext=$name; my $UWZ_CC; my $UWZ_INT; my $UWZ_download; my $UWZ_savepath; my $UWZ_humanreadable; return unless ( defined($name) ); my $hash = $defs{$name}; return unless (defined($hash->{NAME})); my $readingStartTime = time(); my $attrCountryCode = AttrVal( $name, 'CountryCode', '' ); my $attrPLZ = AttrVal( $name, 'PLZ', "" ); my $attrINTERVAL = AttrVal( $name, 'INTERVAL',''); my $attrdownload = AttrVal( $name, 'download',''); my $attrsavepath = AttrVal( $name, 'savepath',''); my $maps2fetch = AttrVal( $name, 'maps',''); ## begin redundant Reading switch my $attrhumanreadable = AttrVal( $name, 'humanreadable',''); ## end redundant Reading switch # preset CountryCode if ($attrCountryCode eq "") { $UWZ_CC = "DE"; } else { $UWZ_CC = $attrCountryCode; } # preset INTERVAL if ($attrINTERVAL eq "") { $UWZ_INT = 3600; } else { $UWZ_INT = $attrINTERVAL; } # preset download if ($attrdownload eq "") { $UWZ_download = 0; } else { $UWZ_download = $attrdownload; } # preset savepath if ($attrsavepath eq "") { $UWZ_savepath = "/tmp/"; } else { $UWZ_savepath = $attrsavepath; } # preset humanreadable if ($attrhumanreadable eq "") { $UWZ_humanreadable = 0; } else { $UWZ_humanreadable = $attrhumanreadable; } if ( $UWZ_download == 1 ) { if ( ! defined($maps2fetch) ) { $maps2fetch = "deutschland"; } UWZ_Log $hash, 4, "Maps2Fetch : ".$maps2fetch; my @maps = split(' ', $maps2fetch); my $uwz_de_url = "http://www.unwetterzentrale.de/images/map/"; foreach my $smap (@maps) { UWZ_Log $hash, 4, "Download map : ".$smap; my $img = UWZ_Map2Image($hash,$smap); if (!defined($img) ) { $img=$uwz_de_url.'deutschland_index.png'; } my $code = getstore($img, $UWZ_savepath.$smap.".png"); if($code == 200) { UWZ_Log $hash, 4, "Successfully downloaded map ".$smap; } else { UWZ_Log $hash, 3, "Failed to download map (".$img.")"; } } } # acquire the json-response my $response = UWZ_JSONAcquire($hash,$hash->{URL}); UWZ_Log $hash, 5, length($response)." characters captured"; my $converter = Text::Iconv->new("windows-1252","UTF-8"); my $uwz_warnings = JSON->new->ascii->decode($response); my $enc = guess_encoding($uwz_warnings); my $uwz_warncount = scalar(@{ $uwz_warnings->{'results'} }); UWZ_Log $hash, 4, "There are ".$uwz_warncount." warnings active"; my $message; my $i=0; my %typenames = ( "1" => "unknown", # <===== FIX HERE "2" => "sturm", "3" => "schnee", "4" => "regen", "5" => "temperatur", "6" => "waldbrand", "7" => "gewitter", "8" => "strassenglaette", "9" => "temperatur", # 9 = hitzewarnung "10" => "glatteisregen", "11" => "temperatur" ); # 11 = bodenfrost my %severitycolor = ( "0" => "green", "1" => "unknown", # <===== FIX HERE "2" => "unknown", # <===== FIX HERE "3" => "unknown", # <===== FIX HERE "4" => "orange", "5" => "unknown", # <===== FIX HERE "6" => "unknown", # <===== FIX HERE "7" => "orange", "8" => "gelb", "9" => "gelb", # <===== FIX HERE "10" => "orange", "11" => "rot", "12" => "violet" ); foreach my $single_warning (@{ $uwz_warnings->{'results'} }) { UWZ_Log $hash, 4, "Warn_".$i."_Type: ".$single_warning->{'type'}; $message .= "Warn_".$i."_Type|".$single_warning->{'type'}."|"; UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel: ".$single_warning->{'payload'}{'uwzLevel'}; $message .= "Warn_".$i."_uwzLevel|".$single_warning->{'payload'}{'uwzLevel'}."|"; UWZ_Log $hash, 4, "Warn_".$i."_Severity: ".$single_warning->{'severity'}; $message .= "Warn_".$i."_Severity|".$single_warning->{'severity'}."|"; UWZ_Log $hash, 4, "Warn_".$i."_Start: ".$single_warning->{'dtgStart'}; $message .= "Warn_".$i."_Start|".$single_warning->{'dtgStart'}."|"; UWZ_Log $hash, 4, "Warn_".$i."_End: ".$single_warning->{'dtgEnd'}; $message .= "Warn_".$i."_End|".$single_warning->{'dtgEnd'}."|"; ## Begin of redundant Reading if ( $UWZ_humanreadable eq 1 ) { UWZ_Log $hash, 4, "Warn_".$i."_Start_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'})); $message .= "Warn_".$i."_Start_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'}))."|"; UWZ_Log $hash, 4, "Warn_".$i."_Start_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgStart'})); $message .= "Warn_".$i."_Start_Time|".strftime("%H:%M", localtime($single_warning->{'dtgStart'}))."|"; UWZ_Log $hash, 4, "Warn_".$i."_End_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'})); $message .= "Warn_".$i."_End_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'}))."|"; UWZ_Log $hash, 4, "Warn_".$i."_End_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgEnd'})); $message .= "Warn_".$i."_End_Time|".strftime("%H:%M", localtime($single_warning->{'dtgEnd'}))."|"; UWZ_Log $hash, 4, "Warn_".$i."_Type_Str: ".ucfirst($typenames{ $single_warning->{'type'} }); $message .= "Warn_".$i."_Type_Str|".ucfirst($typenames{ $single_warning->{'type'} })."|"; } ## End of redundant Reading UWZ_Log $hash, 4, "Warn_".$i."_levelName: ".$single_warning->{'payload'}{'levelName'}; $message .= "Warn_".$i."_levelName|".$single_warning->{'payload'}{'levelName'}."|"; UWZ_Log $hash, 4, "Warn_".$i."_LongText: ".$enc->decode($single_warning->{'payload'}{'translationsLongText'}{'DE'}); $message .= "Warn_".$i."_LongText|".$converter->convert($single_warning->{'payload'}{'translationsLongText'}{'DE'})."|"; UWZ_Log $hash, 4, "Warn_".$i."_ShortText: ".$enc->decode($single_warning->{'payload'}{'translationsShortText'}{'DE'}); $message .= "Warn_".$i."_ShortText|".$converter->convert($single_warning->{'payload'}{'translationsShortText'}{'DE'})."|"; UWZ_Log $hash, 4, "Warn_".$i."_IconURL: http://www.unwetterzentrale.de/images/icons/".$typenames{ $single_warning->{'type'} }."-".$single_warning->{'severity'}.".gif"; $message .= "Warn_".$i."_IconURL|http://www.unwetterzentrale.de/images/icons/".$typenames{ $single_warning->{'type'} }."-".$severitycolor{ $single_warning->{'severity'} }.".gif|"; ## Hagel start my $hagelcount = my @hagelmatch = $single_warning->{'payload'}{'translationsLongText'}{'DE'} =~ /Hagel/g; if ( $hagelcount ne 0 ) { UWZ_Log $hash, 4, "Warn_".$i."_Hail: 1"; $message .= "Warn_".$i."_Hail|1|"; } else { UWZ_Log $hash, 4, "Warn_".$i."_Hail: 0"; $message .= "Warn_".$i."_Hail|0|"; } ## Hagel end $i++; } $message .= "durationFetchReadings|"; $message .= sprintf "%.2f", time() - $readingStartTime; UWZ_Log $hash, 3, "Done fetching data"; UWZ_Log $hash, 4, "Will return : "."$name|$message|WarnCount|$uwz_warncount" ; return "$name|$message|WarnCount|$uwz_warncount" ; } ##################################### sub UWZAsHtml($;$) { my ($hash,$items) = @_; my $ret = ''; if (ReadingsVal($hash, "WarnCount", "") != 0 ) { $ret .= ''; $ret .= '
'; $ret .= ''; for ( my $i=0; $i'; $ret .= ''; } $ret .= '
'.ReadingsVal($hash, "Warn_".$i."_ShortText", "").'

'; $ret .= ReadingsVal($hash, "Warn_".$i."_LongText", "").'

'; $ret .= ''; $ret .= ''; $ret .= '
Start:'.localtime(ReadingsVal($hash, "Warn_".$i."_Start", "")).'Ende:'.localtime(ReadingsVal($hash, "Warn_".$i."_End", "")).'
'; $ret .= '
'; $ret .= '
'; } else { $ret .= ''; $ret .= '
'; $ret .= ''; $ret .= ''; $ret .= '
'; $ret .='Keine Warnungen'; $ret .= '
'; $ret .= '
'; } return $ret; } ##################################### sub UWZAsHtmlLite($;$) { my ($hash,$items) = @_; my $ret = ''; if (ReadingsVal($hash, "WarnCount", "") != 0 ) { $ret .= ''; $ret .= '
'; $ret .= ''; for ( my $i=0; $i'; $ret .= ''; } $ret .= '
'.ReadingsVal($hash, "Warn_".$i."_ShortText", "").'

'; $ret .= ''; $ret .= ''; $ret .= '
Start:'.localtime(ReadingsVal($hash, "Warn_".$i."_Start", "")).'Ende:'.localtime(ReadingsVal($hash, "Warn_".$i."_End", "")).'
'; $ret .= '
'; $ret .= '
'; } else { $ret .= ''; $ret .= '
'; $ret .= ''; $ret .= ''; $ret .= '
'; $ret .='Keine Warnungen'; $ret .= '
'; $ret .= '
'; } return $ret; } ##################################### sub UWZAsHtmlFP($;$) { my ($hash,$items) = @_; my $tablewidth = ReadingsVal($hash, "WarnCount", "") * 80; my $ret = ''; $ret .= ''; $ret .= ""; for ( my $i=0; $i'; } $ret .= ""; $ret .= '
'; return $ret; } ##################################### sub UWZAsHtmlKarteLand($$) { my ($hash,$land) = @_; # my $uwz_de_url = "http://www.unwetterzentrale.de/images/map/"; # my $uwz_at_url = "http://unwetter.wetteralarm.at/images/map/"; my $url = UWZ_Map2Image($hash,$land); my $ret = ''; $ret .= '
'; $ret .= ''; $ret .= '
'; if(defined($url)) { $ret .= ''; } else { $ret .= 'unbekannte Landbezeichnung'; } $ret .= '
'; return $ret; } ##################################### 1; =pod =begin html

UWZ

=end html =begin html_DE

UWZ

=end html_DE =cut