77_UWZ.pm 84 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334
  1. ####################################################################################################
  2. #
  3. # 77_UWZ.pm
  4. #
  5. # (c) 2015-2016 Tobias D. Oestreicher
  6. #
  7. # Special thanks goes to comitters:
  8. # - Marko Oldenburg (leongaultier at gmail dot com)
  9. # - Hanjo (Forum) patch for sort by creation
  10. # - cb1 <kontakt@it-buchinger.de> patch Replace Iconv with native perl encode()
  11. #
  12. # Storm warnings from unwetterzentrale.de
  13. # inspired by 59_PROPLANTA.pm
  14. #
  15. # Copyright notice
  16. #
  17. # This script is free software; you can redistribute it and/or modify
  18. # it under the terms of the GNU General Public License as published by
  19. # the Free Software Foundation; either version 2 of the License, or
  20. # (at your option) any later version.
  21. #
  22. # The GNU General Public License can be found at
  23. # http://www.gnu.org/copyleft/gpl.html.
  24. # A copy is found in the text file GPL.txt and important notices to the license
  25. # from the author is found in LICENSE.txt distributed with these scripts.
  26. #
  27. # This script is distributed in the hope that it will be useful,
  28. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  29. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  30. # GNU General Public License for more details.
  31. #
  32. # This copyright notice MUST APPEAR in all copies of the script!
  33. #
  34. #
  35. #
  36. # $Id: 77_UWZ.pm 15650 2017-12-20 05:41:22Z CoolTux $
  37. #
  38. ####################################################################################################
  39. # also a thanks goes to hexenmeister
  40. ##############################################
  41. package main;
  42. use strict;
  43. use feature qw/say switch/;
  44. use warnings;
  45. no if $] >= 5.017011, warnings => 'experimental::lexical_subs','experimental::smartmatch';
  46. my $missingModul;
  47. eval "use LWP::UserAgent;1" or $missingModul .= "LWP::UserAgent ";
  48. eval "use LWP::Simple;1" or $missingModul .= "LWP::Simple ";
  49. eval "use HTTP::Request;1" or $missingModul .= "HTTP::Request ";
  50. eval "use HTML::Parser;1" or $missingModul .= "HTML::Parser ";
  51. eval "use JSON;1" or $missingModul .= "JSON ";
  52. eval "use Encode::Guess;1" or $missingModul .= "Encode::Guess ";
  53. require 'Blocking.pm';
  54. require 'HttpUtils.pm';
  55. use vars qw($readingFnAttributes);
  56. use vars qw(%defs);
  57. my $MODUL = "UWZ";
  58. my $version = "2.0.0";
  59. # Declare functions
  60. sub UWZ_Log($$$);
  61. sub UWZ_Map2Movie($$);
  62. sub UWZ_Map2Image($$);
  63. sub UWZ_Initialize($);
  64. sub UWZ_Define($$);
  65. sub UWZ_Undef($$);
  66. sub UWZ_Set($@);
  67. sub UWZ_Get($@);
  68. sub UWZ_GetCurrent($@);
  69. sub UWZ_GetCurrentHail($);
  70. sub UWZ_JSONAcquire($$);
  71. sub UWZ_Start($);
  72. sub UWZ_Aborted($);
  73. sub UWZ_Done($);
  74. sub UWZ_Run($);
  75. sub UWZAsHtml($;$);
  76. sub UWZAsHtmlLite($;$);
  77. sub UWZAsHtmlFP($;$);
  78. sub UWZAsHtmlMovie($$);
  79. sub UWZAsHtmlKarteLand($$);
  80. sub UWZ_GetSeverityColor($$);
  81. sub UWZ_GetUWZLevel($$);
  82. sub UWZSearchLatLon($$);
  83. sub UWZSearchAreaID($$);
  84. sub UWZ_IntervalAtWarnLevel($);
  85. my $countrycode = "DE";
  86. my $plz = "77777";
  87. my $uwz_alert_url = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=getWarning&language=de&areaID=UWZ" . $countrycode . $plz;
  88. ########################################
  89. sub UWZ_Log($$$) {
  90. my ( $hash, $loglevel, $text ) = @_;
  91. my $xline = ( caller(0) )[2];
  92. my $xsubroutine = ( caller(1) )[3];
  93. my $sub = ( split( ':', $xsubroutine ) )[2];
  94. $sub =~ s/UWZ_//;
  95. my $instName = ( ref($hash) eq "HASH" ) ? $hash->{NAME} : $hash;
  96. Log3 $instName, $loglevel, "$MODUL $instName: $sub.$xline " . $text;
  97. }
  98. ########################################
  99. sub UWZ_Map2Movie($$) {
  100. my $uwz_movie_url = "http://www.meteocentrale.ch/uploads/media/";
  101. my ( $hash, $smap ) = @_;
  102. my $lmap;
  103. $smap=lc($smap);
  104. ## Euro
  105. $lmap->{'niederschlag-wolken'}=$uwz_movie_url.'UWZ_EUROPE_COMPLETE_niwofi.mp4';
  106. $lmap->{'stroemung'}=$uwz_movie_url.'UWZ_EUROPE_COMPLETE_stfi.mp4';
  107. $lmap->{'temperatur'}=$uwz_movie_url.'UWZ_EUROPE_COMPLETE_theta_E.mp4';
  108. ## DE
  109. $lmap->{'niederschlag-wolken-de'}=$uwz_movie_url.'UWZ_EUROPE_GERMANY_COMPLETE_niwofi.mp4';
  110. $lmap->{'stroemung-de'}=$uwz_movie_url.'UWZ_EUROPE_GERMANY_COMPLETE_stfi.mp4';
  111. ## CH
  112. $lmap->{'niederschlag-wolken-ch'}=$uwz_movie_url.'UWZ_EUROPE_SWITZERLAND_COMPLETE_niwofi.mp4';
  113. $lmap->{'stroemung-ch'}=$uwz_movie_url.'UWZ_EUROPE_SWITZERLAND_COMPLETE_stfi.mp4';
  114. ## AT
  115. $lmap->{'niederschlag-wolken-at'}=$uwz_movie_url.'UWZ_EUROPE_AUSTRIA_COMPLETE_niwofi.mp4';
  116. $lmap->{'stroemung-at'}=$uwz_movie_url.'UWZ_EUROPE_AUSTRIA_COMPLETE_stfi.mp4';
  117. ## UK
  118. $lmap->{'clouds-precipitation-uk'}=$uwz_movie_url.'UWZ_EUROPE_GREATBRITAIN_COMPLETE_niwofi.mp4';
  119. $lmap->{'currents-uk'}=$uwz_movie_url.'UWZ_EUROPE_GREATBRITAIN_COMPLETE_stfi.mp4';
  120. ## IT
  121. $lmap->{'niederschlag-wolken-it'}=$uwz_movie_url.'UWZ_EUROPE_ITALY_COMPLETE_niwofi.mp4';
  122. $lmap->{'stroemung-it'}=$uwz_movie_url.'UWZ_EUROPE_ITALY_COMPLETE_stfi.mp4';
  123. return $lmap->{$smap};
  124. }
  125. ########################################
  126. sub UWZ_Map2Image($$) {
  127. my $uwz_de_url = "http://www.unwetterzentrale.de/images/map/";
  128. my $uwz_at_url = "http://unwetter.wetteralarm.at/images/map/";
  129. my $uwz_ch_url = "http://alarm.meteocentrale.ch/images/map/";
  130. my $uwz_en_url = "http://warnings.severe-weather-centre.co.uk/images/map/";
  131. my $uwz_li_url = "http://alarm.meteocentrale.li/images/map/";
  132. my $uwz_be_url = "http://alarm.meteo-info.be/images/map/";
  133. my $uwz_dk_url = "http://alarm.vejrcentral.dk/images/map/";
  134. my $uwz_fi_url = "http://vaaratasot.saa-varoitukset.fi/images/map/";
  135. my $uwz_fr_url = "http://alerte.vigilance-meteo.fr/images/map/";
  136. my $uwz_lu_url = "http://alarm.meteozentral.lu/images/map/";
  137. my $uwz_nl_url = "http://alarm.noodweercentrale.nl/images/map/";
  138. my $uwz_no_url = "http://advarsler.vaer-sentral.no/images/map/";
  139. my $uwz_pt_url = "http://avisos.centrometeo.pt/images/map/";
  140. my $uwz_se_url = "http://varningar.vader-alarm.se/images/map/";
  141. my $uwz_es_url = "http://avisos.alertas-tiempo.es/images/map/";
  142. my $uwz_it_url = "http://allarmi.meteo-allerta.it/images/map/";
  143. my ( $hash, $smap ) = @_;
  144. my $lmap;
  145. $smap=lc($smap);
  146. ## Euro
  147. $lmap->{'europa'}=$uwz_de_url.'europe_index.png';
  148. ## DE
  149. $lmap->{'deutschland'}=$uwz_de_url.'deutschland_index.png';
  150. $lmap->{'deutschland-small'}=$uwz_de_url.'deutschland_preview.png';
  151. $lmap->{'niedersachsen'}=$uwz_de_url.'niedersachsen_index.png';
  152. $lmap->{'bremen'}=$uwz_de_url.'niedersachsen_index.png';
  153. $lmap->{'bayern'}=$uwz_de_url.'bayern_index.png';
  154. $lmap->{'schleswig-holstein'}=$uwz_de_url.'schleswig_index.png';
  155. $lmap->{'hamburg'}=$uwz_de_url.'schleswig_index.png';
  156. $lmap->{'mecklenburg-vorpommern'}=$uwz_de_url.'meckpom_index.png';
  157. $lmap->{'sachsen'}=$uwz_de_url.'sachsen_index.png';
  158. $lmap->{'sachsen-anhalt'}=$uwz_de_url.'sachsenanhalt_index.png';
  159. $lmap->{'nordrhein-westfalen'}=$uwz_de_url.'nrw_index.png';
  160. $lmap->{'thueringen'}=$uwz_de_url.'thueringen_index.png';
  161. $lmap->{'rheinland-pfalz'}=$uwz_de_url.'rlp_index.png';
  162. $lmap->{'saarland'}=$uwz_de_url.'rlp_index.png';
  163. $lmap->{'baden-wuerttemberg'}=$uwz_de_url.'badenwuerttemberg_index.png';
  164. $lmap->{'hessen'}=$uwz_de_url.'hessen_index.png';
  165. $lmap->{'brandenburg'}=$uwz_de_url.'brandenburg_index.png';
  166. $lmap->{'berlin'}=$uwz_de_url.'brandenburg_index.png';
  167. ## AT
  168. $lmap->{'oesterreich'}=$uwz_at_url.'oesterreich_index.png';
  169. $lmap->{'burgenland'}=$uwz_at_url.'burgenland_index.png';
  170. $lmap->{'kaernten'}=$uwz_at_url.'kaernten_index.png';
  171. $lmap->{'niederoesterreich'}=$uwz_at_url.'niederoesterreich_index.png';
  172. $lmap->{'oberoesterreich'}=$uwz_at_url.'oberoesterreich_index.png';
  173. $lmap->{'salzburg'}=$uwz_at_url.'salzburg_index.png';
  174. $lmap->{'steiermark'}=$uwz_at_url.'steiermark_index.png';
  175. $lmap->{'tirol'}=$uwz_at_url.'tirol_index.png';
  176. $lmap->{'vorarlberg'}=$uwz_at_url.'vorarlberg_index.png';
  177. $lmap->{'wien'}=$uwz_at_url.'wien_index.png';
  178. ## CH
  179. $lmap->{'schweiz'}=$uwz_ch_url.'schweiz_index.png';
  180. $lmap->{'aargau'}=$uwz_ch_url.'aargau_index.png';
  181. $lmap->{'appenzell_ausserrhoden'}=$uwz_ch_url.'appenzell_ausserrhoden_index.png';
  182. $lmap->{'appenzell_innerrhoden'}=$uwz_ch_url.'appenzell_innerrhoden_index.png';
  183. $lmap->{'basel_landschaft'}=$uwz_ch_url.'basel_landschaft_index.png';
  184. $lmap->{'basel_stadt'}=$uwz_ch_url.'basel_stadt_index.png';
  185. $lmap->{'bern'}=$uwz_ch_url.'bern_index.png';
  186. $lmap->{'fribourg'}=$uwz_ch_url.'fribourg_index.png';
  187. $lmap->{'geneve'}=$uwz_ch_url.'geneve_index.png';
  188. $lmap->{'glarus'}=$uwz_ch_url.'glarus_index.png';
  189. $lmap->{'graubuenden'}=$uwz_ch_url.'graubuenden_index.png';
  190. $lmap->{'jura'}=$uwz_ch_url.'jura_index.png';
  191. $lmap->{'luzern'}=$uwz_ch_url.'luzern_index.png';
  192. $lmap->{'neuchatel'}=$uwz_ch_url.'neuchatel_index.png';
  193. $lmap->{'nidwalden'}=$uwz_ch_url.'nidwalden_index.png';
  194. $lmap->{'obwalden'}=$uwz_ch_url.'obwalden_index.png';
  195. $lmap->{'schaffhausen'}=$uwz_ch_url.'schaffhausen_index.png';
  196. $lmap->{'schwyz'}=$uwz_ch_url.'schwyz_index.png';
  197. $lmap->{'solothurn'}=$uwz_ch_url.'solothurn_index.png';
  198. $lmap->{'stgallen'}=$uwz_ch_url.'stgallen_index.png';
  199. $lmap->{'ticino'}=$uwz_ch_url.'ticino_index.png';
  200. $lmap->{'thurgau'}=$uwz_ch_url.'thurgau_index.png';
  201. $lmap->{'uri'}=$uwz_ch_url.'uri_index.png';
  202. $lmap->{'waadt'}=$uwz_ch_url.'waadt_index.png';
  203. $lmap->{'wallis'}=$uwz_ch_url.'wallis_index.png';
  204. $lmap->{'zug'}=$uwz_ch_url.'zug_index.png';
  205. $lmap->{'zuerich'}=$uwz_ch_url.'zuerich_index.png';
  206. ## LI
  207. $lmap->{'liechtenstein'}=$uwz_li_url.'liechtenstein_index.png';
  208. ## UK
  209. $lmap->{'unitedkingdom'}=$uwz_en_url.'unitedkingdom_index.png';
  210. $lmap->{'eastofengland'}=$uwz_en_url.'eastofengland_index.png';
  211. $lmap->{'eastmidlands'}=$uwz_en_url.'eastmidlands-index.png';
  212. $lmap->{'london'}=$uwz_en_url.'london-index.png';
  213. $lmap->{'northeastengland'}=$uwz_en_url.'northeastengland-index.png';
  214. $lmap->{'northernireland'}=$uwz_en_url.'northernireland-index.png';
  215. $lmap->{'northwestengland'}=$uwz_en_url.'northwestengland-index.png';
  216. $lmap->{'scotland'}=$uwz_en_url.'scotland-index.png';
  217. $lmap->{'southeastengland'}=$uwz_en_url.'southeastengland-index.png';
  218. $lmap->{'southwestengland'}=$uwz_en_url.'southwestengland-index.png';
  219. $lmap->{'wales'}=$uwz_en_url.'wales-index.png';
  220. $lmap->{'westmidlands'}=$uwz_en_url.'westmidlands-index.png';
  221. $lmap->{'yorkshireandthehumber'}=$uwz_en_url.'yorkshireandthehumber-index.png';
  222. ## BE
  223. $lmap->{'belgique'}=$uwz_be_url.'belgique_index.png';
  224. ## DK
  225. $lmap->{'denmark'}=$uwz_dk_url.'denmark_index.png';
  226. ## FI
  227. $lmap->{'finnland'}=$uwz_fi_url.'finnland_index.png';
  228. ## FR
  229. $lmap->{'france'}=$uwz_fr_url.'france_index.png';
  230. ## LU
  231. $lmap->{'letzebuerg'}=$uwz_lu_url.'letzebuerg_index.png';
  232. ## NL
  233. $lmap->{'nederland'}=$uwz_nl_url.'nederland_index.png';
  234. ## NO
  235. $lmap->{'norwegen'}=$uwz_no_url.'norwegen_index.png';
  236. ## PT
  237. $lmap->{'portugal'}=$uwz_pt_url.'portugal_index.png';
  238. ## SE
  239. $lmap->{'sverige'}=$uwz_se_url.'sverige_index.png';
  240. ## ES
  241. $lmap->{'espana'}=$uwz_es_url.'espana_index.png';
  242. ## IT
  243. $lmap->{'italia'}=$uwz_it_url.'italia_index.png';
  244. $lmap->{'valledaosta'}=$uwz_it_url.'valledaosta_index.png';
  245. $lmap->{'piemonte'}=$uwz_it_url.'piemonte_index.png';
  246. $lmap->{'lombardia'}=$uwz_it_url.'lombardia_index.png';
  247. $lmap->{'trentinoaltoadige'}=$uwz_it_url.'trentinoaltoadige_index.png';
  248. $lmap->{'friuliveneziagiulia'}=$uwz_it_url.'friuliveneziagiulia_index.png';
  249. $lmap->{'veneto'}=$uwz_it_url.'veneto_index.png';
  250. $lmap->{'liguria'}=$uwz_it_url.'liguria_index.png';
  251. $lmap->{'emiliaromagna'}=$uwz_it_url.'emiliaromagna_index.png';
  252. $lmap->{'toscana'}=$uwz_it_url.'toscana_index.png';
  253. $lmap->{'marche'}=$uwz_it_url.'marche_index.png';
  254. $lmap->{'umbria'}=$uwz_it_url.'umbria_index.png';
  255. $lmap->{'lazio'}=$uwz_it_url.'lazio_index.png';
  256. $lmap->{'molise'}=$uwz_it_url.'molise_index.png';
  257. $lmap->{'abruzzo'}=$uwz_it_url.'abruzzo_index.png';
  258. $lmap->{'campania'}=$uwz_it_url.'campania_index.png';
  259. $lmap->{'puglia'}=$uwz_it_url.'puglia_index.png';
  260. $lmap->{'basilicata'}=$uwz_it_url.'basilicata_index.png';
  261. $lmap->{'calabria'}=$uwz_it_url.'calabria_index.png';
  262. $lmap->{'sicilia'}=$uwz_it_url.'sicilia_index.png';
  263. $lmap->{'sardegna'}=$uwz_it_url.'sardegna_index.png';
  264. ## Isobaren
  265. $lmap->{'isobaren1'}="http://www.unwetterzentrale.de/images/icons/UWZ_ISO_00.jpg";
  266. $lmap->{'isobaren2'}="http://www.wetteralarm.at/uploads/pics/UWZ_EURO_ISO_GER_00.jpg";
  267. $lmap->{'isobaren3'}="http://www.severe-weather-centre.co.uk/uploads/pics/UWZ_EURO_ISO_ENG_00.jpg";
  268. return $lmap->{$smap};
  269. }
  270. ###################################
  271. sub UWZ_Initialize($) {
  272. my ($hash) = @_;
  273. $hash->{DefFn} = "UWZ_Define";
  274. $hash->{UndefFn} = "UWZ_Undef";
  275. $hash->{SetFn} = "UWZ_Set";
  276. $hash->{GetFn} = "UWZ_Get";
  277. $hash->{AttrList} = "download:0,1 ".
  278. "savepath ".
  279. "maps ".
  280. "humanreadable:0,1 ".
  281. "htmlattr ".
  282. "htmltitle ".
  283. "htmltitleclass ".
  284. "htmlsequence:ascending,descending ".
  285. "lang ".
  286. "sort_readings_by:severity,start,creation ".
  287. "localiconbase ".
  288. "intervalAtWarnLevel ".
  289. $readingFnAttributes;
  290. foreach my $d(sort keys %{$modules{UWZ}{defptr}}) {
  291. my $hash = $modules{UWZ}{defptr}{$d};
  292. $hash->{VERSION} = $version;
  293. }
  294. }
  295. ###################################
  296. sub UWZ_Define($$) {
  297. my ( $hash, $def ) = @_;
  298. my $name = $hash->{NAME};
  299. my $lang = "";
  300. my @a = split( "[ \t][ \t]*", $def );
  301. return "Error: Perl moduls ".$missingModul."are missing on this system" if( $missingModul );
  302. return "Wrong syntax: use define <name> UWZ <CountryCode> <PLZ> <Interval> " if (int(@a) != 5 and ((lc $a[2]) ne "search"));
  303. if ((lc $a[2]) ne "search") {
  304. $hash->{STATE} = "Initializing";
  305. $hash->{CountryCode} = $a[2];
  306. $hash->{PLZ} = $a[3];
  307. ## URL by CountryCode
  308. my $URL_language="en";
  309. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  310. $URL_language="de";
  311. }
  312. $hash->{URL} = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=getWarning&language=" . $URL_language . "&areaID=UWZ" . $a[2] . $a[3];
  313. $hash->{fhem}{LOCAL} = 0;
  314. $hash->{INTERVAL} = $a[4];
  315. $hash->{INTERVALWARN} = 0;
  316. $hash->{VERSION} = $version;
  317. RemoveInternalTimer($hash);
  318. #Get first data after 12 seconds
  319. InternalTimer( gettimeofday() + 12, "UWZ_Start", $hash, 0 ) if ((lc $hash->{CountryCode}) ne "search");
  320. } else {
  321. $hash->{STATE} = "Search-Mode";
  322. $hash->{CountryCode} = uc $a[2];
  323. $hash->{VERSION} = $version;
  324. }
  325. $modules{UWZ}{defptr}{$hash->{PLZ}} = $hash;
  326. return undef;
  327. }
  328. #####################################
  329. sub UWZ_Undef($$) {
  330. my ( $hash, $arg ) = @_;
  331. RemoveInternalTimer( $hash );
  332. BlockingKill( $hash->{helper}{RUNNING_PID} ) if ( defined( $hash->{helper}{RUNNING_PID} ) );
  333. delete($modules{UWZ}{defptr}{$hash->{PLZ}});
  334. return undef;
  335. }
  336. #####################################
  337. sub UWZ_Set($@) {
  338. my ( $hash, @a ) = @_;
  339. my $name = $hash->{NAME};
  340. my $reUINT = '^([\\+]?\\d+)$';
  341. my $usage = "Unknown argument $a[1], choose one of update:noArg " if ( (lc $hash->{CountryCode}) ne "search" );
  342. return $usage if ( @a < 2 );
  343. my $cmd = lc( $a[1] );
  344. given ($cmd)
  345. {
  346. when ("?")
  347. {
  348. return $usage;
  349. }
  350. when ("update")
  351. {
  352. UWZ_Log $hash, 4, "set command: " . $a[1];
  353. $hash->{fhem}{LOCAL} = 1;
  354. UWZ_Start($hash);
  355. $hash->{fhem}{LOCAL} = 0;
  356. }
  357. default
  358. {
  359. return $usage;
  360. }
  361. }
  362. return;
  363. }
  364. sub UWZ_Get($@) {
  365. my ( $hash, @a ) = @_;
  366. my $name = $hash->{NAME};
  367. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  368. 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 ";
  369. return $usage if ( @a < 2 );
  370. if ($a[1] =~ /^Sturm/) { UWZ_GetCurrent($hash,2); }
  371. elsif ($a[1] =~ /^Schneefall/) { UWZ_GetCurrent($hash,3); }
  372. elsif ($a[1] =~ /^Regen/) { UWZ_GetCurrent($hash,4); }
  373. elsif ($a[1] =~ /^Extremfrost/) { UWZ_GetCurrent($hash,5); }
  374. elsif ($a[1] =~ /^Waldbrand/) { UWZ_GetCurrent($hash,6); }
  375. elsif ($a[1] =~ /^Gewitter/) { UWZ_GetCurrent($hash,7); }
  376. elsif ($a[1] =~ /^Glaette/) { UWZ_GetCurrent($hash,8); }
  377. elsif ($a[1] =~ /^Hitze/) { UWZ_GetCurrent($hash,9); }
  378. elsif ($a[1] =~ /^Glatteisregen/) { UWZ_GetCurrent($hash,10); }
  379. elsif ($a[1] =~ /^Bodenfrost/) { UWZ_GetCurrent($hash,11); }
  380. elsif ($a[1] =~ /^Hagel/) { UWZ_GetCurrentHail($hash); }
  381. else { return $usage; }
  382. }
  383. elsif ( (lc $hash->{CountryCode}) eq 'search' ) {
  384. my $usage = "Unknown argument $a[1], choose one of SearchAreaID ";
  385. return $usage if ( @a < 3 );
  386. if ($a[1] =~ /^SearchAreaID/) { UWZSearchLatLon($name, $a[2]); }
  387. elsif ($a[1] =~ /^AreaID/) { my @splitparam = split(/,/,$a[2]); UWZSearchAreaID($splitparam[0],$splitparam[1]); }
  388. else { return $usage; }
  389. } else {
  390. my $usage = "Unknown argument $a[1], choose one of storm:noArg snow:noArg rain:noArg extremfrost:noArg forest-fire:noArg thunderstorms:noArg glaze:noArg heat:noArg glazed-rain:noArg soil-frost:noArg hail:noArg ";
  391. return $usage if ( @a < 2 );
  392. if ($a[1] =~ /^storm/) { UWZ_GetCurrent($hash,2); }
  393. elsif ($a[1] =~ /^snow/) { UWZ_GetCurrent($hash,3); }
  394. elsif ($a[1] =~ /^rain/) { UWZ_GetCurrent($hash,4); }
  395. elsif ($a[1] =~ /^extremfrost/) { UWZ_GetCurrent($hash,5); }
  396. elsif ($a[1] =~ /^forest-fire/) { UWZ_GetCurrent($hash,6); }
  397. elsif ($a[1] =~ /^thunderstorms/) { UWZ_GetCurrent($hash,7); }
  398. elsif ($a[1] =~ /^glaze/) { UWZ_GetCurrent($hash,8); }
  399. elsif ($a[1] =~ /^heat/) { UWZ_GetCurrent($hash,9); }
  400. elsif ($a[1] =~ /^glazed-rain/) { UWZ_GetCurrent($hash,10); }
  401. elsif ($a[1] =~ /^soil-frost/) { UWZ_GetCurrent($hash,11); }
  402. elsif ($a[1] =~ /^hail/) { UWZ_GetCurrentHail($hash); }
  403. else { return $usage; }
  404. }
  405. }
  406. #####################################
  407. sub UWZ_GetCurrent($@) {
  408. my ( $hash, @a ) = @_;
  409. my $name = $hash->{NAME};
  410. my $out;
  411. my $curTimestamp = time();
  412. if ( ReadingsVal($name,"WarnCount", 0) eq 0 ) {
  413. $out = "inactive";
  414. } else {
  415. for(my $i= 0;$i < ReadingsVal($name,"WarnCount", 0);$i++) {
  416. if ( (ReadingsVal($name,"Warn_".$i."_Start","") le $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_End","") ge $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_Type","") eq $a[0]) ) {
  417. $out= "active";
  418. last;
  419. } else {
  420. $out = "inactive";
  421. }
  422. }
  423. }
  424. return $out;
  425. }
  426. #####################################
  427. sub UWZ_GetCurrentHail($) {
  428. my ( $hash ) = @_;
  429. my $name = $hash->{NAME};
  430. my $out;
  431. my $curTimestamp = time();
  432. if ( ReadingsVal($name,"WarnCount", 0) eq 0 ) {
  433. $out = "inactive";
  434. } else {
  435. for(my $i= 0;$i < ReadingsVal($name,"WarnCount", 0);$i++) {
  436. if ( (ReadingsVal($name,"Warn_".$i."_Start","") le $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_End","") ge $curTimestamp) && (ReadingsVal($name,"Warn_".$i."_Hail","") eq 1) ) {
  437. $out= "active";
  438. last;
  439. } else {
  440. $out= "inactive";
  441. }
  442. }
  443. }
  444. return $out;
  445. }
  446. #####################################
  447. sub UWZ_JSONAcquire($$) {
  448. my ($hash, $URL) = @_;
  449. my $name = $hash->{NAME};
  450. return unless (defined($hash->{NAME}));
  451. UWZ_Log $hash, 4, "Start capturing of $URL";
  452. my $err_log = "";
  453. my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
  454. my $request = HTTP::Request->new( GET => $URL );
  455. my $response = $agent->request($request);
  456. $err_log = "Can't get $URL -- " . $response->status_line unless( $response->is_success );
  457. if ( $err_log ne "" ) {
  458. readingsSingleUpdate($hash, "lastConnection", $response->status_line, 1);
  459. UWZ_Log $hash, 1, "Error: $err_log";
  460. return "Error|Error " . $response->status_line;
  461. }
  462. UWZ_Log $hash, 4, length($response->content)." characters captured";
  463. return $response->content;
  464. }
  465. #####################################
  466. sub UWZ_Start($) {
  467. my ($hash) = @_;
  468. my $name = $hash->{NAME};
  469. return unless (defined($hash->{NAME}));
  470. if(!$hash->{fhem}{LOCAL} && $hash->{INTERVAL} > 0) { # set up timer if automatically call
  471. RemoveInternalTimer( $hash );
  472. InternalTimer(gettimeofday() + $hash->{INTERVAL}, "UWZ_Start", $hash, 1 );
  473. return undef if( AttrVal($name, "disable", 0 ) == 1 );
  474. readingsSingleUpdate($hash,'currentIntervalMode','normal',0);
  475. }
  476. ## URL by CountryCode
  477. my $URL_language="en";
  478. if (AttrVal($hash->{NAME}, "lang", undef) ) {
  479. $URL_language=AttrVal($hash->{NAME}, "lang", "");
  480. } else {
  481. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  482. $URL_language="de";
  483. }
  484. }
  485. $hash->{URL} = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=getWarning&language=" . $URL_language . "&areaID=UWZ" . $hash->{CountryCode} . $hash->{PLZ};
  486. if ( not defined( $hash->{URL} ) ) {
  487. UWZ_Log $hash, 3, "missing URL";
  488. return;
  489. }
  490. $hash->{helper}{RUNNING_PID} =
  491. BlockingCall(
  492. "UWZ_Run", # callback worker task
  493. $name, # name of the device
  494. "UWZ_Done", # callback result method
  495. 120, # timeout seconds
  496. "UWZ_Aborted", # callback for abortion
  497. $hash ); # parameter for abortion
  498. }
  499. #####################################
  500. sub UWZ_Aborted($) {
  501. my ($hash) = @_;
  502. delete( $hash->{helper}{RUNNING_PID} );
  503. }
  504. #####################################
  505. # asyncronous callback by blocking
  506. sub UWZ_Done($) {
  507. my ($string) = @_;
  508. return unless ( defined($string) );
  509. # all term are separated by "|" , the first is the name of the instance
  510. my ( $name, %values ) = split( "\\|", $string );
  511. my $hash = $defs{$name};
  512. return unless ( defined($hash->{NAME}) );
  513. # delete the marker for RUNNING_PID process
  514. delete( $hash->{helper}{RUNNING_PID} );
  515. # UnWetterdaten speichern
  516. readingsBeginUpdate($hash);
  517. if ( defined $values{Error} ) {
  518. readingsBulkUpdate( $hash, "lastConnection", $values{Error} );
  519. } else {
  520. while (my ($rName, $rValue) = each(%values) ) {
  521. readingsBulkUpdate( $hash, $rName, $rValue );
  522. UWZ_Log $hash, 5, "reading:$rName value:$rValue";
  523. }
  524. if (keys %values > 0) {
  525. my $newState;
  526. UWZ_Log $hash, 4, "Delete old Readings";
  527. for my $Counter ($values{WarnCount} .. 9) {
  528. CommandDeleteReading(undef, "$hash->{NAME} Warn_${Counter}_.*");
  529. }
  530. if (defined $values{WarnCount}) {
  531. # Message by CountryCode
  532. $newState = "Warnings: " . $values{WarnCount};
  533. $newState = "Warnungen: " . $values{WarnCount} if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] );
  534. # end Message by CountryCode
  535. } else {
  536. $newState = "Error: Could not capture all data. Please check CountryCode and PLZ.";
  537. }
  538. readingsBulkUpdate($hash, "state", $newState);
  539. readingsBulkUpdate( $hash, "lastConnection", keys( %values )." values captured in ".$values{durationFetchReadings}." s" );
  540. UWZ_Log $hash, 4, keys( %values )." values captured";
  541. } else {
  542. readingsBulkUpdate( $hash, "lastConnection", "no data found" );
  543. UWZ_Log $hash, 1, "No data found. Check city name or URL.";
  544. }
  545. }
  546. readingsEndUpdate( $hash, 1 );
  547. if( AttrVal($name,'intervalAtWarnLevel','') ne '' and ReadingsVal($name,'WarnUWZLevel',0) > 1 ) {
  548. UWZ_IntervalAtWarnLevel($hash);
  549. UWZ_Log $hash, 5, "run Sub IntervalAtWarnLevel";
  550. }
  551. }
  552. #####################################
  553. sub UWZ_Run($) {
  554. my ($name) = @_;
  555. my $ptext=$name;
  556. my $UWZ_download;
  557. my $UWZ_savepath;
  558. my $UWZ_humanreadable;
  559. return unless ( defined($name) );
  560. my $hash = $defs{$name};
  561. return unless (defined($hash->{NAME}));
  562. my $readingStartTime = time();
  563. my $attrdownload = AttrVal( $name, 'download','');
  564. my $attrsavepath = AttrVal( $name, 'savepath','');
  565. my $maps2fetch = AttrVal( $name, 'maps','');
  566. ## begin redundant Reading switch
  567. my $attrhumanreadable = AttrVal( $name, 'humanreadable','');
  568. ## end redundant Reading switch
  569. # preset download
  570. if ($attrdownload eq "") {
  571. $UWZ_download = 0;
  572. } else {
  573. $UWZ_download = $attrdownload;
  574. }
  575. # preset savepath
  576. if ($attrsavepath eq "") {
  577. $UWZ_savepath = "/tmp/";
  578. } else {
  579. $UWZ_savepath = $attrsavepath;
  580. }
  581. # preset humanreadable
  582. if ($attrhumanreadable eq "") {
  583. $UWZ_humanreadable = 0;
  584. } else {
  585. $UWZ_humanreadable = $attrhumanreadable;
  586. }
  587. if ( $UWZ_download == 1 ) {
  588. if ( ! defined($maps2fetch) ) { $maps2fetch = "deutschland"; }
  589. UWZ_Log $hash, 4, "Maps2Fetch : ".$maps2fetch;
  590. my @maps = split(' ', $maps2fetch);
  591. my $uwz_de_url = "http://www.unwetterzentrale.de/images/map/";
  592. foreach my $smap (@maps) {
  593. UWZ_Log $hash, 4, "Download map : ".$smap;
  594. my $img = UWZ_Map2Image($hash,$smap);
  595. if (!defined($img) ) { $img=$uwz_de_url.'deutschland_index.png'; }
  596. my $code = getstore($img, $UWZ_savepath.$smap.".png");
  597. if($code == 200) {
  598. UWZ_Log $hash, 4, "Successfully downloaded map ".$smap;
  599. } else {
  600. UWZ_Log $hash, 3, "Failed to download map (".$img.")";
  601. }
  602. }
  603. }
  604. # acquire the json-response
  605. my $response = UWZ_JSONAcquire($hash,$hash->{URL});
  606. UWZ_Log $hash, 5, length($response)." characters captured";
  607. my $uwz_warnings = JSON->new->ascii->decode($response);
  608. my $enc = guess_encoding($uwz_warnings);
  609. my $uwz_warncount = scalar(@{ $uwz_warnings->{'results'} });
  610. UWZ_Log $hash, 4, "There are ".$uwz_warncount." warnings active";
  611. my $sortby = AttrVal( $name, 'sort_readings_by',"" );
  612. my @sorted;
  613. if ( $sortby eq "creation" ) {
  614. UWZ_Log $hash, 4, "Sorting by creation";
  615. @sorted = sort { $b->{payload}{creation} <=> $a->{payload}{creation} } @{ $uwz_warnings->{'results'} };
  616. } elsif ( $sortby ne "severity" ) {
  617. UWZ_Log $hash, 4, "Sorting by dtgStart";
  618. @sorted = sort { $a->{dtgStart} <=> $b->{dtgStart} } @{ $uwz_warnings->{'results'} };
  619. } else {
  620. UWZ_Log $hash, 4, "Sorting by severity";
  621. @sorted = sort { $a->{severity} <=> $b->{severity} } @{ $uwz_warnings->{'results'} };
  622. }
  623. my $message;
  624. my $i=0;
  625. my %typenames = ( "1" => "unknown", # <===== FIX HERE
  626. "2" => "sturm",
  627. "3" => "schnee",
  628. "4" => "regen",
  629. "5" => "temperatur",
  630. "6" => "waldbrand",
  631. "7" => "gewitter",
  632. "8" => "strassenglaette",
  633. "9" => "temperatur", # 9 = hitzewarnung
  634. "10" => "glatteisregen",
  635. "11" => "temperatur" ); # 11 = bodenfrost
  636. my %typenames_de_str= ( "1" => "unknown", # <===== FIX HERE
  637. "2" => "Sturm",
  638. "3" => "Schnee",
  639. "4" => "Regen",
  640. "5" => "Temperatur",
  641. "6" => "Waldbrand",
  642. "7" => "Gewitter",
  643. "8" => "Strassenglaette",
  644. "9" => "Hitze", # 9 = hitzewarnung
  645. "10" => "Glatteisregen",
  646. "11" => "Bodenfrost" ); # 11 = bodenfrost
  647. my %typenames_en_str= ( "1" => "unknown", # <===== FIX HERE
  648. "2" => "storm",
  649. "3" => "snow",
  650. "4" => "rain",
  651. "5" => "temperatur",
  652. "6" => "forest fire",
  653. "7" => "thunderstorms",
  654. "8" => "slippery road",
  655. "9" => "heat", # 9 = hitzewarnung
  656. "10" => "black ice rain",
  657. "11" => "soil frost" ); # 11 = bodenfrost
  658. my %severitycolor = ( "0" => "green",
  659. "1" => "unknown", # <===== FIX HERE
  660. "2" => "unknown", # <===== FIX HERE
  661. "3" => "unknown", # <===== FIX HERE
  662. "4" => "orange",
  663. "5" => "unknown", # <===== FIX HERE
  664. "6" => "unknown", # <===== FIX HERE
  665. "7" => "orange",
  666. "8" => "gelb",
  667. "9" => "gelb", # <===== FIX HERE
  668. "10" => "orange",
  669. "11" => "rot",
  670. "12" => "violett" );
  671. my @uwzmaxlevel;
  672. foreach my $single_warning (@sorted) {
  673. push @uwzmaxlevel, UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'});
  674. UWZ_Log $hash, 4, "Warn_".$i."_EventID: ".$single_warning->{'payload'}{'id'};
  675. $message .= "Warn_".$i."_EventID|".$single_warning->{'payload'}{'id'}."|";
  676. my $chopcreation = substr($single_warning->{'payload'}{'creation'},0,10);
  677. $chopcreation = $chopcreation;
  678. UWZ_Log $hash, 4, "Warn_".$i."_Creation: ".$chopcreation;
  679. $message .= "Warn_".$i."_Creation|".$chopcreation."|";
  680. UWZ_Log $hash, 4, "Warn_".$i."_Type: ".$single_warning->{'type'};
  681. $message .= "Warn_".$i."_Type|".$single_warning->{'type'}."|";
  682. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel: ".UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'});
  683. $message .= "Warn_".$i."_uwzLevel|".UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'})."|";
  684. UWZ_Log $hash, 4, "Warn_".$i."_Severity: ".$single_warning->{'severity'};
  685. $message .= "Warn_".$i."_Severity|".$single_warning->{'severity'}."|";
  686. UWZ_Log $hash, 4, "Warn_".$i."_Start: ".$single_warning->{'dtgStart'};
  687. $message .= "Warn_".$i."_Start|".$single_warning->{'dtgStart'}."|";
  688. UWZ_Log $hash, 4, "Warn_".$i."_End: ".$single_warning->{'dtgEnd'};
  689. $message .= "Warn_".$i."_End|".$single_warning->{'dtgEnd'}."|";
  690. ## Begin of redundant Reading
  691. if ( $UWZ_humanreadable eq 1 ) {
  692. UWZ_Log $hash, 4, "Warn_".$i."_Start_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'}));
  693. $message .= "Warn_".$i."_Start_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'}))."|";
  694. UWZ_Log $hash, 4, "Warn_".$i."_Start_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgStart'}));
  695. $message .= "Warn_".$i."_Start_Time|".strftime("%H:%M", localtime($single_warning->{'dtgStart'}))."|";
  696. UWZ_Log $hash, 4, "Warn_".$i."_End_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'}));
  697. $message .= "Warn_".$i."_End_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'}))."|";
  698. UWZ_Log $hash, 4, "Warn_".$i."_End_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgEnd'}));
  699. $message .= "Warn_".$i."_End_Time|".strftime("%H:%M", localtime($single_warning->{'dtgEnd'}))."|";
  700. UWZ_Log $hash, 4, "Warn_".$i."_Creation_Date: ".strftime("%d.%m.%Y", localtime($chopcreation));
  701. $message .= "Warn_".$i."_Creation_Date|".strftime("%d.%m.%Y", localtime($chopcreation))."|";
  702. UWZ_Log $hash, 4, "Warn_".$i."_Creation_Time: ".strftime("%H:%M", localtime($chopcreation));
  703. $message .= "Warn_".$i."_Creation_Time|".strftime("%H:%M", localtime($chopcreation))."|";
  704. # Begin Language by AttrVal
  705. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  706. UWZ_Log $hash, 4, "Warn_".$i."_Type_Str: ".$typenames_de_str{ $single_warning->{'type'} };
  707. $message .= "Warn_".$i."_Type_Str|".$typenames_de_str{ $single_warning->{'type'} }."|";
  708. my %uwzlevelname = ( "0" => "Stufe Grün (keine Warnung)",
  709. "1" => "Stufe Dunkelgrün (Wetterhinweise)",
  710. "2" => "Stufe Gelb (Vorwarnung für Unwetterwarnung)",
  711. "3" => "Warnstufe Orange (Unwetterwarnung)",
  712. "4" => "Warnstufe Rot (Unwetterwarnung)",
  713. "5" => "Warnstufe Violett (Unwetterwarnung)");
  714. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel_Str: ".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) };
  715. $message .= "Warn_".$i."_uwzLevel_Str|".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) }."|";
  716. } else {
  717. UWZ_Log $hash, 4, "Warn_".$i."_Type_Str: ".$typenames_en_str{ $single_warning->{'type'} };
  718. $message .= "Warn_".$i."_Type_Str|".$typenames_en_str{ $single_warning->{'type'} }."|";
  719. my %uwzlevelname = ( "0" => "level green (no warnings)",
  720. "1" => "level dark green (weather notice)",
  721. "2" => "level yellow (severe weather watch)",
  722. "3" => "Alert level Orange",
  723. "4" => "Alert level Red",
  724. "5" => "Alert level Violet");
  725. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel_Str: ".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) };
  726. $message .= "Warn_".$i."_uwzLevel_Str|".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) }."|";
  727. }
  728. }
  729. ## End of redundant Reading
  730. UWZ_Log $hash, 4, "Warn_".$i."_levelName: ".$single_warning->{'payload'}{'levelName'};
  731. $message .= "Warn_".$i."_levelName|".$single_warning->{'payload'}{'levelName'}."|";
  732. UWZ_Log $hash, 4, "Warn_".$i."_AltitudeMin: ".$enc->decode($single_warning->{'payload'}{'altMin'});
  733. $message .= "Warn_".$i."_AltitudeMin|".encode("UTF-8", decode("iso-8859-1", $single_warning->{'payload'}{'altMin'}))."|";
  734. UWZ_Log $hash, 4, "Warn_".$i."_AltitudeMax: ".$enc->decode($single_warning->{'payload'}{'altMax'});
  735. $message .= "Warn_".$i."_AltitudeMax|".encode("UTF-8", decode("iso-8859-1", $single_warning->{'payload'}{'altMax'}))."|";
  736. my $uclang = "EN";
  737. if (AttrVal( $name, 'lang',undef) ) {
  738. $uclang = uc AttrVal( $name, 'lang','');
  739. } else {
  740. # Begin Language by AttrVal
  741. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  742. $uclang = "DE";
  743. } else {
  744. $uclang = "EN";
  745. }
  746. }
  747. UWZ_Log $hash, 4, "Warn_".$i."_LongText: ".$enc->decode($single_warning->{'payload'}{'translationsLongText'}{$uclang});
  748. $message .= "Warn_".$i."_LongText|".encode("UTF-8", decode("iso-8859-1", $single_warning->{'payload'}{'translationsLongText'}{$uclang}))."|";
  749. UWZ_Log $hash, 4, "Warn_".$i."_ShortText: ".$enc->decode($single_warning->{'payload'}{'translationsShortText'}{$uclang});
  750. $message .= "Warn_".$i."_ShortText|".encode("UTF-8", decode("iso-8859-1", $single_warning->{'payload'}{'translationsShortText'}{$uclang}))."|";
  751. ###
  752. if (AttrVal( $name, 'localiconbase',undef) ) {
  753. UWZ_Log $hash, 4, "Warn_".$i."_IconURL: ".AttrVal( $name, 'localiconbase',undef).$typenames{ $single_warning->{'type'} }."-".$single_warning->{'severity'}.".png";
  754. $message .= "Warn_".$i."_IconURL|".AttrVal( $name, 'localiconbase',undef).$typenames{ $single_warning->{'type'} }."-".UWZ_GetSeverityColor($hash, UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'} )).".png|";
  755. } else {
  756. UWZ_Log $hash, 4, "Warn_".$i."_IconURL: http://www.unwetterzentrale.de/images/icons/".$typenames{ $single_warning->{'type'} }."-".$single_warning->{'severity'}.".gif";
  757. $message .= "Warn_".$i."_IconURL|http://www.unwetterzentrale.de/images/icons/".$typenames{ $single_warning->{'type'} }."-".UWZ_GetSeverityColor($hash, UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'} )).".gif|";
  758. }
  759. ###
  760. ## Hagel start
  761. my $hagelcount = 0;
  762. # Begin Language by AttrVal
  763. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  764. $hagelcount = my @hagelmatch = $single_warning->{'payload'}{'translationsLongText'}{'DE'} =~ /Hagel/g;
  765. } else {
  766. $hagelcount = my @hagelmatch = $single_warning->{'payload'}{'translationsLongText'}{'EN'} =~ /Hail/g;
  767. }
  768. # end language by AttrVal
  769. if ( $hagelcount ne 0 ) {
  770. UWZ_Log $hash, 4, "Warn_".$i."_Hail: 1";
  771. $message .= "Warn_".$i."_Hail|1|";
  772. } else {
  773. UWZ_Log $hash, 4, "Warn_".$i."_Hail: 0";
  774. $message .= "Warn_".$i."_Hail|0|";
  775. }
  776. ## Hagel end
  777. $i++;
  778. }
  779. my $max=0;
  780. for (@uwzmaxlevel) {
  781. $max = $_ if !$max || $_ > $max
  782. };
  783. $message .= "WarnUWZLevel|";
  784. $message .= $max."|";
  785. UWZ_Log $hash, 4, "WarnUWZLevel_Color: ".UWZ_GetSeverityColor($hash, $max);
  786. $message .= "WarnUWZLevel_Color|".UWZ_GetSeverityColor($hash, $max)."|";
  787. ## Begin of redundant Reading
  788. if ( $UWZ_humanreadable eq 1 ) {
  789. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  790. my %uwzlevelname = ( "0" => "Stufe Grün (keine Warnung)",
  791. "1" => "Stufe Dunkelgrün (Wetterhinweise)",
  792. "2" => "Stufe Gelb (Vorwarnung für Unwetterwarnung)",
  793. "3" => "Warnstufe Orange (Unwetterwarnung)",
  794. "4" => "Warnstufe Rot (Unwetterwarnung)",
  795. "5" => "Warnstufe Violett (Unwetterwarnung)");
  796. UWZ_Log $hash, 4, "WarnUWZLevel_Str: ".$uwzlevelname{ $max };
  797. $message .= "WarnUWZLevel_Str|".$uwzlevelname{ $max }."|";
  798. } else {
  799. my %uwzlevelname = ( "0" => "level green (no warnings)",
  800. "1" => "level dark green (weather notice)",
  801. "2" => "level yellow (severe weather watch)",
  802. "3" => "Alert level Orange",
  803. "4" => "Alert level Red",
  804. "5" => "Alert level Violet");
  805. UWZ_Log $hash, 4, "WarnUWZLevel_Str: ".$uwzlevelname{ $max };
  806. $message .= "WarnUWZLevel_Str|".$uwzlevelname{ $max }."|";
  807. }
  808. }
  809. $message .= "durationFetchReadings|";
  810. $message .= sprintf "%.2f", time() - $readingStartTime;
  811. UWZ_Log $hash, 3, "Done fetching data";
  812. UWZ_Log $hash, 4, "Will return : "."$name|$message|WarnCount|$uwz_warncount" ;
  813. return "$name|$message|WarnCount|$uwz_warncount" ;
  814. }
  815. #####################################
  816. sub UWZAsHtml($;$) {
  817. my ($name,$items) = @_;
  818. my $ret = '';
  819. my $hash = $defs{$name};
  820. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  821. my $htmltitle = AttrVal($name, "htmltitle", "");
  822. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  823. my $attr;
  824. if (AttrVal($name, "htmlattr", "none") ne "none") {
  825. $attr = AttrVal($name, "htmlattr", "");
  826. } else {
  827. $attr = 'width="100%"';
  828. }
  829. if (ReadingsVal($name, "WarnCount", 0) != 0 ) {
  830. $ret .= '<table><tr><td>';
  831. $ret .= '<table class="block" '.$attr.'><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  832. if ($htmlsequence eq "descending") {
  833. for ( my $i=ReadingsVal($name, "WarnCount", -1)-1; $i>=0; $i--){
  834. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  835. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  836. $ret .= ReadingsVal($name, "Warn_".$i."_LongText", "").'<br><br>';
  837. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  838. # language by AttrVal
  839. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  840. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  841. } else {
  842. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  843. }
  844. # end language by AttrVal
  845. $ret .= '</tr></table>';
  846. $ret .= '</td></tr>';
  847. }
  848. } else {
  849. ###
  850. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", 0); $i++){
  851. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  852. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  853. $ret .= ReadingsVal($name, "Warn_".$i."_LongText", "").'<br><br>';
  854. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  855. # language by AttrVal
  856. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  857. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  858. } else {
  859. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  860. }
  861. # end language by AttrVal
  862. $ret .= '</tr></table>';
  863. $ret .= '</td></tr>';
  864. }
  865. }
  866. ###
  867. $ret .= '</table>';
  868. $ret .= '</td></tr>';
  869. $ret .= '</table>';
  870. } else {
  871. $ret .= '<table><tr><td>';
  872. $ret .= '<table class="block wide" width="600px"><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  873. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;">';
  874. # language by AttrVal
  875. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  876. $ret .='<b>Keine Warnungen</b>';
  877. } else {
  878. $ret .='<b>No Warnings</b>';
  879. }
  880. # end language by AttrVal
  881. $ret .= '</td></tr>';
  882. $ret .= '</table>';
  883. $ret .= '</td></tr>';
  884. $ret .= '</table>';
  885. }
  886. return $ret;
  887. }
  888. #####################################
  889. sub UWZAsHtmlLite($;$) {
  890. my ($name,$items) = @_;
  891. my $ret = '';
  892. my $hash = $defs{$name};
  893. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  894. my $htmltitle = AttrVal($name, "htmltitle", "");
  895. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  896. my $attr;
  897. if (AttrVal($name, "htmlattr", "none") ne "none") {
  898. $attr = AttrVal($name, "htmlattr", "");
  899. } else {
  900. $attr = 'width="100%"';
  901. }
  902. if (ReadingsVal($name, "WarnCount", "") != 0 ) {
  903. $ret .= '<table><tr><td>';
  904. $ret .= '<table class="block" '.$attr.'><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  905. if ($htmlsequence eq "descending") {
  906. for ( my $i=ReadingsVal($name, "WarnCount", "")-1; $i>=0; $i--){
  907. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  908. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  909. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  910. # language by AttrVal
  911. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  912. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  913. } else {
  914. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  915. }
  916. # end language by AttrVal
  917. $ret .= '</tr></table>';
  918. $ret .= '</td></tr>';
  919. }
  920. } else {
  921. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", ""); $i++){
  922. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  923. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  924. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  925. # language by AttrVal
  926. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  927. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  928. } else {
  929. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  930. }
  931. # end language by AttrVal
  932. $ret .= '</tr></table>';
  933. $ret .= '</td></tr>';
  934. }
  935. }
  936. $ret .= '</table>';
  937. $ret .= '</td></tr>';
  938. $ret .= '</table>';
  939. } else {
  940. $ret .= '<table><tr><td>';
  941. $ret .= '<table class="block wide" width="600px"><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  942. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;">';
  943. # language by AttrVal
  944. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  945. $ret .='<b>Keine Warnungen</b>';
  946. } else {
  947. $ret .='<b>No Warnings</b>';
  948. }
  949. # end language by AttrVal
  950. $ret .= '</td></tr>';
  951. $ret .= '</table>';
  952. $ret .= '</td></tr>';
  953. $ret .= '</table>';
  954. }
  955. return $ret;
  956. }
  957. #####################################
  958. sub UWZAsHtmlFP($;$) {
  959. my ($name,$items) = @_;
  960. my $tablewidth = ReadingsVal($name, "WarnCount", "") * 80;
  961. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  962. my $htmltitle = AttrVal($name, "htmltitle", "");
  963. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  964. my $ret = '';
  965. $ret .= '<table class="uwz-fp" style="width:'.$tablewidth.'px"><tr><th class="'.$htmltitleclass.'" colspan="'.ReadingsVal($name, "WarnCount", "none").'">'.$htmltitle.'</th></tr>';
  966. $ret .= "<tr>";
  967. if ($htmlsequence eq "descending") {
  968. for ( my $i=ReadingsVal($name, "WarnCount", "")-1; $i>=0; $i--){
  969. $ret .= '<td class="uwzIcon"><img width="80px" src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  970. }
  971. } else {
  972. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", ""); $i++){
  973. $ret .= '<td class="uwzIcon"><img width="80px" src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  974. }
  975. }
  976. $ret .= "</tr>";
  977. $ret .= '</table>';
  978. return $ret;
  979. }
  980. #####################################
  981. sub UWZAsHtmlMovie($$) {
  982. my ($name,$land) = @_;
  983. my $url = UWZ_Map2Movie($name,$land);
  984. my $hash = $defs{$name};
  985. my $ret = '<table><tr><td>';
  986. $ret .= '<table class="block wide">';
  987. $ret .= '<tr class="even"><td>';
  988. if(defined($url)) {
  989. $ret .= '<video controls="controls">';
  990. $ret .= '<source src="'.$url.'" type="video/mp4">';
  991. $ret .= '</video>';
  992. } else {
  993. # language by AttrVal
  994. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  995. $ret .= 'unbekannte Landbezeichnung';
  996. } else {
  997. $ret .='unknown movie setting';
  998. }
  999. # end language by AttrVal
  1000. }
  1001. $ret .= '</td></tr></table></td></tr>';
  1002. $ret .= '</table>';
  1003. return $ret;
  1004. }
  1005. #####################################
  1006. sub UWZAsHtmlKarteLand($$) {
  1007. my ($name,$land) = @_;
  1008. my $url = UWZ_Map2Image($name,$land);
  1009. my $hash = $defs{$name};
  1010. my $ret = '<table><tr><td>';
  1011. $ret .= '<table class="block wide">';
  1012. $ret .= '<tr class="even"><td>';
  1013. if(defined($url)) {
  1014. $ret .= '<img src="'.$url.'">';
  1015. } else {
  1016. # language by AttrVal
  1017. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  1018. $ret .= 'unbekannte Landbezeichnung';
  1019. } else {
  1020. $ret .='unknown map setting';
  1021. }
  1022. # end language by AttrVal
  1023. }
  1024. $ret .= '</td></tr></table></td></tr>';
  1025. $ret .= '</table>';
  1026. return $ret;
  1027. }
  1028. #####################################
  1029. sub UWZ_GetSeverityColor($$) {
  1030. my ($name,$uwzlevel) = @_;
  1031. my $alertcolor = "";
  1032. my %UWZSeverity = ( "0" => "gruen",
  1033. "1" => "orange",
  1034. "2" => "gelb",
  1035. "3" => "orange",
  1036. "4" => "rot",
  1037. "5" => "violett");
  1038. return $UWZSeverity{$uwzlevel};
  1039. }
  1040. #####################################
  1041. sub UWZ_GetUWZLevel($$) {
  1042. my ($name,$warnname) = @_;
  1043. my @alert = split(/_/,$warnname);
  1044. if ( $alert[0] eq "notice" ) {
  1045. return "1";
  1046. } elsif ( $alert[1] eq "forewarn" ) {
  1047. return "2";
  1048. } else {
  1049. my %UWZSeverity = ( "green" => "0",
  1050. "yellow" => "2",
  1051. "orange" => "3",
  1052. "red" => "4",
  1053. "violet" => "5");
  1054. return $UWZSeverity{$alert[2]};
  1055. }
  1056. }
  1057. #####################################
  1058. sub UWZ_IntervalAtWarnLevel($) {
  1059. my $hash = shift;
  1060. my $name = $hash->{NAME};
  1061. my $warnLevel = ReadingsVal($name,'WarnUWZLevel',0);
  1062. my @valuestring = split( ',', AttrVal($name,'intervalAtWarnLevel','') );
  1063. my %warnLevelInterval;
  1064. readingsSingleUpdate($hash,'currentIntervalMode','warn',0);
  1065. foreach( @valuestring ) {
  1066. my @values = split( '=' , $_ );
  1067. $warnLevelInterval{$values[0]} = $values[1];
  1068. }
  1069. if( defined($warnLevelInterval{$warnLevel}) and $hash->{INTERVALWARN} != $warnLevelInterval{$warnLevel} ) {
  1070. $hash->{INTERVALWARN} = $warnLevelInterval{$warnLevel};
  1071. RemoveInternalTimer( $hash );
  1072. InternalTimer(gettimeofday() + $hash->{INTERVALWARN}, "UWZ_Start", $hash, 1 );
  1073. UWZ_Log $hash, 4, "restart internal timer with interval $hash->{INTERVALWARN}";
  1074. } else {
  1075. RemoveInternalTimer( $hash );
  1076. InternalTimer(gettimeofday() + $hash->{INTERVALWARN}, "UWZ_Start", $hash, 1 );
  1077. UWZ_Log $hash, 4, "restart internal timer with interval $hash->{INTERVALWARN}";
  1078. }
  1079. }
  1080. #####################################
  1081. ##
  1082. ## UWZ Helper Functions
  1083. ##
  1084. #####################################
  1085. sub UWZSearchLatLon($$) {
  1086. my ($name,$loc) = @_;
  1087. my $url = "http://alertspro.geoservice.meteogroup.de/weatherpro/SearchFeed.php?search=".$loc;
  1088. my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
  1089. my $request = HTTP::Request->new( GET => $url );
  1090. my $response = $agent->request($request);
  1091. my $err_log = "Can't get $url -- " . $response->status_line unless( $response->is_success );
  1092. if ( $err_log ne "" ) {
  1093. print "Error|Error " . $response->status_line;
  1094. }
  1095. use XML::Simple qw(:strict);
  1096. use Data::Dumper;
  1097. use Encode qw(decode encode);
  1098. my $uwzxmlparser = XML::Simple->new();
  1099. #my $xmlres = $parser->XMLin(
  1100. my $search = $uwzxmlparser->XMLin($response->content, KeyAttr => { city => 'id' }, ForceArray => [ 'city' ]);
  1101. my $ret = '<html><table><tr><td>';
  1102. $ret .= '<table class="block wide">';
  1103. $ret .= '<tr class="even">';
  1104. $ret .= "<td><b>city</b></td>";
  1105. $ret .= "<td><b>country</b></td>";
  1106. $ret .= "<td><b>latitude</b></td>";
  1107. $ret .= "<td><b>longitude</b></td>";
  1108. $ret .= '</tr>';
  1109. foreach my $locres ($search->{cities}->{city})
  1110. {
  1111. my $linecount=1;
  1112. while ( my ($key, $value) = each(%$locres) ) {
  1113. if ( $linecount % 2 == 0 ) {
  1114. $ret .= '<tr class="even">';
  1115. } else {
  1116. $ret .= '<tr class="odd">';
  1117. }
  1118. $ret .= "<td>".encode('utf-8',$value->{'name'})."</td>";
  1119. $ret .= "<td>$value->{'country-name'}</td>";
  1120. $ret .= "<td>$value->{'latitude'}</td>";
  1121. $ret .= "<td>$value->{'longitude'}</td>";
  1122. my @headerHost = grep /Host/, @FW_httpheader;
  1123. $headerHost[0] =~ s/Host: //g;
  1124. my $aHref="<a href=\"http://".$headerHost[0]."/fhem?cmd=get+".$name."+AreaID+".$value->{'latitude'}.",".$value->{'longitude'}."\">Get AreaID</a>";
  1125. $ret .= "<td>".$aHref."</td>";
  1126. $ret .= '</tr>';
  1127. $linecount++;
  1128. }
  1129. }
  1130. $ret .= '</table></td></tr>';
  1131. $ret .= '</table></html>';
  1132. return $ret;
  1133. }
  1134. #####################################
  1135. sub UWZSearchAreaID($$) {
  1136. my ($lat,$lon) = @_;
  1137. my $url = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=lookupCoord&lat=".$lat."&lon=".$lon;
  1138. my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
  1139. my $request = HTTP::Request->new( GET => $url );
  1140. my $response = $agent->request($request);
  1141. my $err_log = "Can't get $url -- " . $response->status_line unless( $response->is_success );
  1142. if ( $err_log ne "" ) {
  1143. print "Error|Error " . $response->status_line;
  1144. }
  1145. use JSON;
  1146. my @perl_scalar = @{JSON->new->utf8->decode($response->content)};
  1147. my $AreaType = $perl_scalar[0]->{'AREA_TYPE'};
  1148. my $CC = substr $perl_scalar[0]->{'AREA_ID'}, 3, 2;
  1149. my $AreaID = substr $perl_scalar[0]->{'AREA_ID'}, 5, 5;
  1150. if ( $AreaType eq "UWZ" ) {
  1151. my $ret = '<html>Please use the following statement to define Unwetterzentrale for your location:<br /><br />';
  1152. $ret .= '<table width=100%><tr><td>';
  1153. $ret .= '<table class="block wide">';
  1154. $ret .= '<tr class="even">';
  1155. $ret .= "<td height=100><center><b>define Unwetterzentrale UWZ $CC $AreaID 3600</b></center></td>";
  1156. $ret .= '</tr>';
  1157. $ret .= '</table>';
  1158. $ret .= '</td></tr></table>';
  1159. $ret .= '<br />';
  1160. $ret .= 'You can also use weblinks to add weathermaps. For a list of possible Weblinks see Commandref. For example to add the Europe Map use:<br />';
  1161. $ret .= '<table width=100%><tr><td>';
  1162. $ret .= '<table class="block wide">';
  1163. $ret .= '<tr class="even">';
  1164. $ret .= "<td height=100><center>define UWZ_Map_Europe weblink htmlCode { UWZAsHtmlKarteLand('Unwetterzentrale','europa') }</center></td>";
  1165. $ret .= '</tr>';
  1166. $ret .= '</table>';
  1167. $ret .= '</td></tr></table>';
  1168. $ret .= '</html>';
  1169. return $ret;
  1170. } else {
  1171. return "Sorry, nothing found or not implemented";
  1172. }
  1173. }
  1174. #####################################
  1175. 1;
  1176. =pod
  1177. =item device
  1178. =item summary extracts thunderstorm warnings from unwetterzentrale.de
  1179. =item summary_DE extrahiert Unwetterwarnungen von unwetterzentrale.de
  1180. =begin html
  1181. <a name="UWZ"></a>
  1182. <h3>UWZ</h3>
  1183. <ul>
  1184. <a name="UWZdefine"></a>
  1185. This modul extracts thunderstorm warnings from <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a>.
  1186. <br/>
  1187. Therefore the same interface is used as the Android App <a href="http://www.alertspro.com">Alerts Pro</a> does.
  1188. A maximum of 10 thunderstorm warnings will be served.
  1189. Additional the module provides a few functions to create HTML-Templates which can be used with weblink.
  1190. <br>
  1191. <i>The following Perl-Modules are used within this module: HTTP::Request, LWP::UserAgent, JSON, Encode::Guess und HTML::Parse</i>.
  1192. <br/><br/>
  1193. <b>Define</b>
  1194. <ul>
  1195. <br>
  1196. <code>define &lt;Name&gt; UWZ [CountryCode] [AreaID] [INTERVAL]</code>
  1197. <br><br><br>
  1198. Example:
  1199. <br>
  1200. <code>
  1201. define Unwetterzentrale UWZ UK 08357 1800<br>
  1202. attr Unwetterzentrale download 1<br>
  1203. attr Unwetterzentrale humanreadable 1<br>
  1204. attr Unwetterzentrale maps eastofengland unitedkingdom<br><br>
  1205. define UnwetterDetails weblink htmlCode {UWZAsHtml("Unwetterzentrale")}<br>
  1206. define UnwetterMapE_UK weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","eastofengland")}<br>
  1207. define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}
  1208. define UnwetterMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","clouds-precipitation-uk")}
  1209. </code>
  1210. <br>&nbsp;
  1211. <li><code>[CountryCode]</code>
  1212. <br>
  1213. Possible values: DE, AT, CH, UK, ...<br/>
  1214. (for other countries than germany use SEARCH for CountryCode to start device in search mode)
  1215. </li><br>
  1216. <li><code>[AreaID]</code>
  1217. <br>
  1218. For Germany you can use the postalcode, other countries use SEARCH for CountryCode to start device in search mode.
  1219. <br>
  1220. </li><br>
  1221. <li><code>[INTERVAL]</code>
  1222. <br>
  1223. Defines the refresh interval. The interval is defined in seconds, so an interval of 3600 means that every hour a refresh will be triggered onetimes.
  1224. <br>
  1225. </li><br>
  1226. <br><br><br>
  1227. Example Search-Mode:
  1228. <br>
  1229. <code>
  1230. define Unwetterzentrale UWZ SEARCH<br>
  1231. </code>
  1232. <br>
  1233. now get the AreaID for your location (example shows london):
  1234. <br>
  1235. <code>
  1236. get Unwetterzentrale SearchAreaID London<br>
  1237. </code>
  1238. <br>
  1239. now redefine your device with the outputted CountryCode and AreaID.
  1240. <br>
  1241. <br>&nbsp;
  1242. </ul>
  1243. <br>
  1244. <a name="UWZget"></a>
  1245. <b>Get</b>
  1246. <ul>
  1247. <br>
  1248. <li><code>get &lt;name&gt; soil-frost</code>
  1249. <br>
  1250. give info about current soil frost (active|inactive).
  1251. </li><br>
  1252. <li><code>get &lt;name&gt; extremfrost</code>
  1253. <br>
  1254. give info about current frost (active|inactive).
  1255. </li><br>
  1256. <li><code>get &lt;name&gt; thunderstorm</code>
  1257. <br>
  1258. give info about current thunderstorm (active|inactive).
  1259. </li><br>
  1260. <li><code>get &lt;name&gt; glaze</code>
  1261. <br>
  1262. give info about current glaze (active|inactive).
  1263. </li><br>
  1264. <li><code>get &lt;name&gt; glazed-rain</code>
  1265. <br>
  1266. give info about current freezing rain (active|inactive).
  1267. </li><br>
  1268. <li><code>get &lt;name&gt; hail</code>
  1269. <br>
  1270. give info about current hail (active|inactive).
  1271. </li><br>
  1272. <li><code>get &lt;name&gt; heat</code>
  1273. <br>
  1274. give info about current heat (active|inactive).
  1275. </li><br>
  1276. <li><code>get &lt;name&gt; rain</code>
  1277. <br>
  1278. give info about current rain (active|inactive).
  1279. </li><br>
  1280. <li><code>get &lt;name&gt; snow</code>
  1281. <br>
  1282. give info about current snow (active|inactive).
  1283. </li><br>
  1284. <li><code>get &lt;name&gt; storm</code>
  1285. <br>
  1286. give info about current storm (active|inactive).
  1287. </li><br>
  1288. <li><code>get &lt;name&gt; forest-fire</code>
  1289. <br>
  1290. give info about current forest fire (active|inactive).
  1291. </li><br>
  1292. </ul>
  1293. <br>
  1294. <b>Get (Search-Mode)</b>
  1295. <ul>
  1296. <br>
  1297. <li><code>get &lt;name&gt; SearchAreaID &lt;city&gt;</code>
  1298. <br>
  1299. Get AreaID coresponnding to entered location.
  1300. </li><br>
  1301. </ul>
  1302. <br>
  1303. <a name="UWZset"></a>
  1304. <b>Set</b>
  1305. <ul>
  1306. <br>
  1307. <li><code>set &lt;name&gt; update</code>
  1308. <br>
  1309. Executes an imediate update of thunderstorm warnings.
  1310. </li><br>
  1311. </ul>
  1312. <br>
  1313. <a name="UWZattr"></a>
  1314. <b>Attributes</b>
  1315. <ul>
  1316. <br>
  1317. <li><code>download</code>
  1318. <br>
  1319. Download maps during update (0|1).
  1320. <br>
  1321. </li>
  1322. <li><code>savepath</code>
  1323. <br>
  1324. Define where to store the map png files (default: /tmp/).
  1325. <br>
  1326. </li>
  1327. <li><code>maps</code>
  1328. <br>
  1329. Define the maps to download space seperated. For possible values see <code>UWZAsHtmlKarteLand</code>.
  1330. <br>
  1331. </li>
  1332. <li><code>humanreadable</code>
  1333. <br>
  1334. Add additional Readings Warn_?_Start_Date, Warn_?_Start_Time, Warn_?_End_Date and Warn_?_End_Time containing the coresponding timetamp in a human readable manner. Additionally Warn_?_uwzLevel_Str and Warn_?_Type_Str will be added to device readings (0|1).
  1335. <br>
  1336. </li>
  1337. <li><code>lang</code>
  1338. <br>
  1339. Overwrite requested language for short and long warn text. (de|en|it|fr|es|..).
  1340. <br>
  1341. </li>
  1342. <li><code>sort_readings_by</code>
  1343. <br>
  1344. define how readings will be sortet (start|severity|creation).
  1345. <br>
  1346. </li>
  1347. <li><code>htmlsequence</code>
  1348. <br>
  1349. define warn order of html output (ascending|descending).
  1350. <br>
  1351. </li>
  1352. <li><code>htmltitle</code>
  1353. <br>
  1354. title / header for the html ouput
  1355. <br>
  1356. </li>
  1357. <li><code>htmltitleclass</code>
  1358. <br>
  1359. css-Class of title / header for the html ouput
  1360. <br>
  1361. </li>
  1362. <li><code>localiconbase</code>
  1363. <br>
  1364. define baseurl to host your own thunderstorm warn pics (filetype is png).
  1365. <br>
  1366. </li>
  1367. <li><code>intervalAtWarnLevel</code>
  1368. <br>
  1369. define the interval per warnLevel. Example: 2=1800,3=900,4=300
  1370. <br>
  1371. </li>
  1372. <br>
  1373. </ul>
  1374. <br>
  1375. <a name="UWZreading"></a>
  1376. <b>Readings</b>
  1377. <ul>
  1378. <br>
  1379. <li><b>Warn_</b><i>0|1|2|3...|9</i><b>_...</b> - active warnings</li>
  1380. <li><b>WarnCount</b> - warnings count</li>
  1381. <li><b>WarnUWZLevel</b> - total warn level </li>
  1382. <li><b>WarnUWZLevel_Color</b> - total warn level color</li>
  1383. <li><b>WarnUWZLevel_Str</b> - total warn level string</li>
  1384. <li><b>Warn_</b><i>0</i><b>_AltitudeMin</b> - minimum altitude for warning </li>
  1385. <li><b>Warn_</b><i>0</i><b>_AltitudeMax</b> - maximum altitude for warning </li>
  1386. <li><b>Warn_</b><i>0</i><b>_EventID</b> - warning EventID </li>
  1387. <li><b>Warn_</b><i>0</i><b>_Creation</b> - warning creation </li>
  1388. <li><b>Warn_</b><i>0</i><b>_Creation_Date</b> - warning creation datum </li>
  1389. <li><b>Warn_</b><i>0</i><b>_Creation_Time</b> - warning creation time </li>
  1390. <li><b>currentIntervalMode</b> - default/warn, Interval is read from INTERVAL or INTERVALWARN Internal</li>
  1391. <li><b>Warn_</b><i>0</i><b>_Start</b> - begin of warnperiod</li>
  1392. <li><b>Warn_</b><i>0</i><b>_Start_Date</b> - start date of warnperiod</li>
  1393. <li><b>Warn_</b><i>0</i><b>_Start_Time</b> - start time of warnperiod</li>
  1394. <li><b>Warn_</b><i>0</i><b>_End</b> - end of warnperiod</li>
  1395. <li><b>Warn_</b><i>0</i><b>_End_Date</b> - end date of warnperiod</li>
  1396. <li><b>Warn_</b><i>0</i><b>_End_Time</b> - end time of warnperiod</li>
  1397. <li><b>Warn_</b><i>0</i><b>_Severity</b> - Severity of thunderstorm (0 no thunderstorm, 4, 7, 11, .. heavy thunderstorm)</li>
  1398. <li><b>Warn_</b><i>0</i><b>_Hail</b> - warning contains hail</li>
  1399. <li><b>Warn_</b><i>0</i><b>_Type</b> - kind of thunderstorm</li>
  1400. <li><b>Warn_</b><i>0</i><b>_Type_Str</b> - kind of thunderstorm (text)</li>
  1401. <ul>
  1402. <li><b>1</b> - unknown</li>
  1403. <li><b>2</b> - storm</li>
  1404. <li><b>3</b> - snow</li>
  1405. <li><b>4</b> - rain</li>
  1406. <li><b>5</b> - frost</li>
  1407. <li><b>6</b> - forest fire</li>
  1408. <li><b>7</b> - thunderstorm</li>
  1409. <li><b>8</b> - glaze</li>
  1410. <li><b>9</b> - heat</li>
  1411. <li><b>10</b> - freezing rain</li>
  1412. <li><b>11</b> - soil frost</li>
  1413. </ul>
  1414. <li><b>Warn_</b><i>0</i><b>_uwzLevel</b> - Severity of thunderstorm (0-5)</li>
  1415. <li><b>Warn_</b><i>0</i><b>_uwzLevel_Str</b> - Severity of thunderstorm (text)</li>
  1416. <li><b>Warn_</b><i>0</i><b>_levelName</b> - Level Warn Name</li>
  1417. <li><b>Warn_</b><i>0</i><b>_ShortText</b> - short warn text</li>
  1418. <li><b>Warn_</b><i>0</i><b>_LongText</b> - detailed warn text</li>
  1419. <li><b>Warn_</b><i>0</i><b>_IconURL</b> - cumulated URL to display warn-icons from <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a></li>
  1420. </ul>
  1421. <br>
  1422. <a name="UWZweblinks"></a>
  1423. <b>Weblinks</b>
  1424. <ul>
  1425. <br>
  1426. With the additional implemented functions <code>UWZAsHtml, UWZAsHtmlLite, UWZAsHtmlFP, UWZAsHtmlKarteLand and UWZAsHtmlMovie</code> HTML-Code will be created to display warnings and weathermovies, using weblinks.
  1427. <br><br><br>
  1428. Example:
  1429. <br>
  1430. <li><code>define UnwetterDetailiert weblink htmlCode {UWZAsHtml("Unwetterzentrale")}</code></li>
  1431. <br>
  1432. <li><code>define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}</code></li>
  1433. <br>
  1434. <li><code>define UnwetterFloorplan weblink htmlCode {UWZAsHtmlFP("Unwetterzentrale")}</code></li>
  1435. <br>
  1436. <li><code>define UnwetterKarteLand weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","Bayern")}</code></li>
  1437. <ul>
  1438. <li>The second parameter should be one of:
  1439. <ul>
  1440. <li>europa</li>
  1441. <br/>
  1442. <li>deutschland</li>
  1443. <li>deutschland-small</li>
  1444. <li>niedersachsen</li>
  1445. <li>bremen</li>
  1446. <li>bayern</li>
  1447. <li>schleswig-holstein</li>
  1448. <li>hamburg</li>
  1449. <li>mecklenburg-vorpommern</li>
  1450. <li>sachsen</li>
  1451. <li>sachsen-anhalt</li>
  1452. <li>nordrhein-westfalen</li>
  1453. <li>thueringen</li>
  1454. <li>rheinland-pfalz</li>
  1455. <li>saarland</li>
  1456. <li>baden-wuerttemberg</li>
  1457. <li>hessen</li>
  1458. <li>brandenburg</li>
  1459. <li>berlin</li>
  1460. <br/>
  1461. <li>oesterreich</li>
  1462. <li>burgenland</li>
  1463. <li>kaernten</li>
  1464. <li>niederoesterreich</li>
  1465. <li>oberoesterreich</li>
  1466. <li>salzburg</li>
  1467. <li>steiermark</li>
  1468. <li>tirol</li>
  1469. <li>vorarlberg</li>
  1470. <li>wien</li>
  1471. <br/>
  1472. <li>schweiz</li>
  1473. <li>aargau</li>
  1474. <li>appenzell_ausserrhoden</li>
  1475. <li>appenzell_innerrhoden</li>
  1476. <li>basel_landschaft</li>
  1477. <li>basel_stadt</li>
  1478. <li>bern</li>
  1479. <li>fribourg</li>
  1480. <li>geneve</li>
  1481. <li>glarus</li>
  1482. <li>graubuenden</li>
  1483. <li>jura</li>
  1484. <li>luzern</li>
  1485. <li>neuchatel</li>
  1486. <li>nidwalden</li>
  1487. <li>obwalden</li>
  1488. <li>schaffhausen</li>
  1489. <li>schwyz</li>
  1490. <li>solothurn</li>
  1491. <li>stgallen</li>
  1492. <li>ticino</li>
  1493. <li>thurgau</li>
  1494. <li>uri</li>
  1495. <li>waadt</li>
  1496. <li>wallis</li>
  1497. <li>zug</li>
  1498. <li>zuerich</li>
  1499. <br/>
  1500. <li>liechtenstein</li>
  1501. <br/>
  1502. <li>belgique</li>
  1503. <br/>
  1504. <li>denmark</li>
  1505. <br/>
  1506. <li>finnland</li>
  1507. <br/>
  1508. <li>france</li>
  1509. <br/>
  1510. <li>letzebuerg</li>
  1511. <br/>
  1512. <li>nederland</li>
  1513. <br/>
  1514. <li>norwegen</li>
  1515. <br/>
  1516. <li>portugal</li>
  1517. <br/>
  1518. <li>sverige</li>
  1519. <br/>
  1520. <li>espana</li>
  1521. <br/>
  1522. <li>unitedkingdom</li>
  1523. <li>eastofengland</li>
  1524. <li>eastmidlands</li>
  1525. <li>london</li>
  1526. <li>northeastengland</li>
  1527. <li>northernireland</li>
  1528. <li>northwestengland</li>
  1529. <li>scotland</li>
  1530. <li>southeastengland</li>
  1531. <li>southwestengland</li>
  1532. <li>wales</li>
  1533. <li>westmidlands</li>
  1534. <li>yorkshireandthehumber</li>
  1535. <br/>
  1536. <li>isobaren1</li>
  1537. <li>isobaren2</li>
  1538. <li>isobaren3</li>
  1539. </ul>
  1540. </li>
  1541. </ul>
  1542. <li><code>define UnwetterKarteMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","currents")}</code></li>
  1543. <ul>
  1544. <li>The second parameter should be one of:
  1545. <ul>
  1546. <li>niederschlag-wolken</li>
  1547. <li>stroemung</li>
  1548. <li>temperatur</li>
  1549. <br/>
  1550. <li>niederschlag-wolken-de</li>
  1551. <li>stroemung-de</li>
  1552. <br/>
  1553. <li>niederschlag-wolken-ch</li>
  1554. <li>stroemung-ch</li>
  1555. <br/>
  1556. <li>niederschlag-wolken-at</li>
  1557. <li>stroemung-at</li>
  1558. <br/>
  1559. <li>niederschlag-wolken-uk</li>
  1560. <li>stroemung-uk</li>
  1561. <br/>
  1562. </ul>
  1563. </li>
  1564. </ul>
  1565. <br/><br/>
  1566. </ul>
  1567. <br>
  1568. </ul>
  1569. =end html
  1570. =begin html_DE
  1571. <a name="UWZ"></a>
  1572. <h3>UWZ</h3>
  1573. <ul>
  1574. <a name="UWZdefine"></a>
  1575. Das Modul extrahiert Unwetterwarnungen von <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a>.
  1576. <br/>
  1577. Hierfür wird die selbe Schnittstelle verwendet die auch die Android App <a href="http://www.alertspro.com">Alerts Pro</a> nutzt.
  1578. Es werden maximal 10 Standortbezogene Unwetterwarnungen zur Verfügung gestellt.
  1579. Weiterhin verfügt das Modul über HTML-Templates welche als weblink verwendet werden können.
  1580. <br>
  1581. <i>Es nutzt die Perl-Module HTTP::Request, LWP::UserAgent, JSON, Encode::Guess und HTML::Parse</i>.
  1582. <br/><br/>
  1583. <b>Define</b>
  1584. <ul>
  1585. <br>
  1586. <code>define &lt;Name&gt; UWZ [L&auml;ndercode] [Postleitzahl] [INTERVAL]</code>
  1587. <br><br><br>
  1588. Beispiel:
  1589. <br>
  1590. <code>define Unwetterzentrale UWZ DE 86405 3600</code>
  1591. <br>&nbsp;
  1592. <li><code>[L&auml;ndercode]</code>
  1593. <br>
  1594. M&ouml;gliche Werte: DE, AT, CH, SEARCH, ...<br/>
  1595. (f&uuml;r ander L&auml;nder als Deutschland bitte den SEARCH Parameter nutzen um die AreaID zu ermitteln.)
  1596. </li><br>
  1597. <li><code>[Postleitzahl/AreaID]</code>
  1598. <br>
  1599. Die Postleitzahl/AreaID des Ortes für den Unwetterinformationen abgefragt werden sollen.
  1600. <br>
  1601. </li><br>
  1602. <li><code>[INTERVAL]</code>
  1603. <br>
  1604. Definiert das Interval zur aktualisierung der Unwetterwarnungen. Das Interval wird in Sekunden angegeben, somit aktualisiert das Modul bei einem Interval von 3600 jede Stunde 1 mal.
  1605. <br>
  1606. </li><br>
  1607. </ul>
  1608. <br>
  1609. <a name="UWZget"></a>
  1610. <b>Get</b>
  1611. <ul>
  1612. <br>
  1613. <li><code>get &lt;name&gt; Bodenfrost</code>
  1614. <br>
  1615. Gibt aus ob aktuell eine Bodenfrostwarnung besteht (active|inactive).
  1616. </li><br>
  1617. <li><code>get &lt;name&gt; Extremfrost</code>
  1618. <br>
  1619. Gibt aus ob aktuell eine Extremfrostwarnung besteht (active|inactive).
  1620. </li><br>
  1621. <li><code>get &lt;name&gt; Gewitter</code>
  1622. <br>
  1623. Gibt aus ob aktuell eine Gewitter Warnung besteht (active|inactive).
  1624. </li><br>
  1625. <li><code>get &lt;name&gt; Glaette</code>
  1626. <br>
  1627. Gibt aus ob aktuell eine Glaettewarnung besteht (active|inactive).
  1628. </li><br>
  1629. <li><code>get &lt;name&gt; Glatteisregen</code>
  1630. <br>
  1631. Gibt aus ob aktuell eine Glatteisregen Warnung besteht (active|inactive).
  1632. </li><br>
  1633. <li><code>get &lt;name&gt; Hagel</code>
  1634. <br>
  1635. Gibt aus ob aktuell eine Hagel Warnung besteht (active|inactive).
  1636. </li><br>
  1637. <li><code>get &lt;name&gt; Hitze</code>
  1638. <br>
  1639. Gibt aus ob aktuell eine Hitze Warnung besteht (active|inactive).
  1640. </li><br>
  1641. <li><code>get &lt;name&gt; Regen</code>
  1642. <br>
  1643. Gibt aus ob aktuell eine Regen Warnung besteht (active|inactive).
  1644. </li><br>
  1645. <li><code>get &lt;name&gt; Schneefall</code>
  1646. <br>
  1647. Gibt aus ob aktuell eine Schneefall Warnung besteht (active|inactive).
  1648. </li><br>
  1649. <li><code>get &lt;name&gt; Sturm</code>
  1650. <br>
  1651. Gibt aus ob aktuell eine Sturm Warnung besteht (active|inactive).
  1652. </li><br>
  1653. <li><code>get &lt;name&gt; Waldbrand</code>
  1654. <br>
  1655. Gibt aus ob aktuell eine Waldbrand Warnung besteht (active|inactive).
  1656. </li><br>
  1657. </ul>
  1658. <br>
  1659. <b>Get (Search-Mode)</b>
  1660. <ul>
  1661. <br>
  1662. <li><code>get &lt;name&gt; SearchAreaID &lt;gesuchte_stadt&gt;</code>
  1663. <br>
  1664. Gibt die AreaID zum eingegebenen Ort aus.
  1665. </li><br>
  1666. </ul>
  1667. <br>
  1668. <a name="UWZset"></a>
  1669. <b>Set</b>
  1670. <ul>
  1671. <br>
  1672. <li><code>set &lt;name&gt; update</code>
  1673. <br>
  1674. Startet sofort ein neues Auslesen der Unwetterinformationen.
  1675. </li><br>
  1676. </ul>
  1677. <br>
  1678. <a name="UWZattr"></a>
  1679. <b>Attribute</b>
  1680. <ul>
  1681. <br>
  1682. <li><code>download</code>
  1683. <br>
  1684. Download Unwetterkarten während des updates (0|1).
  1685. <br>
  1686. </li>
  1687. <li><code>savepath</code>
  1688. <br>
  1689. Pfad zum speichern der Karten (default: /tmp/).
  1690. <br>
  1691. </li>
  1692. <li><code>maps</code>
  1693. <br>
  1694. Leerzeichen separierte Liste der zu speichernden Karten. Für mögliche Karten siehe <code>UWZAsHtmlKarteLand</code>.
  1695. <br>
  1696. </li>
  1697. <li><code>humanreadable</code>
  1698. <br>
  1699. Anzeige weiterer Readings Warn_?_Start_Date, Warn_?_Start_Time, Warn_?_End_Date, Warn_?_End_Time. Diese Readings enthalten aus dem Timestamp kalkulierte Datums/Zeit Angaben. Weiterhin werden folgende Readings aktivier: Warn_?_Type_Str und Warn_?_uwzLevel_Str welche den Unwettertyp als auch das Unwetter-Warn-Level als Text ausgeben. (0|1)
  1700. <br>
  1701. </li>
  1702. <li><code>lang</code>
  1703. <br>
  1704. Umschalten der angeforderten Sprache für kurz und lange warn text. (de|en|it|fr|es|..).
  1705. <br>
  1706. </li>
  1707. <li><code>sort_readings_by</code>
  1708. <br>
  1709. Sortierreihenfolge der Warnmeldungen. (start|severity|creation).
  1710. <br>
  1711. </li>
  1712. <li><code>htmlsequence</code>
  1713. <br>
  1714. Anzeigereihenfolge der html warnungen. (ascending|descending).
  1715. <br>
  1716. </li>
  1717. <li><code>htmltitle</code>
  1718. <br>
  1719. Titel / Ueberschrift der HTML Ausgabe
  1720. <br>
  1721. </li>
  1722. <li><code>htmltitleclass</code>
  1723. <br>
  1724. css-Class des Titels der HTML Ausgabe
  1725. <br>
  1726. </li>
  1727. <li><code>localiconbase</code>
  1728. <br>
  1729. BaseURL angeben um Warn Icons lokal zu hosten. (Dateityp ist png).
  1730. <br>
  1731. </li>
  1732. <li><code>intervalAtWarnLevel</code>
  1733. <br>
  1734. konfiguriert den Interval je nach WarnLevel. Beispiel: 2=1800,3=900,4=300
  1735. <br>
  1736. </li>
  1737. <br>
  1738. </ul>
  1739. <br>
  1740. <a name="UWZreading"></a>
  1741. <b>Readings</b>
  1742. <ul>
  1743. <br>
  1744. <li><b>Warn_</b><i>0|1|2|3...|9</i><b>_...</b> - aktive Warnmeldungen</li>
  1745. <li><b>WarnCount</b> - Anzahl der aktiven Warnmeldungen</li>
  1746. <li><b>WarnUWZLevel</b> - Gesamt Warn Level </li>
  1747. <li><b>WarnUWZLevel_Color</b> - Gesamt Warn Level Farbe</li>
  1748. <li><b>WarnUWZLevel_Str</b> - Gesamt Warn Level Text</li>
  1749. <li><b>Warn_</b><i>0</i><b>_AltitudeMin</b> - minimum Höhe für Warnung </li>
  1750. <li><b>Warn_</b><i>0</i><b>_AltitudeMax</b> - maximum Höhe für Warnung </li>
  1751. <li><b>Warn_</b><i>0</i><b>_EventID</b> - EventID der Warnung </li>
  1752. <li><b>Warn_</b><i>0</i><b>_Creation</b> - Warnungs Erzeugung </li>
  1753. <li><b>Warn_</b><i>0</i><b>_Creation_Date</b> - Warnungs Erzeugungs Datum </li>
  1754. <li><b>Warn_</b><i>0</i><b>_Creation_Time</b> - Warnungs Erzeugungs Zeit </li>
  1755. <li><b>currentIntervalMode</b> - default/warn, aktuell Verwendeter Interval. Internal INTERVAL oder INTERVALWARN</li>
  1756. <li><b>Warn_</b><i>0</i><b>_Start</b> - Begin der Warnung</li>
  1757. <li><b>Warn_</b><i>0</i><b>_Start_Date</b> - Startdatum der Warnung</li>
  1758. <li><b>Warn_</b><i>0</i><b>_Start_Time</b> - Startzeit der Warnung</li>
  1759. <li><b>Warn_</b><i>0</i><b>_End</b> - Warn Ende</li>
  1760. <li><b>Warn_</b><i>0</i><b>_End_Date</b> - Enddatum der Warnung</li>
  1761. <li><b>Warn_</b><i>0</i><b>_End_Time</b> - Endzeit der Warnung</li>
  1762. <li><b>Warn_</b><i>0</i><b>_Severity</b> - Schwere des Unwetters (0 kein Unwetter, 12 massives Unwetter)</li>
  1763. <li><b>Warn_</b><i>0</i><b>_Hail</b> - Hagelwarnung (1|0)</li>
  1764. <li><b>Warn_</b><i>0</i><b>_Type</b> - Art des Unwetters</li>
  1765. <li><b>Warn_</b><i>0</i><b>_Type_Str</b> - Art des Unwetters (text)</li>
  1766. <ul>
  1767. <li><b>1</b> - unbekannt</li>
  1768. <li><b>2</b> - Sturm/Orkan</li>
  1769. <li><b>3</b> - Schneefall</li>
  1770. <li><b>4</b> - Regen</li>
  1771. <li><b>5</b> - Extremfrost</li>
  1772. <li><b>6</b> - Waldbrandgefahr</li>
  1773. <li><b>7</b> - Gewitter</li>
  1774. <li><b>8</b> - Glätte</li>
  1775. <li><b>9</b> - Hitze</li>
  1776. <li><b>10</b> - Glatteisregen</li>
  1777. <li><b>11</b> - Bodenfrost</li>
  1778. </ul>
  1779. <li><b>Warn_</b><i>0</i><b>_uwzLevel</b> - Unwetterwarnstufe (0-5)</li>
  1780. <li><b>Warn_</b><i>0</i><b>_uwzLevel_Str</b> - Unwetterwarnstufe (text)</li>
  1781. <li><b>Warn_</b><i>0</i><b>_levelName</b> - Level Warn Name</li>
  1782. <li><b>Warn_</b><i>0</i><b>_ShortText</b> - Kurzbeschreibung der Warnung</li>
  1783. <li><b>Warn_</b><i>0</i><b>_LongText</b> - Ausführliche Unwetterbeschreibung</li>
  1784. <li><b>Warn_</b><i>0</i><b>_IconURL</b> - Kumulierte URL um Warnungs-Icon von <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a> anzuzeigen</li>
  1785. </ul>
  1786. <br>
  1787. <a name="UWZweblinks"></a>
  1788. <b>Weblinks</b>
  1789. <ul>
  1790. <br>
  1791. &Uuml;ber die Funktionen <code>UWZAsHtml, UWZAsHtmlLite, UWZAsHtmlFP, UWZAsHtmlKarteLand, UWZAsHtmlMovie</code> wird HTML-Code zur Warnanzeige und Wetterfilme über weblinks erzeugt.
  1792. <br><br><br>
  1793. Beispiele:
  1794. <br>
  1795. <li><code>define UnwetterDetailiert weblink htmlCode {UWZAsHtml("Unwetterzentrale")}</code></li>
  1796. <br>
  1797. <li><code>define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}</code></li>
  1798. <br>
  1799. <li><code>define UnwetterFloorplan weblink htmlCode {UWZAsHtmlFP("Unwetterzentrale")}</code></li>
  1800. <br>
  1801. <li><code>define UnwetterKarteLand weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","Bayern")}</code></li>
  1802. <ul>
  1803. <li>Der zweite Parameter kann einer der folgenden sein:
  1804. <ul>
  1805. <li>europa</li>
  1806. <br/>
  1807. <li>deutschland</li>
  1808. <li>deutschland-small</li>
  1809. <li>niedersachsen</li>
  1810. <li>bremen</li>
  1811. <li>bayern</li>
  1812. <li>schleswig-holstein</li>
  1813. <li>hamburg</li>
  1814. <li>mecklenburg-vorpommern</li>
  1815. <li>sachsen</li>
  1816. <li>sachsen-anhalt</li>
  1817. <li>nordrhein-westfalen</li>
  1818. <li>thueringen</li>
  1819. <li>rheinland-pfalz</li>
  1820. <li>saarland</li>
  1821. <li>baden-wuerttemberg</li>
  1822. <li>hessen</li>
  1823. <li>brandenburg</li>
  1824. <li>berlin</li>
  1825. <br/>
  1826. <li>oesterreich</li>
  1827. <li>burgenland</li>
  1828. <li>kaernten</li>
  1829. <li>niederoesterreich</li>
  1830. <li>oberoesterreich</li>
  1831. <li>salzburg</li>
  1832. <li>steiermark</li>
  1833. <li>tirol</li>
  1834. <li>vorarlberg</li>
  1835. <li>wien</li>
  1836. <br/>
  1837. <li>schweiz</li>
  1838. <li>aargau</li>
  1839. <li>appenzell_ausserrhoden</li>
  1840. <li>appenzell_innerrhoden</li>
  1841. <li>basel_landschaft</li>
  1842. <li>basel_stadt</li>
  1843. <li>bern</li>
  1844. <li>fribourg</li>
  1845. <li>geneve</li>
  1846. <li>glarus</li>
  1847. <li>graubuenden</li>
  1848. <li>jura</li>
  1849. <li>luzern</li>
  1850. <li>neuchatel</li>
  1851. <li>nidwalden</li>
  1852. <li>obwalden</li>
  1853. <li>schaffhausen</li>
  1854. <li>schwyz</li>
  1855. <li>solothurn</li>
  1856. <li>stgallen</li>
  1857. <li>ticino</li>
  1858. <li>thurgau</li>
  1859. <li>uri</li>
  1860. <li>waadt</li>
  1861. <li>wallis</li>
  1862. <li>zug</li>
  1863. <li>zuerich</li>
  1864. <br/>
  1865. <li>liechtenstein</li>
  1866. <br/>
  1867. <li>belgique</li>
  1868. <br/>
  1869. <li>denmark</li>
  1870. <br/>
  1871. <li>finnland</li>
  1872. <br/>
  1873. <li>france</li>
  1874. <br/>
  1875. <li>letzebuerg</li>
  1876. <br/>
  1877. <li>nederland</li>
  1878. <br/>
  1879. <li>norwegen</li>
  1880. <br/>
  1881. <li>portugal</li>
  1882. <br/>
  1883. <li>sverige</li>
  1884. <br/>
  1885. <li>espana</li>
  1886. <br/>
  1887. <li>unitedkingdom</li>
  1888. <li>eastofengland</li>
  1889. <li>eastmidlands</li>
  1890. <li>london</li>
  1891. <li>northeastengland</li>
  1892. <li>northernireland</li>
  1893. <li>northwestengland</li>
  1894. <li>scotland</li>
  1895. <li>southeastengland</li>
  1896. <li>southwestengland</li>
  1897. <li>wales</li>
  1898. <li>westmidlands</li>
  1899. <li>yorkshireandthehumber</li>
  1900. <br/>
  1901. <li>isobaren1</li>
  1902. <li>isobaren2</li>
  1903. <li>isobaren3</li>
  1904. </ul>
  1905. </li>
  1906. </ul>
  1907. <li><code>define UnwetterKarteMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","niederschlag-wolken-de")}</code></li>
  1908. <ul>
  1909. <li>Der zweite Parameter kann einer der folgenden sein:
  1910. <ul>
  1911. <li>niederschlag-wolken</li>
  1912. <li>stroemung</li>
  1913. <li>temperatur</li>
  1914. <br/>
  1915. <li>niederschlag-wolken-de</li>
  1916. <li>stroemung-de</li>
  1917. <br/>
  1918. <li>niederschlag-wolken-ch</li>
  1919. <li>stroemung-ch</li>
  1920. <br/>
  1921. <li>niederschlag-wolken-at</li>
  1922. <li>stroemung-at</li>
  1923. <br/>
  1924. <li>clouds-precipitation-uk</li>
  1925. <li>currents-uk</li>
  1926. <br/>
  1927. </ul>
  1928. </li>
  1929. </ul>
  1930. <br/><br/>
  1931. </ul>
  1932. <br>
  1933. </ul>
  1934. =end html_DE
  1935. =cut