Autor Thema: httpmod.template: bugs, Fragen, Anregungen  (Gelesen 15722 mal)

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7416
Antw:httpmod.template: bugs, Fragen, Anregungen
« Antwort #180 am: 05 Januar 2021, 13:29:07 »
Das habe ich vergessen. Ist aber nicht so schlimm. Ich mache es beim nächsten Einchecken.
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Offline artoffhem

  • New Member
  • *
  • Beiträge: 6
Antw:httpmod.template: bugs, Fragen, Anregungen
« Antwort #181 am: 05 Januar 2021, 14:16:37 »
weil ich gerade dabei bin habe ich mir auch noch die Astro-Daten angesehen, die momentan nicht funktionieren. Der Grund dürfte das Regex für dayLength sein, dass 00:00 erwartert, jedoch momentan 0:00 ist. ORF liefert hier im Gegensatz zu anderen Zeiten keine führende NULL aus.
... [\w\W]*Tagesl[^>]+>(\d\d:\d\d)&[\w\W]* ...
meine Lösung würde so aussehen
... [\w\W]*Tagesl[^>]+>([\d]+:\d\d)&[\w\W]* ...
ORF Astro-Daten
      <div class="details">
         <div class="sunData">
            <p class="rise" title="Sonnenaufgang"><span class="offscreen">Sonnenaufgang um </span>07:56<span class="offscreen"> Uhr.</span></p>
            <p class="set" title="Sonnenuntergang"><span class="offscreen">Sonnenuntergang um </span>16:31<span class="offscreen"> Uhr.</span></p>
         </div>

         <div class="moonData">
            <p class="offscreen">Mondphase: Abnehmender Halbmond.</p>
            <p class="rise" title="Mondaufgang"><span class="offscreen">Mondaufgang um </span>23:48<span class="offscreen"> Uhr.</span></p>
            <p class="set" title="Monduntergang"><span class="offscreen">Monduntergang um </span>11:40<span class="offscreen"> Uhr.</span></p>
         </div>
      </div>

      <div class="extendedDetails">
         <p><span class="label">Tagesl&auml;nge: </span>8:34&thinsp;<abbr title="Stunden">h</abbr></p>
         <p><span class="label">D&auml;mmerung<span class="offscreen"> Morgen</span>: </span>07:21&thinsp;Uhr</p>
         <p><span class="label"><span class="offscreen">D&auml;mmerung Abend:</span></span>17:06&thinsp;Uhr</p>
      </div>

Offline amenomade

  • Developer
  • Hero Member
  • ****
  • Beiträge: 7416
Antw:httpmod.template: bugs, Fragen, Anregungen
« Antwort #182 am: 09 Januar 2021, 01:03:13 »
Hab die Korrektur eingecheckt. Danke Dir :)
Pi 3B, Alexa, CUL868+Selbstbau 1/2λ-Dipol-Antenne, USB Optolink / Vitotronic, Debmatic und HM / HmIP Komponenten, Rademacher Duofern Jalousien, Fritz!Dect Thermostaten, Proteus

Offline antonwinden

  • Full Member
  • ***
  • Beiträge: 262
Antw:httpmod.template: bugs, Fragen, Anregungen
« Antwort #183 am: 04 April 2021, 08:35:44 »
Habe hier ein komisches Problem:
Wetter von ORF Neusiedl am See (https://wetter/orf/at/burgenland/neusiedlsee) funktioniert ohne Probleme.
Nur wenn ich Podersdorf auswähle stürzt mein Fhem ab -> https://wetter/orf/at/burgenland/podersdorf

die letzten Zeilen im Log sind:
   <script type="text/javascript">,
   var ivwPrefix = "RedCont/Wetter/Oesterreichwetter/v2wet/v2bgl/v2lawe/station/";,
   var oewa_data = {,
           "cn": "at",,
           "st": "at_w_atorf",,
           "sv": "in",,
           "ps": "lin",,
           "cp": "RedCont/Wetter/Oesterreichwetter/v2wet/v2bgl/v2lawe/station/",,
           "sc": "yes",
         };,,
>,
,
,
</body>,
</html>,
,
,
2021.04.04 08:27:43.239 4: ORFp: BodyDecode is not decoding the response body (charset utf-8, bodyDecode defaults to none),
2021.04.04 08:27:43.239 5: ORFp: GetCookies is looking for Cookies,
2021.04.04 08:27:43.239 4: ORFp: GetCookies parsed Cookie: HopSession Wert 127.0.0.178.18.171.8214try4wwf0 Rest Path=/; Domain=.orf.at; HttpOnly,
2021.04.04 08:27:43.239 5: ORFp: ExtractSid called, context get, num 01,
2021.04.04 08:27:43.239 4: ORFp: checking for redirects, code=200, ignore=0,
2021.04.04 08:27:43.239 4: ORFp: no redirects to handle,
2021.04.04 08:27:43.239 5: ORFp: Read callback sets LAST_REQUEST to get01,
2021.04.04 08:27:43.239 5: ORFp: CheckAuth decided no authentication required,
2021.04.04 08:27:43.240 5: ORFp: ExtractReading for context get, num 01 - no individual parse definition,
2021.04.04 08:27:43.240 5: ORFp: UpdateReadingList created list of reading.* nums to parse during getUpdate as 01,
2021.04.04 08:27:43.240 5: ORFp: Read starts parsing response to get01 with defined readings: 01,
2021.04.04 08:27:43.240 5: ORFp: ExtractReading reading01 with regex /(?^:(?s)Temperatur.*?.*?>.*?(?<temperature>(&minus;)?[\d,]+)&thinsp.*?Taupunkt.*?.*?>.*?(?<taupunkt>(&minus;)?[\d,]+)&thinsp.*?Wind.*?>\n\s*(?<wind>[^<]+)\s<abbr.*?Windspitzen.*?>\n\s*(?<windspitzen>[^<]+)\s<abbr.*?Luftdruck.*?>\n\s*(?<luftdruck>[^<]+)\s<abbr.*?Luftfeuchtigkeit.*?>\n\s*(?<humidity>[^<]+)\s<abbr.*?Sonnenschein.*?>\n\s*(?<sonne>[^<]+)\s<abbr.*?Niederschlag.*?>\n\s*(?<rain>[^<\n]+).*?</p.*?(?<messwerte>Messwerte[^<\n]+))/...,
danach kommt nichts mehr...
kann auch mit neusiedl am See gut leben...
gruß Anton
KNX, Raspberry, Denon 3313, Philips TV, Xtrend9X00 und viel Optimismus...

Offline yersinia

  • Sr. Member
  • ****
  • Beiträge: 980
    • Cyanide & Happiness
Antw:httpmod.template: bugs, Fragen, Anregungen
« Antwort #184 am: 23 April 2021, 10:53:00 »
Wegen Änderung einiger Readings nach Upgrade auf 9.4.0 kleine Anpassung am HTTPMOD tasmota_firmware_check (analog zum JsonMod Template):
#Contributed by OdfFHEM, see https://forum.fhem.de/index.php/topic,97694.msg992348.html#msg992348
name:tasmota_firmware_updates
filter:TYPE=HTTPMOD
desc: Check Tasmota homepage for available new firmware files<br>Define a HTTPMOD device like <br>define tasmotaupdates HTTPMOD https://github.com/arendst/Tasmota/tags 86400<a href="https://forum.fhem.de/index.php/topic,97694.msg992308.html#msg992308">Source: Forum</a>.
order:TECHZ06
par:WHICHROOM;Actual room of the device, defaults to HTTPMOD; {AttrVal("DEVICE","room","HTTPMOD" )}
par:UPDATABLEDEVICESMODE;Actual mode for updatableDevices, defaults to onlyUpdatable; {AttrVal("DEVICE","updatableDevicesMode","onlyUpdatable")}
par:INTERVAL;Actual interval for updating, defaults to one week; {InternalVal("DEVICE","Interval","604800")}
defmod DEVICE HTTPMOD https://github.com/arendst/Tasmota/tags INTERVAL
attr DEVICE userattr reading01Name reading01Regex reading02Name reading02OExpr reading02Regex updatableDevicesMode:onlyUpdatable,all
attr DEVICE enableControlSet 1
attr DEVICE event-on-change-reading .*
attr DEVICE event-on-update-reading LAST_ERROR,MATCHED_READINGS
attr DEVICE handleRedirects 0
attr DEVICE reading01Name latestVersion
attr DEVICE reading01Regex commit-title">[\w\W]*?<a href=".*">[\w\W]*?v(\d*.\d*.\d*)[\w\W]*?</a>
attr DEVICE reading02Name latestDate
attr DEVICE reading02OExpr $val =~ m/^(.{4})-(.{2})-(.{2})$/ ;; "$3.$2.$1"
attr DEVICE reading02Regex relative-time[\w\W]*?datetime="(\d*-\d*-\d*)T\d*:\d*:\d*Z"
attr DEVICE showError 1
attr DEVICE showMatched 1
attr DEVICE stateFormat { my $ret ="";;\
    my $lastCheck = ReadingsTimestamp($name,"MATCHED_READINGS","???");;\
    $ret .= '<div style="text-align:left;;">';;\
    $ret .= 'last <a title="versions" href="https://github.com/arendst/Tasmota/releases" target="_blank">tasmota</a>-check => '.$lastCheck;;\
    $ret .= '<br><br><pre>';;\
    $ret .= "| device                           | current |   new   |  released  |<br>";;\
    $ret .= "---------------------------------------------------------------------<br>";;\
    my $check = ReadingsVal($name,"updatableDevices","error => no or wrong data from server!");;\
    if($check eq "no updates needed!") {\
      $ret .= '| <b style="color:green;;">';;\
      $ret .= sprintf("%-65s",$check);;\
      $ret .= '</b> |';;\
    } elsif($check eq "error => no or wrong data from server!") {\
      $ret .= '| <b style="color:red;;">';;\
      $ret .= sprintf("%-65s",$check);;\
      $ret .= '</b> |';;\
    } else {\
      my @devices = split(',',$check);;\
      foreach my $devStr (@devices) {\
        my ($dev,$old,$new,$date) = $devStr =~ m/^([^\s]+)\s\(([^\s]+)\s\|\s([^\s]+)\s\|\s([^\)]+)\)$/;;\
        $ret .= '| <a href="/fhem?detail='.$dev.'"><b>';;\
        $ret .= sprintf("%-32s",AttrVal($dev,"alias",$dev));;\
        $ret .= '</b></a> | ';;\
        $ret .= '<b style="color:lightgray;;">';;\
        $ret .= '<a href="http://'.ReadingsVal($dev,"Info2_IPAddress",ReadingsVal($dev,"IPAddress",ReadingsVal($dev,"INFO2_IPAddress","0.0.0.0"))).'/up" target="_blank">';;\
        $ret .= sprintf("%7s",$old);;\
        $ret .= '</a></b> | ';;\
        $ret .= '<a href="https://github.com/arendst/Tasmota/releases/tag/v'.$new.'">';;\
        $ret .= '<b style="color:red;;">';;\
        $ret .= sprintf("%7s",$new);;\
        $ret .= '</b></a> | ';;\
        $ret .= '<a href="https://github.com/arendst/Tasmota/releases/tag/v'.$new.'">';;\
        $ret .= '<b style="color:black;;">';;\
        $ret .= sprintf("%-10s",$date);;\
        $ret .= '</b></a>';;\
        $ret .= " |<br>";;\
      }\
    }\
    $ret .= '</pre></div>';;\
  return $ret;;\
}
attr DEVICE timestamp-on-change-reading .*
attr DEVICE updatableDevicesMode UPDATABLEDEVICESMODE
attr DEVICE userReadings updatableDevices:MATCHED_READINGS.* {\
  my $ret = "";;\
  if (ReadingsVal($name,"MATCHED_READINGS","") eq "") {\
    $ret = "error => no or wrong data from server!";;\
  } else {\
    my $VERSION = ReadingsVal($name,"latestVersion","unknown");;\
    my $DATE = ReadingsVal($name,"latestDate","unknown");;\
    foreach my $dev (devspec2array("TYPE=MQTT[2]?_[D]EVICE:FILTER=readingList~.*tele[/].*INFO.*:FILTER=Version!=,TYPE=MQTT[2]?_[D]EVICE:FILTER=readingList~.*tele[/].*INFO.*:FILTER=INFO1_Version!=")) {\
      my $version = ReadingsVal($dev,"Info1_Version",ReadingsVal($dev,"Version",ReadingsVal($dev,"INFO1_Version","0.0.0")));;\
      $version =~ m/([0-9.]*).*/;;\
      $version = $1;;\
      if ( AttrVal($name,"updatableDevicesMode","onlyUpdatable") eq "all" || $version ne $VERSION ) {\
        $ret .= "," if($ret ne "");;\
        $ret .= $dev." (".$version." | ".$VERSION." | ".$DATE.")";;\
      }\
    }\
  }\
  return ($ret eq "")?"no updates needed!":$ret;;\
}
attr DEVICE webCmd reread
attr DEVICE room WHICHROOM
attr DEVICE model tasmota_firmware_updates
setreading DEVICE attrTemplateVersion 20210423
viele Grüße, yersinia
----
FHEM 6.0 (SVN) on RPi 4B with RasPi OS Buster (perl 5.28.1) | FTUI
nanoCUL->2x868(1x ser2net)@tsculfw, 1x433@aculfw | MQTT2 | Tasmota | ESPEasy
VCCU->14xSEC-SCo, 7xCC-RT-DN, 5xLC-Bl1PBU-FM, 3xTC-IT-WM-W-EU, 1xPB-2-WM55, 1xLC-Sw1PBU-FM, 1xES-PMSw1-Pl