77_UWZ.pm 83 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331
  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. #
  11. # Storm warnings from unwetterzentrale.de
  12. # inspired by 59_PROPLANTA.pm
  13. #
  14. # Copyright notice
  15. #
  16. # This script is free software; you can redistribute it and/or modify
  17. # it under the terms of the GNU General Public License as published by
  18. # the Free Software Foundation; either version 2 of the License, or
  19. # (at your option) any later version.
  20. #
  21. # The GNU General Public License can be found at
  22. # http://www.gnu.org/copyleft/gpl.html.
  23. # A copy is found in the text file GPL.txt and important notices to the license
  24. # from the author is found in LICENSE.txt distributed with these scripts.
  25. #
  26. # This script is distributed in the hope that it will be useful,
  27. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. # GNU General Public License for more details.
  30. #
  31. # This copyright notice MUST APPEAR in all copies of the script!
  32. #
  33. #
  34. #
  35. # $Id: 77_UWZ.pm 15215 2017-10-09 09:01:41Z CoolTux $
  36. #
  37. ####################################################################################################
  38. # also a thanks goes to hexenmeister
  39. ##############################################
  40. package main;
  41. use strict;
  42. use feature qw/say switch/;
  43. use warnings;
  44. no if $] >= 5.017011, warnings => 'experimental::lexical_subs','experimental::smartmatch';
  45. my $missingModul;
  46. eval "use LWP::UserAgent;1" or $missingModul .= "LWP::UserAgent ";
  47. eval "use LWP::Simple;1" or $missingModul .= "LWP::Simple ";
  48. eval "use HTTP::Request;1" or $missingModul .= "HTTP::Request ";
  49. eval "use HTML::Parser;1" or $missingModul .= "HTML::Parser ";
  50. eval "use JSON;1" or $missingModul .= "JSON ";
  51. eval "use Encode::Guess;1" or $missingModul .= "Encode::Guess ";
  52. eval "use Text::Iconv;1" or $missingModul .= "Text::Iconv ";
  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 = "1.8.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 $converter = Text::Iconv->new("windows-1252","UTF-8");
  608. my $uwz_warnings = JSON->new->ascii->decode($response);
  609. my $enc = guess_encoding($uwz_warnings);
  610. my $uwz_warncount = scalar(@{ $uwz_warnings->{'results'} });
  611. UWZ_Log $hash, 4, "There are ".$uwz_warncount." warnings active";
  612. my $sortby = AttrVal( $name, 'sort_readings_by',"" );
  613. my @sorted;
  614. if ( $sortby eq "creation" ) {
  615. UWZ_Log $hash, 4, "Sorting by creation";
  616. @sorted = sort { $b->{payload}{creation} <=> $a->{payload}{creation} } @{ $uwz_warnings->{'results'} };
  617. } elsif ( $sortby ne "severity" ) {
  618. UWZ_Log $hash, 4, "Sorting by dtgStart";
  619. @sorted = sort { $a->{dtgStart} <=> $b->{dtgStart} } @{ $uwz_warnings->{'results'} };
  620. } else {
  621. UWZ_Log $hash, 4, "Sorting by severity";
  622. @sorted = sort { $a->{severity} <=> $b->{severity} } @{ $uwz_warnings->{'results'} };
  623. }
  624. my $message;
  625. my $i=0;
  626. my %typenames = ( "1" => "unknown", # <===== FIX HERE
  627. "2" => "sturm",
  628. "3" => "schnee",
  629. "4" => "regen",
  630. "5" => "temperatur",
  631. "6" => "waldbrand",
  632. "7" => "gewitter",
  633. "8" => "strassenglaette",
  634. "9" => "temperatur", # 9 = hitzewarnung
  635. "10" => "glatteisregen",
  636. "11" => "temperatur" ); # 11 = bodenfrost
  637. my %typenames_de_str= ( "1" => "unknown", # <===== FIX HERE
  638. "2" => "Sturm",
  639. "3" => "Schnee",
  640. "4" => "Regen",
  641. "5" => "Temperatur",
  642. "6" => "Waldbrand",
  643. "7" => "Gewitter",
  644. "8" => "Strassenglaette",
  645. "9" => "Hitze", # 9 = hitzewarnung
  646. "10" => "Glatteisregen",
  647. "11" => "Bodenfrost" ); # 11 = bodenfrost
  648. my %typenames_en_str= ( "1" => "unknown", # <===== FIX HERE
  649. "2" => "storm",
  650. "3" => "snow",
  651. "4" => "rain",
  652. "5" => "temperatur",
  653. "6" => "forest fire",
  654. "7" => "thunderstorms",
  655. "8" => "slippery road",
  656. "9" => "heat", # 9 = hitzewarnung
  657. "10" => "black ice rain",
  658. "11" => "soil frost" ); # 11 = bodenfrost
  659. my %severitycolor = ( "0" => "green",
  660. "1" => "unknown", # <===== FIX HERE
  661. "2" => "unknown", # <===== FIX HERE
  662. "3" => "unknown", # <===== FIX HERE
  663. "4" => "orange",
  664. "5" => "unknown", # <===== FIX HERE
  665. "6" => "unknown", # <===== FIX HERE
  666. "7" => "orange",
  667. "8" => "gelb",
  668. "9" => "gelb", # <===== FIX HERE
  669. "10" => "orange",
  670. "11" => "rot",
  671. "12" => "violett" );
  672. my @uwzmaxlevel;
  673. foreach my $single_warning (@sorted) {
  674. push @uwzmaxlevel, UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'});
  675. UWZ_Log $hash, 4, "Warn_".$i."_EventID: ".$single_warning->{'payload'}{'id'};
  676. $message .= "Warn_".$i."_EventID|".$single_warning->{'payload'}{'id'}."|";
  677. my $chopcreation = substr($single_warning->{'payload'}{'creation'},0,10);
  678. $chopcreation = $chopcreation;
  679. UWZ_Log $hash, 4, "Warn_".$i."_Creation: ".$chopcreation;
  680. $message .= "Warn_".$i."_Creation|".$chopcreation."|";
  681. UWZ_Log $hash, 4, "Warn_".$i."_Type: ".$single_warning->{'type'};
  682. $message .= "Warn_".$i."_Type|".$single_warning->{'type'}."|";
  683. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel: ".UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'});
  684. $message .= "Warn_".$i."_uwzLevel|".UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'})."|";
  685. UWZ_Log $hash, 4, "Warn_".$i."_Severity: ".$single_warning->{'severity'};
  686. $message .= "Warn_".$i."_Severity|".$single_warning->{'severity'}."|";
  687. UWZ_Log $hash, 4, "Warn_".$i."_Start: ".$single_warning->{'dtgStart'};
  688. $message .= "Warn_".$i."_Start|".$single_warning->{'dtgStart'}."|";
  689. UWZ_Log $hash, 4, "Warn_".$i."_End: ".$single_warning->{'dtgEnd'};
  690. $message .= "Warn_".$i."_End|".$single_warning->{'dtgEnd'}."|";
  691. ## Begin of redundant Reading
  692. if ( $UWZ_humanreadable eq 1 ) {
  693. UWZ_Log $hash, 4, "Warn_".$i."_Start_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'}));
  694. $message .= "Warn_".$i."_Start_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgStart'}))."|";
  695. UWZ_Log $hash, 4, "Warn_".$i."_Start_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgStart'}));
  696. $message .= "Warn_".$i."_Start_Time|".strftime("%H:%M", localtime($single_warning->{'dtgStart'}))."|";
  697. UWZ_Log $hash, 4, "Warn_".$i."_End_Date: ".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'}));
  698. $message .= "Warn_".$i."_End_Date|".strftime("%d.%m.%Y", localtime($single_warning->{'dtgEnd'}))."|";
  699. UWZ_Log $hash, 4, "Warn_".$i."_End_Time: ".strftime("%H:%M", localtime($single_warning->{'dtgEnd'}));
  700. $message .= "Warn_".$i."_End_Time|".strftime("%H:%M", localtime($single_warning->{'dtgEnd'}))."|";
  701. UWZ_Log $hash, 4, "Warn_".$i."_Creation_Date: ".strftime("%d.%m.%Y", localtime($chopcreation));
  702. $message .= "Warn_".$i."_Creation_Date|".strftime("%d.%m.%Y", localtime($chopcreation))."|";
  703. UWZ_Log $hash, 4, "Warn_".$i."_Creation_Time: ".strftime("%H:%M", localtime($chopcreation));
  704. $message .= "Warn_".$i."_Creation_Time|".strftime("%H:%M", localtime($chopcreation))."|";
  705. # Begin Language by AttrVal
  706. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  707. UWZ_Log $hash, 4, "Warn_".$i."_Type_Str: ".$typenames_de_str{ $single_warning->{'type'} };
  708. $message .= "Warn_".$i."_Type_Str|".$typenames_de_str{ $single_warning->{'type'} }."|";
  709. my %uwzlevelname = ( "0" => "Stufe Grün (keine Warnung)",
  710. "1" => "Stufe Dunkelgrün (Wetterhinweise)",
  711. "2" => "Stufe Gelb (Vorwarnung für Unwetterwarnung)",
  712. "3" => "Warnstufe Orange (Unwetterwarnung)",
  713. "4" => "Warnstufe Rot (Unwetterwarnung)",
  714. "5" => "Warnstufe Violett (Unwetterwarnung)");
  715. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel_Str: ".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) };
  716. $message .= "Warn_".$i."_uwzLevel_Str|".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) }."|";
  717. } else {
  718. UWZ_Log $hash, 4, "Warn_".$i."_Type_Str: ".$typenames_en_str{ $single_warning->{'type'} };
  719. $message .= "Warn_".$i."_Type_Str|".$typenames_en_str{ $single_warning->{'type'} }."|";
  720. my %uwzlevelname = ( "0" => "level green (no warnings)",
  721. "1" => "level dark green (weather notice)",
  722. "2" => "level yellow (severe weather watch)",
  723. "3" => "Alert level Orange",
  724. "4" => "Alert level Red",
  725. "5" => "Alert level Violet");
  726. UWZ_Log $hash, 4, "Warn_".$i."_uwzLevel_Str: ".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) };
  727. $message .= "Warn_".$i."_uwzLevel_Str|".$uwzlevelname{ UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'}) }."|";
  728. }
  729. }
  730. ## End of redundant Reading
  731. UWZ_Log $hash, 4, "Warn_".$i."_levelName: ".$single_warning->{'payload'}{'levelName'};
  732. $message .= "Warn_".$i."_levelName|".$single_warning->{'payload'}{'levelName'}."|";
  733. UWZ_Log $hash, 4, "Warn_".$i."_AltitudeMin: ".$enc->decode($single_warning->{'payload'}{'altMin'});
  734. $message .= "Warn_".$i."_AltitudeMin|".$converter->convert($single_warning->{'payload'}{'altMin'})."|";
  735. UWZ_Log $hash, 4, "Warn_".$i."_AltitudeMax: ".$enc->decode($single_warning->{'payload'}{'altMax'});
  736. $message .= "Warn_".$i."_AltitudeMax|".$converter->convert($single_warning->{'payload'}{'altMax'})."|";
  737. my $uclang = "EN";
  738. if (AttrVal( $name, 'lang',undef) ) {
  739. $uclang = uc AttrVal( $name, 'lang','');
  740. } else {
  741. # Begin Language by AttrVal
  742. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  743. $uclang = "DE";
  744. } else {
  745. $uclang = "EN";
  746. }
  747. }
  748. UWZ_Log $hash, 4, "Warn_".$i."_LongText: ".$enc->decode($single_warning->{'payload'}{'translationsLongText'}{$uclang});
  749. $message .= "Warn_".$i."_LongText|".$converter->convert($single_warning->{'payload'}{'translationsLongText'}{$uclang})."|";
  750. UWZ_Log $hash, 4, "Warn_".$i."_ShortText: ".$enc->decode($single_warning->{'payload'}{'translationsShortText'}{$uclang});
  751. $message .= "Warn_".$i."_ShortText|".$converter->convert($single_warning->{'payload'}{'translationsShortText'}{$uclang})."|";
  752. ###
  753. if (AttrVal( $name, 'localiconbase',undef) ) {
  754. UWZ_Log $hash, 4, "Warn_".$i."_IconURL: ".AttrVal( $name, 'localiconbase',undef).$typenames{ $single_warning->{'type'} }."-".$single_warning->{'severity'}.".png";
  755. $message .= "Warn_".$i."_IconURL|".AttrVal( $name, 'localiconbase',undef).$typenames{ $single_warning->{'type'} }."-".UWZ_GetSeverityColor($hash, UWZ_GetUWZLevel($hash,$single_warning->{'payload'}{'levelName'} )).".png|";
  756. } else {
  757. UWZ_Log $hash, 4, "Warn_".$i."_IconURL: http://www.unwetterzentrale.de/images/icons/".$typenames{ $single_warning->{'type'} }."-".$single_warning->{'severity'}.".gif";
  758. $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|";
  759. }
  760. ###
  761. ## Hagel start
  762. my $hagelcount = 0;
  763. # Begin Language by AttrVal
  764. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  765. $hagelcount = my @hagelmatch = $single_warning->{'payload'}{'translationsLongText'}{'DE'} =~ /Hagel/g;
  766. } else {
  767. $hagelcount = my @hagelmatch = $single_warning->{'payload'}{'translationsLongText'}{'EN'} =~ /Hail/g;
  768. }
  769. # end language by AttrVal
  770. if ( $hagelcount ne 0 ) {
  771. UWZ_Log $hash, 4, "Warn_".$i."_Hail: 1";
  772. $message .= "Warn_".$i."_Hail|1|";
  773. } else {
  774. UWZ_Log $hash, 4, "Warn_".$i."_Hail: 0";
  775. $message .= "Warn_".$i."_Hail|0|";
  776. }
  777. ## Hagel end
  778. $i++;
  779. }
  780. my $max=0;
  781. for (@uwzmaxlevel) {
  782. $max = $_ if !$max || $_ > $max
  783. };
  784. $message .= "WarnUWZLevel|";
  785. $message .= $max."|";
  786. UWZ_Log $hash, 4, "WarnUWZLevel_Color: ".UWZ_GetSeverityColor($hash, $max);
  787. $message .= "WarnUWZLevel_Color|".UWZ_GetSeverityColor($hash, $max)."|";
  788. ## Begin of redundant Reading
  789. if ( $UWZ_humanreadable eq 1 ) {
  790. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  791. my %uwzlevelname = ( "0" => "Stufe Grün (keine Warnung)",
  792. "1" => "Stufe Dunkelgrün (Wetterhinweise)",
  793. "2" => "Stufe Gelb (Vorwarnung für Unwetterwarnung)",
  794. "3" => "Warnstufe Orange (Unwetterwarnung)",
  795. "4" => "Warnstufe Rot (Unwetterwarnung)",
  796. "5" => "Warnstufe Violett (Unwetterwarnung)");
  797. UWZ_Log $hash, 4, "WarnUWZLevel_Str: ".$uwzlevelname{ $max };
  798. $message .= "WarnUWZLevel_Str|".$uwzlevelname{ $max }."|";
  799. } else {
  800. my %uwzlevelname = ( "0" => "level green (no warnings)",
  801. "1" => "level dark green (weather notice)",
  802. "2" => "level yellow (severe weather watch)",
  803. "3" => "Alert level Orange",
  804. "4" => "Alert level Red",
  805. "5" => "Alert level Violet");
  806. UWZ_Log $hash, 4, "WarnUWZLevel_Str: ".$uwzlevelname{ $max };
  807. $message .= "WarnUWZLevel_Str|".$uwzlevelname{ $max }."|";
  808. }
  809. }
  810. $message .= "durationFetchReadings|";
  811. $message .= sprintf "%.2f", time() - $readingStartTime;
  812. UWZ_Log $hash, 3, "Done fetching data";
  813. UWZ_Log $hash, 4, "Will return : "."$name|$message|WarnCount|$uwz_warncount" ;
  814. return "$name|$message|WarnCount|$uwz_warncount" ;
  815. }
  816. #####################################
  817. sub UWZAsHtml($;$) {
  818. my ($name,$items) = @_;
  819. my $ret = '';
  820. my $hash = $defs{$name};
  821. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  822. my $htmltitle = AttrVal($name, "htmltitle", "");
  823. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  824. my $attr;
  825. if (AttrVal($name, "htmlattr", "none") ne "none") {
  826. $attr = AttrVal($name, "htmlattr", "");
  827. } else {
  828. $attr = 'width="100%"';
  829. }
  830. if (ReadingsVal($name, "WarnCount", 0) != 0 ) {
  831. $ret .= '<table><tr><td>';
  832. $ret .= '<table class="block" '.$attr.'><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  833. if ($htmlsequence eq "descending") {
  834. for ( my $i=ReadingsVal($name, "WarnCount", -1)-1; $i>=0; $i--){
  835. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  836. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  837. $ret .= ReadingsVal($name, "Warn_".$i."_LongText", "").'<br><br>';
  838. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  839. # language by AttrVal
  840. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  841. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  842. } else {
  843. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  844. }
  845. # end language by AttrVal
  846. $ret .= '</tr></table>';
  847. $ret .= '</td></tr>';
  848. }
  849. } else {
  850. ###
  851. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", 0); $i++){
  852. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  853. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  854. $ret .= ReadingsVal($name, "Warn_".$i."_LongText", "").'<br><br>';
  855. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  856. # language by AttrVal
  857. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  858. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  859. } else {
  860. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  861. }
  862. # end language by AttrVal
  863. $ret .= '</tr></table>';
  864. $ret .= '</td></tr>';
  865. }
  866. }
  867. ###
  868. $ret .= '</table>';
  869. $ret .= '</td></tr>';
  870. $ret .= '</table>';
  871. } else {
  872. $ret .= '<table><tr><td>';
  873. $ret .= '<table class="block wide" width="600px"><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  874. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;">';
  875. # language by AttrVal
  876. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  877. $ret .='<b>Keine Warnungen</b>';
  878. } else {
  879. $ret .='<b>No Warnings</b>';
  880. }
  881. # end language by AttrVal
  882. $ret .= '</td></tr>';
  883. $ret .= '</table>';
  884. $ret .= '</td></tr>';
  885. $ret .= '</table>';
  886. }
  887. return $ret;
  888. }
  889. #####################################
  890. sub UWZAsHtmlLite($;$) {
  891. my ($name,$items) = @_;
  892. my $ret = '';
  893. my $hash = $defs{$name};
  894. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  895. my $htmltitle = AttrVal($name, "htmltitle", "");
  896. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  897. my $attr;
  898. if (AttrVal($name, "htmlattr", "none") ne "none") {
  899. $attr = AttrVal($name, "htmlattr", "");
  900. } else {
  901. $attr = 'width="100%"';
  902. }
  903. if (ReadingsVal($name, "WarnCount", "") != 0 ) {
  904. $ret .= '<table><tr><td>';
  905. $ret .= '<table class="block" '.$attr.'><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  906. if ($htmlsequence eq "descending") {
  907. for ( my $i=ReadingsVal($name, "WarnCount", "")-1; $i>=0; $i--){
  908. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  909. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  910. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  911. # language by AttrVal
  912. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  913. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  914. } else {
  915. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  916. }
  917. # end language by AttrVal
  918. $ret .= '</tr></table>';
  919. $ret .= '</td></tr>';
  920. }
  921. } else {
  922. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", ""); $i++){
  923. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;"><img src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  924. $ret .= '<td class="uwzValue"><b>'.ReadingsVal($name, "Warn_".$i."_ShortText", "").'</b><br><br>';
  925. $ret .= '<table '.$attr.'><tr><th></th><th></th></tr><tr><td><b>Start:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_Start", "")).'</td>';
  926. # language by AttrVal
  927. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  928. $ret .= '<td><b>Ende:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  929. } else {
  930. $ret .= '<td><b>End:</b></td><td>'.localtime(ReadingsVal($name, "Warn_".$i."_End", "")).'</td>';
  931. }
  932. # end language by AttrVal
  933. $ret .= '</tr></table>';
  934. $ret .= '</td></tr>';
  935. }
  936. }
  937. $ret .= '</table>';
  938. $ret .= '</td></tr>';
  939. $ret .= '</table>';
  940. } else {
  941. $ret .= '<table><tr><td>';
  942. $ret .= '<table class="block wide" width="600px"><tr><th class="'.$htmltitleclass.'" colspan="2">'.$htmltitle.'</th></tr>';
  943. $ret .= '<tr><td class="uwzIcon" style="vertical-align:top;">';
  944. # language by AttrVal
  945. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  946. $ret .='<b>Keine Warnungen</b>';
  947. } else {
  948. $ret .='<b>No Warnings</b>';
  949. }
  950. # end language by AttrVal
  951. $ret .= '</td></tr>';
  952. $ret .= '</table>';
  953. $ret .= '</td></tr>';
  954. $ret .= '</table>';
  955. }
  956. return $ret;
  957. }
  958. #####################################
  959. sub UWZAsHtmlFP($;$) {
  960. my ($name,$items) = @_;
  961. my $tablewidth = ReadingsVal($name, "WarnCount", "") * 80;
  962. my $htmlsequence = AttrVal($name, "htmlsequence", "none");
  963. my $htmltitle = AttrVal($name, "htmltitle", "");
  964. my $htmltitleclass = AttrVal($name, "htmltitleclass", "");
  965. my $ret = '';
  966. $ret .= '<table class="uwz-fp" style="width:'.$tablewidth.'px"><tr><th class="'.$htmltitleclass.'" colspan="'.ReadingsVal($name, "WarnCount", "none").'">'.$htmltitle.'</th></tr>';
  967. $ret .= "<tr>";
  968. if ($htmlsequence eq "descending") {
  969. for ( my $i=ReadingsVal($name, "WarnCount", "")-1; $i>=0; $i--){
  970. $ret .= '<td class="uwzIcon"><img width="80px" src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  971. }
  972. } else {
  973. for ( my $i=0; $i<ReadingsVal($name, "WarnCount", ""); $i++){
  974. $ret .= '<td class="uwzIcon"><img width="80px" src="'.ReadingsVal($name, "Warn_".$i."_IconURL", "").'"></td>';
  975. }
  976. }
  977. $ret .= "</tr>";
  978. $ret .= '</table>';
  979. return $ret;
  980. }
  981. #####################################
  982. sub UWZAsHtmlMovie($$) {
  983. my ($name,$land) = @_;
  984. my $url = UWZ_Map2Movie($name,$land);
  985. my $hash = $defs{$name};
  986. my $ret = '<table><tr><td>';
  987. $ret .= '<table class="block wide">';
  988. $ret .= '<tr class="even"><td>';
  989. if(defined($url)) {
  990. $ret .= '<video controls="controls">';
  991. $ret .= '<source src="'.$url.'" type="video/mp4">';
  992. $ret .= '</video>';
  993. } else {
  994. # language by AttrVal
  995. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  996. $ret .= 'unbekannte Landbezeichnung';
  997. } else {
  998. $ret .='unknown movie setting';
  999. }
  1000. # end language by AttrVal
  1001. }
  1002. $ret .= '</td></tr></table></td></tr>';
  1003. $ret .= '</table>';
  1004. return $ret;
  1005. }
  1006. #####################################
  1007. sub UWZAsHtmlKarteLand($$) {
  1008. my ($name,$land) = @_;
  1009. my $url = UWZ_Map2Image($name,$land);
  1010. my $hash = $defs{$name};
  1011. my $ret = '<table><tr><td>';
  1012. $ret .= '<table class="block wide">';
  1013. $ret .= '<tr class="even"><td>';
  1014. if(defined($url)) {
  1015. $ret .= '<img src="'.$url.'">';
  1016. } else {
  1017. # language by AttrVal
  1018. if ( $hash->{CountryCode} ~~ [ 'DE', 'AT', 'CH' ] ) {
  1019. $ret .= 'unbekannte Landbezeichnung';
  1020. } else {
  1021. $ret .='unknown map setting';
  1022. }
  1023. # end language by AttrVal
  1024. }
  1025. $ret .= '</td></tr></table></td></tr>';
  1026. $ret .= '</table>';
  1027. return $ret;
  1028. }
  1029. #####################################
  1030. sub UWZ_GetSeverityColor($$) {
  1031. my ($name,$uwzlevel) = @_;
  1032. my $alertcolor = "";
  1033. my %UWZSeverity = ( "0" => "gruen",
  1034. "1" => "orange",
  1035. "2" => "gelb",
  1036. "3" => "orange",
  1037. "4" => "rot",
  1038. "5" => "violett");
  1039. return $UWZSeverity{$uwzlevel};
  1040. }
  1041. #####################################
  1042. sub UWZ_GetUWZLevel($$) {
  1043. my ($name,$warnname) = @_;
  1044. my @alert = split(/_/,$warnname);
  1045. if ( $alert[0] eq "notice" ) {
  1046. return "1";
  1047. } elsif ( $alert[1] eq "forewarn" ) {
  1048. return "2";
  1049. } else {
  1050. my %UWZSeverity = ( "green" => "0",
  1051. "yellow" => "2",
  1052. "orange" => "3",
  1053. "red" => "4",
  1054. "violet" => "5");
  1055. return $UWZSeverity{$alert[2]};
  1056. }
  1057. }
  1058. #####################################
  1059. sub UWZ_IntervalAtWarnLevel($) {
  1060. my $hash = shift;
  1061. my $name = $hash->{NAME};
  1062. my $warnLevel = ReadingsVal($name,'WarnUWZLevel',0);
  1063. my @valuestring = split( ',', AttrVal($name,'intervalAtWarnLevel','') );
  1064. my %warnLevelInterval;
  1065. readingsSingleUpdate($hash,'currentIntervalMode','warn',0);
  1066. foreach( @valuestring ) {
  1067. my @values = split( '=' , $_ );
  1068. $warnLevelInterval{$values[0]} = $values[1];
  1069. }
  1070. if( defined($warnLevelInterval{$warnLevel}) and $hash->{INTERVALWARN} != $warnLevelInterval{$warnLevel} ) {
  1071. $hash->{INTERVALWARN} = $warnLevelInterval{$warnLevel};
  1072. RemoveInternalTimer( $hash );
  1073. InternalTimer(gettimeofday() + $hash->{INTERVALWARN}, "UWZ_Start", $hash, 1 );
  1074. UWZ_Log $hash, 4, "restart internal timer with interval $hash->{INTERVALWARN}";
  1075. } else {
  1076. RemoveInternalTimer( $hash );
  1077. InternalTimer(gettimeofday() + $hash->{INTERVALWARN}, "UWZ_Start", $hash, 1 );
  1078. UWZ_Log $hash, 4, "restart internal timer with interval $hash->{INTERVALWARN}";
  1079. }
  1080. }
  1081. #####################################
  1082. ##
  1083. ## UWZ Helper Functions
  1084. ##
  1085. #####################################
  1086. sub UWZSearchLatLon($$) {
  1087. my ($name,$loc) = @_;
  1088. my $url = "http://alertspro.geoservice.meteogroup.de/weatherpro/SearchFeed.php?search=".$loc;
  1089. my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
  1090. my $request = HTTP::Request->new( GET => $url );
  1091. my $response = $agent->request($request);
  1092. my $err_log = "Can't get $url -- " . $response->status_line unless( $response->is_success );
  1093. if ( $err_log ne "" ) {
  1094. print "Error|Error " . $response->status_line;
  1095. }
  1096. use XML::Simple qw(:strict);
  1097. use Data::Dumper;
  1098. use Encode qw(decode encode);
  1099. my $uwzxmlparser = XML::Simple->new();
  1100. #my $xmlres = $parser->XMLin(
  1101. my $search = $uwzxmlparser->XMLin($response->content, KeyAttr => { city => 'id' }, ForceArray => [ 'city' ]);
  1102. my $ret = '<html><table><tr><td>';
  1103. $ret .= '<table class="block wide">';
  1104. $ret .= '<tr class="even">';
  1105. $ret .= "<td><b>city</b></td>";
  1106. $ret .= "<td><b>country</b></td>";
  1107. $ret .= "<td><b>latitude</b></td>";
  1108. $ret .= "<td><b>longitude</b></td>";
  1109. $ret .= '</tr>';
  1110. foreach my $locres ($search->{cities}->{city})
  1111. {
  1112. my $linecount=1;
  1113. while ( my ($key, $value) = each(%$locres) ) {
  1114. if ( $linecount % 2 == 0 ) {
  1115. $ret .= '<tr class="even">';
  1116. } else {
  1117. $ret .= '<tr class="odd">';
  1118. }
  1119. $ret .= "<td>".encode('utf-8',$value->{'name'})."</td>";
  1120. $ret .= "<td>$value->{'country-name'}</td>";
  1121. $ret .= "<td>$value->{'latitude'}</td>";
  1122. $ret .= "<td>$value->{'longitude'}</td>";
  1123. my @headerHost = grep /Host/, @FW_httpheader;
  1124. $headerHost[0] =~ s/Host: //g;
  1125. my $aHref="<a href=\"http://".$headerHost[0]."/fhem?cmd=get+".$name."+AreaID+".$value->{'latitude'}.",".$value->{'longitude'}."\">Get AreaID</a>";
  1126. $ret .= "<td>".$aHref."</td>";
  1127. $ret .= '</tr>';
  1128. $linecount++;
  1129. }
  1130. }
  1131. $ret .= '</table></td></tr>';
  1132. $ret .= '</table></html>';
  1133. return $ret;
  1134. }
  1135. #####################################
  1136. sub UWZSearchAreaID($$) {
  1137. my ($lat,$lon) = @_;
  1138. my $url = "http://feed.alertspro.meteogroup.com/AlertsPro/AlertsProPollService.php?method=lookupCoord&lat=".$lat."&lon=".$lon;
  1139. my $agent = LWP::UserAgent->new( env_proxy => 1, keep_alive => 1, protocols_allowed => ['http'], timeout => 10 );
  1140. my $request = HTTP::Request->new( GET => $url );
  1141. my $response = $agent->request($request);
  1142. my $err_log = "Can't get $url -- " . $response->status_line unless( $response->is_success );
  1143. if ( $err_log ne "" ) {
  1144. print "Error|Error " . $response->status_line;
  1145. }
  1146. use JSON;
  1147. my @perl_scalar = @{JSON->new->utf8->decode($response->content)};
  1148. my $AreaType = $perl_scalar[0]->{'AREA_TYPE'};
  1149. my $CC = substr $perl_scalar[0]->{'AREA_ID'}, 3, 2;
  1150. my $AreaID = substr $perl_scalar[0]->{'AREA_ID'}, 5, 5;
  1151. if ( $AreaType eq "UWZ" ) {
  1152. my $ret = '<html>Please use the following statement to define Unwetterzentrale for your location:<br /><br />';
  1153. $ret .= '<table width=100%><tr><td>';
  1154. $ret .= '<table class="block wide">';
  1155. $ret .= '<tr class="even">';
  1156. $ret .= "<td height=100><center><b>define Unwetterzentrale UWZ $CC $AreaID 3600</b></center></td>";
  1157. $ret .= '</tr>';
  1158. $ret .= '</table>';
  1159. $ret .= '</td></tr></table>';
  1160. $ret .= '<br />';
  1161. $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 />';
  1162. $ret .= '<table width=100%><tr><td>';
  1163. $ret .= '<table class="block wide">';
  1164. $ret .= '<tr class="even">';
  1165. $ret .= "<td height=100><center>define UWZ_Map_Europe weblink htmlCode { UWZAsHtmlKarteLand('Unwetterzentrale','europa') }</center></td>";
  1166. $ret .= '</tr>';
  1167. $ret .= '</table>';
  1168. $ret .= '</td></tr></table>';
  1169. $ret .= '</html>';
  1170. return $ret;
  1171. } else {
  1172. return "Sorry, nothing found or not implemented";
  1173. }
  1174. }
  1175. #####################################
  1176. 1;
  1177. =pod
  1178. =item device
  1179. =item summary extracts thunderstorm warnings from unwetterzentrale.de
  1180. =item summary_DE extrahiert Unwetterwarnungen von unwetterzentrale.de
  1181. =begin html
  1182. <a name="UWZ"></a>
  1183. <h3>UWZ</h3>
  1184. <ul>
  1185. <a name="UWZdefine"></a>
  1186. This modul extracts thunderstorm warnings from <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a>.
  1187. <br/>
  1188. Therefore the same interface is used as the Android App <a href="http://www.alertspro.com">Alerts Pro</a> does.
  1189. A maximum of 10 thunderstorm warnings will be served.
  1190. Additional the module provides a few functions to create HTML-Templates which can be used with weblink.
  1191. <br>
  1192. <i>The following Perl-Modules are used within this module: HTTP::Request, LWP::UserAgent, JSON, Encode::Guess, Text::Iconv und HTML::Parse</i>.
  1193. <br/><br/>
  1194. <b>Define</b>
  1195. <ul>
  1196. <br>
  1197. <code>define &lt;Name&gt; UWZ [CountryCode] [AreaID] [INTERVAL]</code>
  1198. <br><br><br>
  1199. Example:
  1200. <br>
  1201. <code>
  1202. define Unwetterzentrale UWZ UK 08357 1800<br>
  1203. attr Unwetterzentrale download 1<br>
  1204. attr Unwetterzentrale humanreadable 1<br>
  1205. attr Unwetterzentrale maps eastofengland unitedkingdom<br><br>
  1206. define UnwetterDetails weblink htmlCode {UWZAsHtml("Unwetterzentrale")}<br>
  1207. define UnwetterMapE_UK weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","eastofengland")}<br>
  1208. define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}
  1209. define UnwetterMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","clouds-precipitation-uk")}
  1210. </code>
  1211. <br>&nbsp;
  1212. <li><code>[CountryCode]</code>
  1213. <br>
  1214. Possible values: DE, AT, CH, UK, ...<br/>
  1215. (for other countries than germany use SEARCH for CountryCode to start device in search mode)
  1216. </li><br>
  1217. <li><code>[AreaID]</code>
  1218. <br>
  1219. For Germany you can use the postalcode, other countries use SEARCH for CountryCode to start device in search mode.
  1220. <br>
  1221. </li><br>
  1222. <li><code>[INTERVAL]</code>
  1223. <br>
  1224. 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.
  1225. <br>
  1226. </li><br>
  1227. <br><br><br>
  1228. Example Search-Mode:
  1229. <br>
  1230. <code>
  1231. define Unwetterzentrale UWZ SEARCH<br>
  1232. </code>
  1233. <br>
  1234. now get the AreaID for your location (example shows london):
  1235. <br>
  1236. <code>
  1237. get Unwetterzentrale SearchAreaID London<br>
  1238. </code>
  1239. <br>
  1240. now redefine your device with the outputted CountryCode and AreaID.
  1241. <br>
  1242. <br>&nbsp;
  1243. </ul>
  1244. <br>
  1245. <a name="UWZget"></a>
  1246. <b>Get</b>
  1247. <ul>
  1248. <br>
  1249. <li><code>get &lt;name&gt; soil-frost</code>
  1250. <br>
  1251. give info about current soil frost (active|inactive).
  1252. </li><br>
  1253. <li><code>get &lt;name&gt; extremfrost</code>
  1254. <br>
  1255. give info about current frost (active|inactive).
  1256. </li><br>
  1257. <li><code>get &lt;name&gt; thunderstorm</code>
  1258. <br>
  1259. give info about current thunderstorm (active|inactive).
  1260. </li><br>
  1261. <li><code>get &lt;name&gt; glaze</code>
  1262. <br>
  1263. give info about current glaze (active|inactive).
  1264. </li><br>
  1265. <li><code>get &lt;name&gt; glazed-rain</code>
  1266. <br>
  1267. give info about current freezing rain (active|inactive).
  1268. </li><br>
  1269. <li><code>get &lt;name&gt; hail</code>
  1270. <br>
  1271. give info about current hail (active|inactive).
  1272. </li><br>
  1273. <li><code>get &lt;name&gt; heat</code>
  1274. <br>
  1275. give info about current heat (active|inactive).
  1276. </li><br>
  1277. <li><code>get &lt;name&gt; rain</code>
  1278. <br>
  1279. give info about current rain (active|inactive).
  1280. </li><br>
  1281. <li><code>get &lt;name&gt; snow</code>
  1282. <br>
  1283. give info about current snow (active|inactive).
  1284. </li><br>
  1285. <li><code>get &lt;name&gt; storm</code>
  1286. <br>
  1287. give info about current storm (active|inactive).
  1288. </li><br>
  1289. <li><code>get &lt;name&gt; forest-fire</code>
  1290. <br>
  1291. give info about current forest fire (active|inactive).
  1292. </li><br>
  1293. </ul>
  1294. <br>
  1295. <b>Get (Search-Mode)</b>
  1296. <ul>
  1297. <br>
  1298. <li><code>get &lt;name&gt; SearchAreaID &lt;city&gt;</code>
  1299. <br>
  1300. Get AreaID coresponnding to entered location.
  1301. </li><br>
  1302. </ul>
  1303. <br>
  1304. <a name="UWZset"></a>
  1305. <b>Set</b>
  1306. <ul>
  1307. <br>
  1308. <li><code>set &lt;name&gt; update</code>
  1309. <br>
  1310. Executes an imediate update of thunderstorm warnings.
  1311. </li><br>
  1312. </ul>
  1313. <br>
  1314. <a name="UWZattr"></a>
  1315. <b>Attributes</b>
  1316. <ul>
  1317. <br>
  1318. <li><code>download</code>
  1319. <br>
  1320. Download maps during update (0|1).
  1321. <br>
  1322. </li>
  1323. <li><code>savepath</code>
  1324. <br>
  1325. Define where to store the map png files (default: /tmp/).
  1326. <br>
  1327. </li>
  1328. <li><code>maps</code>
  1329. <br>
  1330. Define the maps to download space seperated. For possible values see <code>UWZAsHtmlKarteLand</code>.
  1331. <br>
  1332. </li>
  1333. <li><code>humanreadable</code>
  1334. <br>
  1335. 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).
  1336. <br>
  1337. </li>
  1338. <li><code>lang</code>
  1339. <br>
  1340. Overwrite requested language for short and long warn text. (de|en|it|fr|es|..).
  1341. <br>
  1342. </li>
  1343. <li><code>sort_readings_by</code>
  1344. <br>
  1345. define how readings will be sortet (start|severity|creation).
  1346. <br>
  1347. </li>
  1348. <li><code>htmlsequence</code>
  1349. <br>
  1350. define warn order of html output (ascending|descending).
  1351. <br>
  1352. </li>
  1353. <li><code>htmltitle</code>
  1354. <br>
  1355. title / header for the html ouput
  1356. <br>
  1357. </li>
  1358. <li><code>htmltitleclass</code>
  1359. <br>
  1360. css-Class of title / header for the html ouput
  1361. <br>
  1362. </li>
  1363. <li><code>localiconbase</code>
  1364. <br>
  1365. define baseurl to host your own thunderstorm warn pics (filetype is png).
  1366. <br>
  1367. </li>
  1368. <li><code>intervalAtWarnLevel</code>
  1369. <br>
  1370. define the interval per warnLevel. Example: 2=1800,3=900,4=300
  1371. <br>
  1372. </li>
  1373. <br>
  1374. </ul>
  1375. <br>
  1376. <a name="UWZreading"></a>
  1377. <b>Readings</b>
  1378. <ul>
  1379. <br>
  1380. <li><b>Warn_</b><i>0|1|2|3...|9</i><b>_...</b> - active warnings</li>
  1381. <li><b>WarnCount</b> - warnings count</li>
  1382. <li><b>WarnUWZLevel</b> - total warn level </li>
  1383. <li><b>WarnUWZLevel_Color</b> - total warn level color</li>
  1384. <li><b>WarnUWZLevel_Str</b> - total warn level string</li>
  1385. <li><b>Warn_</b><i>0</i><b>_AltitudeMin</b> - minimum altitude for warning </li>
  1386. <li><b>Warn_</b><i>0</i><b>_AltitudeMax</b> - maximum altitude for warning </li>
  1387. <li><b>Warn_</b><i>0</i><b>_EventID</b> - warning EventID </li>
  1388. <li><b>Warn_</b><i>0</i><b>_Creation</b> - warning creation </li>
  1389. <li><b>Warn_</b><i>0</i><b>_Creation_Date</b> - warning creation datum </li>
  1390. <li><b>Warn_</b><i>0</i><b>_Creation_Time</b> - warning creation time </li>
  1391. <li><b>currentIntervalMode</b> - default/warn, Interval is read from INTERVAL or INTERVALWARN Internal</li>
  1392. <li><b>Warn_</b><i>0</i><b>_Start</b> - begin of warnperiod</li>
  1393. <li><b>Warn_</b><i>0</i><b>_Start_Date</b> - start date of warnperiod</li>
  1394. <li><b>Warn_</b><i>0</i><b>_Start_Time</b> - start time of warnperiod</li>
  1395. <li><b>Warn_</b><i>0</i><b>_End</b> - end of warnperiod</li>
  1396. <li><b>Warn_</b><i>0</i><b>_End_Date</b> - end date of warnperiod</li>
  1397. <li><b>Warn_</b><i>0</i><b>_End_Time</b> - end time of warnperiod</li>
  1398. <li><b>Warn_</b><i>0</i><b>_Severity</b> - Severity of thunderstorm (0 no thunderstorm, 4, 7, 11, .. heavy thunderstorm)</li>
  1399. <li><b>Warn_</b><i>0</i><b>_Hail</b> - warning contains hail</li>
  1400. <li><b>Warn_</b><i>0</i><b>_Type</b> - kind of thunderstorm</li>
  1401. <li><b>Warn_</b><i>0</i><b>_Type_Str</b> - kind of thunderstorm (text)</li>
  1402. <ul>
  1403. <li><b>1</b> - unknown</li>
  1404. <li><b>2</b> - storm</li>
  1405. <li><b>3</b> - snow</li>
  1406. <li><b>4</b> - rain</li>
  1407. <li><b>5</b> - frost</li>
  1408. <li><b>6</b> - forest fire</li>
  1409. <li><b>7</b> - thunderstorm</li>
  1410. <li><b>8</b> - glaze</li>
  1411. <li><b>9</b> - heat</li>
  1412. <li><b>10</b> - freezing rain</li>
  1413. <li><b>11</b> - soil frost</li>
  1414. </ul>
  1415. <li><b>Warn_</b><i>0</i><b>_uwzLevel</b> - Severity of thunderstorm (0-5)</li>
  1416. <li><b>Warn_</b><i>0</i><b>_uwzLevel_Str</b> - Severity of thunderstorm (text)</li>
  1417. <li><b>Warn_</b><i>0</i><b>_levelName</b> - Level Warn Name</li>
  1418. <li><b>Warn_</b><i>0</i><b>_ShortText</b> - short warn text</li>
  1419. <li><b>Warn_</b><i>0</i><b>_LongText</b> - detailed warn text</li>
  1420. <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>
  1421. </ul>
  1422. <br>
  1423. <a name="UWZweblinks"></a>
  1424. <b>Weblinks</b>
  1425. <ul>
  1426. <br>
  1427. 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.
  1428. <br><br><br>
  1429. Example:
  1430. <br>
  1431. <li><code>define UnwetterDetailiert weblink htmlCode {UWZAsHtml("Unwetterzentrale")}</code></li>
  1432. <br>
  1433. <li><code>define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}</code></li>
  1434. <br>
  1435. <li><code>define UnwetterFloorplan weblink htmlCode {UWZAsHtmlFP("Unwetterzentrale")}</code></li>
  1436. <br>
  1437. <li><code>define UnwetterKarteLand weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","Bayern")}</code></li>
  1438. <ul>
  1439. <li>The second parameter should be one of:
  1440. <ul>
  1441. <li>europa</li>
  1442. <br/>
  1443. <li>deutschland</li>
  1444. <li>deutschland-small</li>
  1445. <li>niedersachsen</li>
  1446. <li>bremen</li>
  1447. <li>bayern</li>
  1448. <li>schleswig-holstein</li>
  1449. <li>hamburg</li>
  1450. <li>mecklenburg-vorpommern</li>
  1451. <li>sachsen</li>
  1452. <li>sachsen-anhalt</li>
  1453. <li>nordrhein-westfalen</li>
  1454. <li>thueringen</li>
  1455. <li>rheinland-pfalz</li>
  1456. <li>saarland</li>
  1457. <li>baden-wuerttemberg</li>
  1458. <li>hessen</li>
  1459. <li>brandenburg</li>
  1460. <li>berlin</li>
  1461. <br/>
  1462. <li>oesterreich</li>
  1463. <li>burgenland</li>
  1464. <li>kaernten</li>
  1465. <li>niederoesterreich</li>
  1466. <li>oberoesterreich</li>
  1467. <li>salzburg</li>
  1468. <li>steiermark</li>
  1469. <li>tirol</li>
  1470. <li>vorarlberg</li>
  1471. <li>wien</li>
  1472. <br/>
  1473. <li>schweiz</li>
  1474. <li>aargau</li>
  1475. <li>appenzell_ausserrhoden</li>
  1476. <li>appenzell_innerrhoden</li>
  1477. <li>basel_landschaft</li>
  1478. <li>basel_stadt</li>
  1479. <li>bern</li>
  1480. <li>fribourg</li>
  1481. <li>geneve</li>
  1482. <li>glarus</li>
  1483. <li>graubuenden</li>
  1484. <li>jura</li>
  1485. <li>luzern</li>
  1486. <li>neuchatel</li>
  1487. <li>nidwalden</li>
  1488. <li>obwalden</li>
  1489. <li>schaffhausen</li>
  1490. <li>schwyz</li>
  1491. <li>solothurn</li>
  1492. <li>stgallen</li>
  1493. <li>ticino</li>
  1494. <li>thurgau</li>
  1495. <li>uri</li>
  1496. <li>waadt</li>
  1497. <li>wallis</li>
  1498. <li>zug</li>
  1499. <li>zuerich</li>
  1500. <br/>
  1501. <li>liechtenstein</li>
  1502. <br/>
  1503. <li>belgique</li>
  1504. <br/>
  1505. <li>denmark</li>
  1506. <br/>
  1507. <li>finnland</li>
  1508. <br/>
  1509. <li>france</li>
  1510. <br/>
  1511. <li>letzebuerg</li>
  1512. <br/>
  1513. <li>nederland</li>
  1514. <br/>
  1515. <li>norwegen</li>
  1516. <br/>
  1517. <li>portugal</li>
  1518. <br/>
  1519. <li>sverige</li>
  1520. <br/>
  1521. <li>espana</li>
  1522. <br/>
  1523. <li>unitedkingdom</li>
  1524. <li>eastofengland</li>
  1525. <li>eastmidlands</li>
  1526. <li>london</li>
  1527. <li>northeastengland</li>
  1528. <li>northernireland</li>
  1529. <li>northwestengland</li>
  1530. <li>scotland</li>
  1531. <li>southeastengland</li>
  1532. <li>southwestengland</li>
  1533. <li>wales</li>
  1534. <li>westmidlands</li>
  1535. <li>yorkshireandthehumber</li>
  1536. <br/>
  1537. <li>isobaren1</li>
  1538. <li>isobaren2</li>
  1539. <li>isobaren3</li>
  1540. </ul>
  1541. </li>
  1542. </ul>
  1543. <li><code>define UnwetterKarteMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","currents")}</code></li>
  1544. <ul>
  1545. <li>The second parameter should be one of:
  1546. <ul>
  1547. <li>niederschlag-wolken</li>
  1548. <li>stroemung</li>
  1549. <li>temperatur</li>
  1550. <br/>
  1551. <li>niederschlag-wolken-de</li>
  1552. <li>stroemung-de</li>
  1553. <br/>
  1554. <li>niederschlag-wolken-ch</li>
  1555. <li>stroemung-ch</li>
  1556. <br/>
  1557. <li>niederschlag-wolken-at</li>
  1558. <li>stroemung-at</li>
  1559. <br/>
  1560. <li>niederschlag-wolken-uk</li>
  1561. <li>stroemung-uk</li>
  1562. <br/>
  1563. </ul>
  1564. </li>
  1565. </ul>
  1566. <br/><br/>
  1567. </ul>
  1568. <br>
  1569. </ul>
  1570. =end html
  1571. =begin html_DE
  1572. <a name="UWZ"></a>
  1573. <h3>UWZ</h3>
  1574. <ul>
  1575. <a name="UWZdefine"></a>
  1576. Das Modul extrahiert Unwetterwarnungen von <a href="http://www.unwetterzentrale.de">www.unwetterzentrale.de</a>.
  1577. <br/>
  1578. Hierfür wird die selbe Schnittstelle verwendet die auch die Android App <a href="http://www.alertspro.com">Alerts Pro</a> nutzt.
  1579. Es werden maximal 10 Standortbezogene Unwetterwarnungen zur Verfügung gestellt.
  1580. Weiterhin verfügt das Modul über HTML-Templates welche als weblink verwendet werden können.
  1581. <br>
  1582. <i>Es nutzt die Perl-Module HTTP::Request, LWP::UserAgent, JSON, Encode::Guess, Text::Iconv und HTML::Parse</i>.
  1583. <br/><br/>
  1584. <b>Define</b>
  1585. <ul>
  1586. <br>
  1587. <code>define &lt;Name&gt; UWZ [L&auml;ndercode] [Postleitzahl] [INTERVAL]</code>
  1588. <br><br><br>
  1589. Beispiel:
  1590. <br>
  1591. <code>define Unwetterzentrale UWZ DE 86405 3600</code>
  1592. <br>&nbsp;
  1593. <li><code>[L&auml;ndercode]</code>
  1594. <br>
  1595. M&ouml;gliche Werte: DE, AT, CH, SEARCH, ...<br/>
  1596. (f&uuml;r ander L&auml;nder als Deutschland bitte den SEARCH Parameter nutzen um die AreaID zu ermitteln.)
  1597. </li><br>
  1598. <li><code>[Postleitzahl/AreaID]</code>
  1599. <br>
  1600. Die Postleitzahl/AreaID des Ortes für den Unwetterinformationen abgefragt werden sollen.
  1601. <br>
  1602. </li><br>
  1603. <li><code>[INTERVAL]</code>
  1604. <br>
  1605. 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.
  1606. <br>
  1607. </li><br>
  1608. </ul>
  1609. <br>
  1610. <a name="UWZget"></a>
  1611. <b>Get</b>
  1612. <ul>
  1613. <br>
  1614. <li><code>get &lt;name&gt; Bodenfrost</code>
  1615. <br>
  1616. Gibt aus ob aktuell eine Bodenfrostwarnung besteht (active|inactive).
  1617. </li><br>
  1618. <li><code>get &lt;name&gt; Extremfrost</code>
  1619. <br>
  1620. Gibt aus ob aktuell eine Extremfrostwarnung besteht (active|inactive).
  1621. </li><br>
  1622. <li><code>get &lt;name&gt; Gewitter</code>
  1623. <br>
  1624. Gibt aus ob aktuell eine Gewitter Warnung besteht (active|inactive).
  1625. </li><br>
  1626. <li><code>get &lt;name&gt; Glaette</code>
  1627. <br>
  1628. Gibt aus ob aktuell eine Glaettewarnung besteht (active|inactive).
  1629. </li><br>
  1630. <li><code>get &lt;name&gt; Glatteisregen</code>
  1631. <br>
  1632. Gibt aus ob aktuell eine Glatteisregen Warnung besteht (active|inactive).
  1633. </li><br>
  1634. <li><code>get &lt;name&gt; Hagel</code>
  1635. <br>
  1636. Gibt aus ob aktuell eine Hagel Warnung besteht (active|inactive).
  1637. </li><br>
  1638. <li><code>get &lt;name&gt; Hitze</code>
  1639. <br>
  1640. Gibt aus ob aktuell eine Hitze Warnung besteht (active|inactive).
  1641. </li><br>
  1642. <li><code>get &lt;name&gt; Regen</code>
  1643. <br>
  1644. Gibt aus ob aktuell eine Regen Warnung besteht (active|inactive).
  1645. </li><br>
  1646. <li><code>get &lt;name&gt; Schneefall</code>
  1647. <br>
  1648. Gibt aus ob aktuell eine Schneefall Warnung besteht (active|inactive).
  1649. </li><br>
  1650. <li><code>get &lt;name&gt; Sturm</code>
  1651. <br>
  1652. Gibt aus ob aktuell eine Sturm Warnung besteht (active|inactive).
  1653. </li><br>
  1654. <li><code>get &lt;name&gt; Waldbrand</code>
  1655. <br>
  1656. Gibt aus ob aktuell eine Waldbrand Warnung besteht (active|inactive).
  1657. </li><br>
  1658. </ul>
  1659. <br>
  1660. <b>Get (Search-Mode)</b>
  1661. <ul>
  1662. <br>
  1663. <li><code>get &lt;name&gt; SearchAreaID &lt;gesuchte_stadt&gt;</code>
  1664. <br>
  1665. Gibt die AreaID zum eingegebenen Ort aus.
  1666. </li><br>
  1667. </ul>
  1668. <br>
  1669. <a name="UWZset"></a>
  1670. <b>Set</b>
  1671. <ul>
  1672. <br>
  1673. <li><code>set &lt;name&gt; update</code>
  1674. <br>
  1675. Startet sofort ein neues Auslesen der Unwetterinformationen.
  1676. </li><br>
  1677. </ul>
  1678. <br>
  1679. <a name="UWZattr"></a>
  1680. <b>Attribute</b>
  1681. <ul>
  1682. <br>
  1683. <li><code>download</code>
  1684. <br>
  1685. Download Unwetterkarten während des updates (0|1).
  1686. <br>
  1687. </li>
  1688. <li><code>savepath</code>
  1689. <br>
  1690. Pfad zum speichern der Karten (default: /tmp/).
  1691. <br>
  1692. </li>
  1693. <li><code>maps</code>
  1694. <br>
  1695. Leerzeichen separierte Liste der zu speichernden Karten. Für mögliche Karten siehe <code>UWZAsHtmlKarteLand</code>.
  1696. <br>
  1697. </li>
  1698. <li><code>humanreadable</code>
  1699. <br>
  1700. 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)
  1701. <br>
  1702. </li>
  1703. <li><code>lang</code>
  1704. <br>
  1705. Umschalten der angeforderten Sprache für kurz und lange warn text. (de|en|it|fr|es|..).
  1706. <br>
  1707. </li>
  1708. <li><code>sort_readings_by</code>
  1709. <br>
  1710. Sortierreihenfolge der Warnmeldungen. (start|severity|creation).
  1711. <br>
  1712. </li>
  1713. <li><code>htmlsequence</code>
  1714. <br>
  1715. Anzeigereihenfolge der html warnungen. (ascending|descending).
  1716. <br>
  1717. </li>
  1718. <li><code>htmltitle</code>
  1719. <br>
  1720. Titel / Ueberschrift der HTML Ausgabe
  1721. <br>
  1722. </li>
  1723. <li><code>htmltitleclass</code>
  1724. <br>
  1725. css-Class des Titels der HTML Ausgabe
  1726. <br>
  1727. </li>
  1728. <li><code>localiconbase</code>
  1729. <br>
  1730. BaseURL angeben um Warn Icons lokal zu hosten. (Dateityp ist png).
  1731. <br>
  1732. </li>
  1733. <li><code>intervalAtWarnLevel</code>
  1734. <br>
  1735. konfiguriert den Interval je nach WarnLevel. Beispiel: 2=1800,3=900,4=300
  1736. <br>
  1737. </li>
  1738. <br>
  1739. </ul>
  1740. <br>
  1741. <a name="UWZreading"></a>
  1742. <b>Readings</b>
  1743. <ul>
  1744. <br>
  1745. <li><b>Warn_</b><i>0|1|2|3...|9</i><b>_...</b> - aktive Warnmeldungen</li>
  1746. <li><b>WarnCount</b> - Anzahl der aktiven Warnmeldungen</li>
  1747. <li><b>WarnUWZLevel</b> - Gesamt Warn Level </li>
  1748. <li><b>WarnUWZLevel_Color</b> - Gesamt Warn Level Farbe</li>
  1749. <li><b>WarnUWZLevel_Str</b> - Gesamt Warn Level Text</li>
  1750. <li><b>Warn_</b><i>0</i><b>_AltitudeMin</b> - minimum Höhe für Warnung </li>
  1751. <li><b>Warn_</b><i>0</i><b>_AltitudeMax</b> - maximum Höhe für Warnung </li>
  1752. <li><b>Warn_</b><i>0</i><b>_EventID</b> - EventID der Warnung </li>
  1753. <li><b>Warn_</b><i>0</i><b>_Creation</b> - Warnungs Erzeugung </li>
  1754. <li><b>Warn_</b><i>0</i><b>_Creation_Date</b> - Warnungs Erzeugungs Datum </li>
  1755. <li><b>Warn_</b><i>0</i><b>_Creation_Time</b> - Warnungs Erzeugungs Zeit </li>
  1756. <li><b>currentIntervalMode</b> - default/warn, aktuell Verwendeter Interval. Internal INTERVAL oder INTERVALWARN</li>
  1757. <li><b>Warn_</b><i>0</i><b>_Start</b> - Begin der Warnung</li>
  1758. <li><b>Warn_</b><i>0</i><b>_Start_Date</b> - Startdatum der Warnung</li>
  1759. <li><b>Warn_</b><i>0</i><b>_Start_Time</b> - Startzeit der Warnung</li>
  1760. <li><b>Warn_</b><i>0</i><b>_End</b> - Warn Ende</li>
  1761. <li><b>Warn_</b><i>0</i><b>_End_Date</b> - Enddatum der Warnung</li>
  1762. <li><b>Warn_</b><i>0</i><b>_End_Time</b> - Endzeit der Warnung</li>
  1763. <li><b>Warn_</b><i>0</i><b>_Severity</b> - Schwere des Unwetters (0 kein Unwetter, 12 massives Unwetter)</li>
  1764. <li><b>Warn_</b><i>0</i><b>_Hail</b> - Hagelwarnung (1|0)</li>
  1765. <li><b>Warn_</b><i>0</i><b>_Type</b> - Art des Unwetters</li>
  1766. <li><b>Warn_</b><i>0</i><b>_Type_Str</b> - Art des Unwetters (text)</li>
  1767. <ul>
  1768. <li><b>1</b> - unbekannt</li>
  1769. <li><b>2</b> - Sturm/Orkan</li>
  1770. <li><b>3</b> - Schneefall</li>
  1771. <li><b>4</b> - Regen</li>
  1772. <li><b>5</b> - Extremfrost</li>
  1773. <li><b>6</b> - Waldbrandgefahr</li>
  1774. <li><b>7</b> - Gewitter</li>
  1775. <li><b>8</b> - Glätte</li>
  1776. <li><b>9</b> - Hitze</li>
  1777. <li><b>10</b> - Glatteisregen</li>
  1778. <li><b>11</b> - Bodenfrost</li>
  1779. </ul>
  1780. <li><b>Warn_</b><i>0</i><b>_uwzLevel</b> - Unwetterwarnstufe (0-5)</li>
  1781. <li><b>Warn_</b><i>0</i><b>_uwzLevel_Str</b> - Unwetterwarnstufe (text)</li>
  1782. <li><b>Warn_</b><i>0</i><b>_levelName</b> - Level Warn Name</li>
  1783. <li><b>Warn_</b><i>0</i><b>_ShortText</b> - Kurzbeschreibung der Warnung</li>
  1784. <li><b>Warn_</b><i>0</i><b>_LongText</b> - Ausführliche Unwetterbeschreibung</li>
  1785. <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>
  1786. </ul>
  1787. <br>
  1788. <a name="UWZweblinks"></a>
  1789. <b>Weblinks</b>
  1790. <ul>
  1791. <br>
  1792. &Uuml;ber die Funktionen <code>UWZAsHtml, UWZAsHtmlLite, UWZAsHtmlFP, UWZAsHtmlKarteLand, UWZAsHtmlMovie</code> wird HTML-Code zur Warnanzeige und Wetterfilme über weblinks erzeugt.
  1793. <br><br><br>
  1794. Beispiele:
  1795. <br>
  1796. <li><code>define UnwetterDetailiert weblink htmlCode {UWZAsHtml("Unwetterzentrale")}</code></li>
  1797. <br>
  1798. <li><code>define UnwetterLite weblink htmlCode {UWZAsHtmlLite("Unwetterzentrale")}</code></li>
  1799. <br>
  1800. <li><code>define UnwetterFloorplan weblink htmlCode {UWZAsHtmlFP("Unwetterzentrale")}</code></li>
  1801. <br>
  1802. <li><code>define UnwetterKarteLand weblink htmlCode {UWZAsHtmlKarteLand("Unwetterzentrale","Bayern")}</code></li>
  1803. <ul>
  1804. <li>Der zweite Parameter kann einer der folgenden sein:
  1805. <ul>
  1806. <li>europa</li>
  1807. <br/>
  1808. <li>deutschland</li>
  1809. <li>deutschland-small</li>
  1810. <li>niedersachsen</li>
  1811. <li>bremen</li>
  1812. <li>bayern</li>
  1813. <li>schleswig-holstein</li>
  1814. <li>hamburg</li>
  1815. <li>mecklenburg-vorpommern</li>
  1816. <li>sachsen</li>
  1817. <li>sachsen-anhalt</li>
  1818. <li>nordrhein-westfalen</li>
  1819. <li>thueringen</li>
  1820. <li>rheinland-pfalz</li>
  1821. <li>saarland</li>
  1822. <li>baden-wuerttemberg</li>
  1823. <li>hessen</li>
  1824. <li>brandenburg</li>
  1825. <li>berlin</li>
  1826. <br/>
  1827. <li>oesterreich</li>
  1828. <li>burgenland</li>
  1829. <li>kaernten</li>
  1830. <li>niederoesterreich</li>
  1831. <li>oberoesterreich</li>
  1832. <li>salzburg</li>
  1833. <li>steiermark</li>
  1834. <li>tirol</li>
  1835. <li>vorarlberg</li>
  1836. <li>wien</li>
  1837. <br/>
  1838. <li>schweiz</li>
  1839. <li>aargau</li>
  1840. <li>appenzell_ausserrhoden</li>
  1841. <li>appenzell_innerrhoden</li>
  1842. <li>basel_landschaft</li>
  1843. <li>basel_stadt</li>
  1844. <li>bern</li>
  1845. <li>fribourg</li>
  1846. <li>geneve</li>
  1847. <li>glarus</li>
  1848. <li>graubuenden</li>
  1849. <li>jura</li>
  1850. <li>luzern</li>
  1851. <li>neuchatel</li>
  1852. <li>nidwalden</li>
  1853. <li>obwalden</li>
  1854. <li>schaffhausen</li>
  1855. <li>schwyz</li>
  1856. <li>solothurn</li>
  1857. <li>stgallen</li>
  1858. <li>ticino</li>
  1859. <li>thurgau</li>
  1860. <li>uri</li>
  1861. <li>waadt</li>
  1862. <li>wallis</li>
  1863. <li>zug</li>
  1864. <li>zuerich</li>
  1865. <br/>
  1866. <li>liechtenstein</li>
  1867. <br/>
  1868. <li>belgique</li>
  1869. <br/>
  1870. <li>denmark</li>
  1871. <br/>
  1872. <li>finnland</li>
  1873. <br/>
  1874. <li>france</li>
  1875. <br/>
  1876. <li>letzebuerg</li>
  1877. <br/>
  1878. <li>nederland</li>
  1879. <br/>
  1880. <li>norwegen</li>
  1881. <br/>
  1882. <li>portugal</li>
  1883. <br/>
  1884. <li>sverige</li>
  1885. <br/>
  1886. <li>espana</li>
  1887. <br/>
  1888. <li>unitedkingdom</li>
  1889. <li>eastofengland</li>
  1890. <li>eastmidlands</li>
  1891. <li>london</li>
  1892. <li>northeastengland</li>
  1893. <li>northernireland</li>
  1894. <li>northwestengland</li>
  1895. <li>scotland</li>
  1896. <li>southeastengland</li>
  1897. <li>southwestengland</li>
  1898. <li>wales</li>
  1899. <li>westmidlands</li>
  1900. <li>yorkshireandthehumber</li>
  1901. <br/>
  1902. <li>isobaren1</li>
  1903. <li>isobaren2</li>
  1904. <li>isobaren3</li>
  1905. </ul>
  1906. </li>
  1907. </ul>
  1908. <li><code>define UnwetterKarteMovie weblink htmlCode {UWZAsHtmlMovie("Unwetterzentrale","niederschlag-wolken-de")}</code></li>
  1909. <ul>
  1910. <li>Der zweite Parameter kann einer der folgenden sein:
  1911. <ul>
  1912. <li>niederschlag-wolken</li>
  1913. <li>stroemung</li>
  1914. <li>temperatur</li>
  1915. <br/>
  1916. <li>niederschlag-wolken-de</li>
  1917. <li>stroemung-de</li>
  1918. <br/>
  1919. <li>niederschlag-wolken-ch</li>
  1920. <li>stroemung-ch</li>
  1921. <br/>
  1922. <li>niederschlag-wolken-at</li>
  1923. <li>stroemung-at</li>
  1924. <br/>
  1925. <li>clouds-precipitation-uk</li>
  1926. <li>currents-uk</li>
  1927. <br/>
  1928. </ul>
  1929. </li>
  1930. </ul>
  1931. <br/><br/>
  1932. </ul>
  1933. <br>
  1934. </ul>
  1935. =end html_DE
  1936. =cut