Hauptmenü

Eishockeytabelle auslesen

Begonnen von Superposchi, 25 Februar 2023, 22:39:49

Vorheriges Thema - Nächstes Thema

Superposchi

Hallo zusammen, habe jetzt kein passendes Unterforum gefunden, falls vorhanden bitte verschieben.

Ich würde gerne per HTTPMOD die Ergebnisse der DEL-Hockey Tabelle auslesen und mir später in FTUI darstellen.
Leider komme ich mit der HTML-Struktur der Webseite nicht zurecht. Die einzelnen Felder sind nicht vernünftig gekennzeichnet.

Habe es jetzt mal mit folgendem Device probiert:
Internals:
   BUSY       0
   CFGFN     
   DEF        https://www.https://www.hockeyweb.de/del/tabelle-spielplan 600
   FUUID      63fa6e1f-f33f-7706-d2b8-5a6af2677313b7ce
   Interval   600
   MainURL    https://www.https://www.hockeyweb.de/del/tabelle-spielplan
   ModuleVersion 4.1.15 - 17.12.2022
   NAME       hockey_table
   NOTIFYDEV  global
   NR         437263
   NTFY_ORDER 50-hockey_table
   STATE      Super_E5: SuperE5 € <br/> Super_E10: SuperE10 € <br/> Super_Plus: SuperPlus € <br/> Dieselsprit : Diesel €
   TYPE       HTTPMOD
   eventCount 3
   value     
   CompiledRegexes:
   HTTPCookieHash:
     csrftoken;:
       Name       csrftoken
       Options    expires=Sat, 24 Feb 2024 20:22:56 GMT; Max-Age=31449600; Path=/; SameSite=Lax
       Path       
       Value      Y8YWFtueLVFoYjUA4nNF9DXNBOhvXfyCRjFcAwtKptatoEDtAY3Y37Dqv4cCitCK
   HttpUtils:
     data       
     displayurl https://www.https://www.hockeyweb.de/del/tabelle-spielplan
     header     Cookie: csrftoken=Y8YWFtueLVFoYjUA4nNF9DXNBOhvXfyCRjFcAwtKptatoEDtAY3Y37Dqv4cCitCK
     httpversion 1.0
     hu_blocking 0
     ignoreredirects 1
     loglevel   4
     redirects  0
     timeout    10
     url        https://www.https://www.hockeyweb.de/del/tabelle-spielplan
     sslargs:
   OLDREADINGS:
   QUEUE:
   READINGS:
   REQUEST:
     context    reading
     data       
     header     
     ignoreredirects 0
     num        unknown
     retryCount 0
     type       update
     url        https://www.https://www.hockeyweb.de/del/tabelle-spielplan
   defptr:
     readingBase:
     readingNum:
     readingOutdated:
     readingSubNum:
     requestReadings:
       update:
Attributes:
   alias      DEL Tabelle
   enableControlSet 1
   event-on-change-reading .*
   group      Informationen
   icon       fuel
   model      clever_tanken_single_station
   reading01Name Platz01_Mannschaft
   reading01Regex <td class="hw-table__team__place">1</td><td class="hw-table__team__name">EHC Red Bull München</td>
   reading02Name Platz01_Spiele
   reading02Regex <td class="hw-table__team__place">1</td><td class="hw-table__team__matches">53</td>
   reading03Name Platz01_Punkte
   reading03Regex <td class="hw-table__team__place">1</td><td class="hw-table__team__points">114</td>
   reading04Name Platz02_Mannschaft
   reading04Regex <td class="hw-table__team__place">2</td><td class="hw-table__team__name">ERC Ingolstadt</td>
   reading05Name Platz02_Spiele
   reading05Regex <td class="hw-table__team__place">2</td><td class="hw-table__team__matches">52</td>
   reading06Name Platz02_Punkte
   reading06Regex <td class="hw-table__team__place">2</td><td class="hw-table__team__points">97</td>
   reading07Name Platz03_Mannschaft
   reading07Regex <td class="hw-table__team__place">3</td><td class="hw-table__team__name">Straubing Tigers</td>
   reading08Name Platz03_Spiele
   reading08Regex <td class="hw-table__team__place">3</td><td class="hw-table__team__matches">52</td>
   reading09Name Platz03_Punkte
   reading09Regex <td class="hw-table__team__place">3</td><td class="hw-table__team__points">92</td>
   readingMaxAge 10
   readingMaxAgeReplacementMode delete
   readingOExpr $val =~ s/<[\d\D]+>//;;$val
   room       Information->Hockey
   timeout    10
   timestamp-on-change-reading .*
   verbose    2


Der entsprechende Teil der webseite sieht im Quelltext folgendermaßen aus:
<div class="hw-appdb__view hw-appdb__view--table">

   
<div class="hw-table">
    <table>
        <thead>
        <tr class="hw-table__head">
            <td class="hw-table__team__place">Pl.</td>
            <td></td>
            <td class="hw-table__team__name">Verein</td>
            <td class="hw-table__team__matches">Spiele</td>
            <td class="hw-table__team__points">Pt.</td>
            <td class="hw-table__team__goalsDiff">Diff.</td>
            <td class="hw-table__team__goals">Tore</td>
            <td class="hw-table__team__wins">G</td>
            <td class="hw-table__team__wins-ot">OTG</td>
            <td class="hw-table__team__wins-pso">PSG</td>
            <td class="hw-table__team__losses-ot">OTV</td>
            <td class="hw-table__team__losses-pso">PSV</td>
            <td class="hw-table__team__losses">V</td>
        </tr>
        </thead>
        <tbody>
        <tr class="hw-table__team">
    <td class="hw-table__team__place">1</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_33_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_33_cell.png"></td>
    <td class="hw-table__team__name">EHC Red Bull München</td>
    <td class="hw-table__team__matches">53</td>
    <td class="hw-table__team__points">114</td>
    <td class="hw-table__team__goalsDiff">66</td>
    <td class="hw-table__team__goals"><span>190 : 124</span></td>
    <td class="hw-table__team__wins">34</td>
    <td class="hw-table__team__wins-ot">3</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">0</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">12</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">2</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_6_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_6_cell.png"></td>
    <td class="hw-table__team__name">ERC Ingolstadt</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">97</td>
    <td class="hw-table__team__goalsDiff">43</td>
    <td class="hw-table__team__goals"><span>171 : 128</span></td>
    <td class="hw-table__team__wins">27</td>
    <td class="hw-table__team__wins-ot">2</td>
    <td class="hw-table__team__wins-pso">3</td>
    <td class="hw-table__team__losses-ot">3</td>
    <td class="hw-table__team__losses-pso">3</td>
    <td class="hw-table__team__losses">14</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">3</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_17_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_17_cell.png"></td>
    <td class="hw-table__team__name">Straubing Tigers</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">92</td>
    <td class="hw-table__team__goalsDiff">23</td>
    <td class="hw-table__team__goals"><span>173 : 150</span></td>
    <td class="hw-table__team__wins">24</td>
    <td class="hw-table__team__wins-ot">4</td>
    <td class="hw-table__team__wins-pso">4</td>
    <td class="hw-table__team__losses-ot">2</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">16</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">4</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_3_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_3_cell.png"></td>
    <td class="hw-table__team__name">Adler Mannheim</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">91</td>
    <td class="hw-table__team__goalsDiff">21</td>
    <td class="hw-table__team__goals"><span>146 : 125</span></td>
    <td class="hw-table__team__wins">22</td>
    <td class="hw-table__team__wins-ot">5</td>
    <td class="hw-table__team__wins-pso">5</td>
    <td class="hw-table__team__losses-ot">4</td>
    <td class="hw-table__team__losses-pso">1</td>
    <td class="hw-table__team__losses">15</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">5</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_5_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_5_cell.png"></td>
    <td class="hw-table__team__name">Düsseldorfer EG</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">89</td>
    <td class="hw-table__team__goalsDiff">18</td>
    <td class="hw-table__team__goals"><span>144 : 126</span></td>
    <td class="hw-table__team__wins">22</td>
    <td class="hw-table__team__wins-ot">5</td>
    <td class="hw-table__team__wins-pso">4</td>
    <td class="hw-table__team__losses-ot">3</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">16</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">6</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_9_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_9_cell.png"></td>
    <td class="hw-table__team__name">Grizzlys Wolfsburg</td>
    <td class="hw-table__team__matches">53</td>
    <td class="hw-table__team__points">88</td>
    <td class="hw-table__team__goalsDiff">23</td>
    <td class="hw-table__team__goals"><span>165 : 142</span></td>
    <td class="hw-table__team__wins">23</td>
    <td class="hw-table__team__wins-ot">2</td>
    <td class="hw-table__team__wins-pso">3</td>
    <td class="hw-table__team__losses-ot">5</td>
    <td class="hw-table__team__losses-pso">4</td>
    <td class="hw-table__team__losses">16</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">7</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_15_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_15_cell.png"></td>
    <td class="hw-table__team__name">Kölner Haie</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">83</td>
    <td class="hw-table__team__goalsDiff">34</td>
    <td class="hw-table__team__goals"><span>178 : 144</span></td>
    <td class="hw-table__team__wins">23</td>
    <td class="hw-table__team__wins-ot">5</td>
    <td class="hw-table__team__wins-pso">1</td>
    <td class="hw-table__team__losses-ot">1</td>
    <td class="hw-table__team__losses-pso">1</td>
    <td class="hw-table__team__losses">21</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">8</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_66_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_66_cell.png"></td>
    <td class="hw-table__team__name">Fischtown Pinguins</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">80</td>
    <td class="hw-table__team__goalsDiff">8</td>
    <td class="hw-table__team__goals"><span>143 : 135</span></td>
    <td class="hw-table__team__wins">21</td>
    <td class="hw-table__team__wins-ot">3</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">5</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">19</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">9</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_16_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_16_cell.png"></td>
    <td class="hw-table__team__name">Nürnberg Ice Tigers</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">76</td>
    <td class="hw-table__team__goalsDiff">-20</td>
    <td class="hw-table__team__goals"><span>149 : 169</span></td>
    <td class="hw-table__team__wins">21</td>
    <td class="hw-table__team__wins-ot">2</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">5</td>
    <td class="hw-table__team__losses-pso">0</td>
    <td class="hw-table__team__losses">22</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">10</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_643_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_643_cell.png"></td>
    <td class="hw-table__team__name">Löwen Frankfurt</td>
    <td class="hw-table__team__matches">53</td>
    <td class="hw-table__team__points">74</td>
    <td class="hw-table__team__goalsDiff">-13</td>
    <td class="hw-table__team__goals"><span>152 : 165</span></td>
    <td class="hw-table__team__wins">18</td>
    <td class="hw-table__team__wins-ot">3</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">5</td>
    <td class="hw-table__team__losses-pso">5</td>
    <td class="hw-table__team__losses">20</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">11</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_30_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_30_cell.png"></td>
    <td class="hw-table__team__name">Schwenninger Wild Wings</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">71</td>
    <td class="hw-table__team__goalsDiff">-5</td>
    <td class="hw-table__team__goals"><span>134 : 139</span></td>
    <td class="hw-table__team__wins">19</td>
    <td class="hw-table__team__wins-ot">2</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">3</td>
    <td class="hw-table__team__losses-pso">3</td>
    <td class="hw-table__team__losses">23</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">12</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_12_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_12_cell.png"></td>
    <td class="hw-table__team__name">Iserlohn Roosters</td>
    <td class="hw-table__team__matches">53</td>
    <td class="hw-table__team__points">70</td>
    <td class="hw-table__team__goalsDiff">-35</td>
    <td class="hw-table__team__goals"><span>142 : 177</span></td>
    <td class="hw-table__team__wins">18</td>
    <td class="hw-table__team__wins-ot">4</td>
    <td class="hw-table__team__wins-pso">1</td>
    <td class="hw-table__team__losses-ot">4</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">24</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">13</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_1_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_1_cell.png"></td>
    <td class="hw-table__team__name">Eisbären Berlin</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">68</td>
    <td class="hw-table__team__goalsDiff">-14</td>
    <td class="hw-table__team__goals"><span>146 : 160</span></td>
    <td class="hw-table__team__wins">16</td>
    <td class="hw-table__team__wins-ot">4</td>
    <td class="hw-table__team__wins-pso">2</td>
    <td class="hw-table__team__losses-ot">3</td>
    <td class="hw-table__team__losses-pso">5</td>
    <td class="hw-table__team__losses">22</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">14</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_4_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_4_cell.png"></td>
    <td class="hw-table__team__name">Augsburger Panther</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">46</td>
    <td class="hw-table__team__goalsDiff">-55</td>
    <td class="hw-table__team__goals"><span>125 : 180</span></td>
    <td class="hw-table__team__wins">11</td>
    <td class="hw-table__team__wins-ot">3</td>
    <td class="hw-table__team__wins-pso">0</td>
    <td class="hw-table__team__losses-ot">5</td>
    <td class="hw-table__team__losses-pso">2</td>
    <td class="hw-table__team__losses">31</td>
</tr>
<tr class="hw-table__team">
    <td class="hw-table__team__place">15</td>
    <!--<td class="hw-table__team__logo"><img src="/theme/public/assets/frontend/graphics/teamLogos/logo_82_cell.png"></td>-->
    <td class="hw-table__team__logo"><img src="https://appdb.hockeyweb.de/v2/teamLogos/logo_82_cell.png"></td>
    <td class="hw-table__team__name">Bietigheim Steelers</td>
    <td class="hw-table__team__matches">52</td>
    <td class="hw-table__team__points">37</td>
    <td class="hw-table__team__goalsDiff">-94</td>
    <td class="hw-table__team__goals"><span>114 : 208</span></td>
    <td class="hw-table__team__wins">7</td>
    <td class="hw-table__team__wins-ot">2</td>
    <td class="hw-table__team__wins-pso">4</td>
    <td class="hw-table__team__losses-ot">1</td>
    <td class="hw-table__team__losses-pso">3</td>
    <td class="hw-table__team__losses">35</td>
</tr>

        </tbody>
    </table>
</div>


Hat jemand einen Tip für mich wie ich die Regex genau beschreiben muss, damit der richtige Text ausgelesen wird?

t1me2die

#1
Moin, so könnte man es machen, der erste Treffer ist die Überschrift der Tabelle, nicht unbedingt schön, aber es klappt:


defmod Hockey HTTPMOD https://www.hockeyweb.de/del/tabelle-spielplan 600
attr Hockey DbLogExclude .*
attr Hockey enableControlSet 1
attr Hockey reading01Name name
attr Hockey reading01RegOpt g
attr Hockey reading01Regex \n    <td class="hw-table__team__name">(.*)<\/td>
attr Hockey reading02Name matches
attr Hockey reading02RegOpt g
attr Hockey reading02Regex \n    <td class="hw-table__team__matches">(.*)<\/td>
attr Hockey reading03Name points
attr Hockey reading03RegOpt g
attr Hockey reading03Regex \n    <td class="hw-table__team__points">(.*)<\/td>
attr Hockey reading04Name goalsDiff
attr Hockey reading04RegOpt g
attr Hockey reading04Regex \n    <td class="hw-table__team__goalsDiff">(.*)<\/td>
attr Hockey reading05Name goals
attr Hockey reading05RegOpt g
attr Hockey reading05Regex \n    <td class="hw-table__team__goals"><span>(.*)<\/span><\/td>
attr Hockey reading06Name wins
attr Hockey reading06RegOpt g
attr Hockey reading06Regex \n    <td class="hw-table__team__wins">(.*)<\/td>
attr Hockey reading07Name wins-ot
attr Hockey reading07RegOpt g
attr Hockey reading07Regex \n    <td class="hw-table__team__wins-ot">(.*)<\/td>
attr Hockey reading08Name wins-pso
attr Hockey reading08RegOpt g
attr Hockey reading08Regex \n    <td class="hw-table__team__wins-pso">(.*)<\/td>
attr Hockey reading09Name losses-ot
attr Hockey reading09RegOpt g
attr Hockey reading09Regex \n    <td class="hw-table__team__losses-ot">(.*)<\/td>
attr Hockey reading10Name losses-pso
attr Hockey reading10RegOpt g
attr Hockey reading10Regex \n    <td class="hw-table__team__losses-pso">(.*)<\/td>
attr Hockey reading11Name losses
attr Hockey reading11RegOpt g
attr Hockey reading11Regex \n    <td class="hw-table__team__losses">(.*)<\/td>


Je nachdem, wie / was du mit den Readings weiter machen möchtest, kannst du die Readings in einer Schleife lesen und einfach alle anzeigen, wobei du das erste Reading immer überspringst.

Gruß

Superposchi

Ich möchte die Readings in meinem FTUI optisch als Tabelle darstellen. Dazu reichen eigentlich auch die Infos zu Mannschaft, Spiele und Punkkte. Ein weiteres Reading pro Tabellenplatz muss ich eh per Userreading selbst errechnen.
Bei 15 Tabellenplätzen möchte ich mir eigentlich nicht mehr Readings in das Device laden als unbedingt nötig. Wenn ich alle Felder auslese wären das dann 15x 13 Werte - sehr Viel und sehr unübersichtlich denke ich.

Reicht es wenn ich in deinem Beispiel einfach die Infos auslasse für die Werte die ich nicht benötige?

t1me2die

#3
Klar, dann sollte es so ausschauen:


attr Hockey reading01Name name
attr Hockey reading01Regex \n    <td class="hw-table__team__name">(.*)<\/td>
attr Hockey reading01RegOpt g

attr Hockey reading02Name matches
attr Hockey reading02Regex \n    <td class="hw-table__team__matches">(.*)<\/td>
attr Hockey reading02RegOpt g

attr Hockey reading03Name points
attr Hockey reading03Regex \n    <td class="hw-table__team__points">(.*)<\/td>
attr Hockey reading03RegOpt g


Dann bekommst du Name, Matches und Points.
Ggf. solltest du das Leseintervall vllt. hoch setzen?
Alle 10Minuten ist vllt. etwas zu viel?!

Warum willst du dir per UserReadings was errechnen?

Im Namen z.B. "name-1", "name-2", "name-3" ist doch implizit die Platzierung enthalten  ;)
Die RegEx geht von Oben nach Unten stumpf durch die Tabelle durch.

Superposchi

Danke hat geklappt. Manchmal kann es so einfach sein.

Jetzt muss ich nur noch den Quotient für jeden Platz errechnen. Also die Punkte durch die Anzahl der Spiele.
Hast du da eventuell auch einen Tip mit einer Schleife, sonst muss ich es per Userreading für jeden Tabellenplatz machen.

t1me2die

#5
Ist auch relativ simpel.
Leg Dir einfach ein Notify auf ein Reading, z.B. auf "name-1" und anschließend rufst du eine Funktion (z.B. calculateQuotient() ) auf, die sich in deiner 99_myUtils.pm befindet, die dann wie folgt ausschaut:

Notify könnte ungefähr so ausschauen (nicht getestet!!!!)
define n_Hockey notify Hockey:name-1.* { calculateQuotient() }

Evtl. brauchst du noch ein:
attr Hockey event-on-update-reading name-1

Und diese Sub haust du in deine 99_myUtils.pm  :)

sub calculateQuotient() {
my $quotient = 0;
for (my $i=1; $i<=15; $i++) {
$quotient = sprintf "%.2f",(ReadingsNum("Hockey","points-$i",0) / ReadingsNum("Hockey","matches-$i",0));
fhem "setreading Hockey quotient-$i $quotient";
}
}


Über die Eingabezeile von FHEM kannst du auch die Funktion direkt aufrufen mit:
{ calculateQuotient() }

Und wenn du es etwas "smarter" machen möchtest, dann übergibst du der Sub einfach deinen Hockey-Devicenamen und verwendest diesen in der Schleife.
Dann hast du keine Konstanten und der Code schaut etwas besser aus.

Superposchi

Klingt interessant, aber wenn ich das richtig verstehe wird die Funktion nur ausgelöst wenn der Name auf Platz 1 sich ändert.
Da es oft genug nur in den unteren Plätzen Änderungen gibt, der erste Platz aber gleich bleibt, sehe ich darin ein Problem.

Oder verstehe ich da was falsch?

t1me2die

Deswegen musst du ein "event-on-update-reading" verwenden.
Dieses wird jedesmal getriggert, wenn der HTTPMOD die Daten aktualisiert.

Superposchi

Ok, habe alles mal soweit umgesetzt, aber das manuelle ausführen der Funktion gibt folgenden Fehler zurück:
Illegal division by zero at ./FHEM/99_myUtils.pm line 210.

Da in den Readings nirgendwo eine Null vorhanden ist oder ein Leeres Reading existiert, kann ich mir das nicht erklären.

t1me2die

Ja gut, dann fangen wir halt 0 ab  ;)


my $quotient = 0;
for (my $i=1; $i<=15; $i++) {
    if (ReadingsNum("Hockey","matches-$i",0) > 0) {
        $quotient = sprintf "%.2f",(ReadingsNum("Hockey","points-$i",0) / ReadingsNum("Hockey","matches-$i",0));
        fhem "setreading Hockey quotient-$i $quotient";
    }
    elsif (ReadingsNum("Hockey","matches-$i",0) == 0) {
        fhem "setreading Hockey quotient-$i 0";
    }
}

Superposchi

Es bleibt bei der Meldung - Verstehe ich nicht.

t1me2die

Dann mal bitte ein List von deinem Device und dann schauen wir mal.
Der Default Wert vom ReadingsNum ist Null, wenn also das ReadingsNum nicht klappt, weil z. B.  nur 14Teams in der Liste sind, dann könnte dies Probleme machen.

Superposchi

Hier das List:
Internals:
   BUSY       0
   CFGFN     
   DEF        https://www.hockeyweb.de/del/tabelle-spielplan 600
   FUUID      63fa6e1f-f33f-7706-d2b8-5a6af2677313b7ce
   Interval   600
   MainURL    https://www.hockeyweb.de/del/tabelle-spielplan
   ModuleVersion 4.1.15 - 17.12.2022
   NAME       hockey_table
   NOTIFYDEV  global
   NR         437263
   NTFY_ORDER 50-hockey_table
   STATE      EHC Red Bull München
   TYPE       HTTPMOD
   eventCount 36
   value     
   CompiledRegexes:
   HTTPCookieHash:
     count;/:
       Name       count
       Options    path=/; domain=www.hockeyweb.de
       Path       /
       Value      63
     csrftoken;:
       Name       csrftoken
       Options    expires=Sat, 24 Feb 2024 20:22:56 GMT; Max-Age=31449600; Path=/; SameSite=Lax
       Path       
       Value      Y8YWFtueLVFoYjUA4nNF9DXNBOhvXfyCRjFcAwtKptatoEDtAY3Y37Dqv4cCitCK
   HttpUtils:
     NAME       
     addr       https://www.hockeyweb.de:443
     auth       0
     code       200
     compress   1
     conn       
     data       
     displayurl https://www.hockeyweb.de/del/tabelle-spielplan
     header     Cookie: count=62; csrftoken=Y8YWFtueLVFoYjUA4nNF9DXNBOhvXfyCRjFcAwtKptatoEDtAY3Y37Dqv4cCitCK
     host       www.hockeyweb.de
     httpheader HTTP/1.1 200 OK
Date: Sun, 26 Feb 2023 20:12:34 GMT
Content-Type: text/html; charset=utf-8
Connection: close
Cache-Control: must-revalidate, proxy-revalidate, private, no-cache, max-age=0
Server-Timing:
Set-Cookie: count=63; path=/; domain=www.hockeyweb.de
Access-Control-Allow-Origin: *
CF-Cache-Status: DYNAMIC
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=8MzKXcjrdoE49SwdCpmqkeeXKs2ffcrk%2BA64cVDHaUXnu4a5XlmDApUJkyttQ2pNMvHdayi8FSuvfzlBu7abHVUt%2Fg%2BL142vArHx1BK0%2FPaDeIfWLMZTpPmwzisQ0MNAIiGW"}],"group":"cf-nel","max_age":604800}
NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Server: cloudflare
CF-RAY: 79fb5613ccb039ca-FRA
Content-Encoding: gzip
alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
     httpversion 1.0
     hu_blocking 0
     hu_filecount 1
     hu_port    443
     hu_portSfx
     ignoreredirects 1
     loglevel   4
     path       /del/tabelle-spielplan
     protocol   https
     redirects  0
     timeout    10
     url        https://www.hockeyweb.de/del/tabelle-spielplan
     sslargs:
   OLDREADINGS:
   QUEUE:
   READINGS:
     2023-02-26 19:08:38   goals-1         192 : 125
     2023-02-26 19:08:38   goals-10        152 : 165
     2023-02-26 19:08:38   goals-11        145 : 179
     2023-02-26 19:08:38   goals-12        136 : 142
     2023-02-26 19:08:38   goals-13        146 : 160
     2023-02-26 19:08:38   goals-14        127 : 181
     2023-02-26 19:08:38   goals-15        119 : 210
     2023-02-26 19:08:38   goals-2         171 : 128
     2023-02-26 19:08:38   goals-3         177 : 153
     2023-02-26 19:08:38   goals-4         148 : 128
     2023-02-26 19:08:38   goals-5         145 : 128
     2023-02-26 19:08:38   goals-6         168 : 144
     2023-02-26 19:08:38   goals-7         181 : 148
     2023-02-26 19:08:38   goals-8         144 : 137
     2023-02-26 19:08:38   goals-9         151 : 174
     2023-02-26 19:08:38   matches-1       54
     2023-02-26 19:08:38   matches-10      53
     2023-02-26 19:08:38   matches-11      54
     2023-02-26 19:08:38   matches-12      53
     2023-02-26 19:08:38   matches-13      52
     2023-02-26 19:08:38   matches-14      53
     2023-02-26 19:08:38   matches-15      53
     2023-02-26 19:08:38   matches-2       52
     2023-02-26 19:08:38   matches-3       53
     2023-02-26 19:08:38   matches-4       53
     2023-02-26 19:08:38   matches-5       53
     2023-02-26 19:08:38   matches-6       54
     2023-02-26 19:08:38   matches-7       53
     2023-02-26 19:08:38   matches-8       53
     2023-02-26 19:08:38   matches-9       53
     2023-02-26 21:12:33   name-1          EHC Red Bull München
     2023-02-26 19:08:38   name-10         Löwen Frankfurt
     2023-02-26 19:08:38   name-11         Iserlohn Roosters
     2023-02-26 19:08:38   name-12         Schwenninger Wild Wings
     2023-02-26 19:08:38   name-13         Eisbären Berlin
     2023-02-26 19:08:38   name-14         Augsburger Panther
     2023-02-26 19:08:38   name-15         Bietigheim Steelers
     2023-02-26 19:08:38   name-2          ERC Ingolstadt
     2023-02-26 19:08:38   name-3          Straubing Tigers
     2023-02-26 19:08:38   name-4          Adler Mannheim
     2023-02-26 19:08:38   name-5          Düsseldorfer EG
     2023-02-26 19:08:38   name-6          Grizzlys Wolfsburg
     2023-02-26 19:08:38   name-7          Kölner Haie
     2023-02-26 19:08:38   name-8          Fischtown Pinguins
     2023-02-26 19:08:38   name-9          Nürnberg Ice Tigers
     2023-02-26 19:08:38   points-1        117
     2023-02-26 19:08:38   points-10       74
     2023-02-26 19:08:38   points-11       73
     2023-02-26 19:08:38   points-12       71
     2023-02-26 19:08:38   points-13       68
     2023-02-26 19:08:38   points-14       48
     2023-02-26 19:08:38   points-15       40
     2023-02-26 19:08:38   points-2        97
     2023-02-26 19:08:38   points-3        94
     2023-02-26 19:08:38   points-4        92
     2023-02-26 19:08:38   points-5        89
     2023-02-26 19:08:38   points-6        90
     2023-02-26 19:08:38   points-7        84
     2023-02-26 19:08:38   points-8        81
     2023-02-26 19:08:38   points-9        76
   REQUEST:
     context    reading
     data       
     header     
     ignoreredirects 0
     num        unknown
     retryCount 0
     type       update
     url        https://www.hockeyweb.de/del/tabelle-spielplan
   defptr:
     readingBase:
       goals-1    reading
       goals-10   reading
       goals-11   reading
       goals-12   reading
       goals-13   reading
       goals-14   reading
       goals-15   reading
       goals-2    reading
       goals-3    reading
       goals-4    reading
       goals-5    reading
       goals-6    reading
       goals-7    reading
       goals-8    reading
       goals-9    reading
       matches-1  reading
       matches-10 reading
       matches-11 reading
       matches-12 reading
       matches-13 reading
       matches-14 reading
       matches-15 reading
       matches-2  reading
       matches-3  reading
       matches-4  reading
       matches-5  reading
       matches-6  reading
       matches-7  reading
       matches-8  reading
       matches-9  reading
       name-1     reading
       name-10    reading
       name-11    reading
       name-12    reading
       name-13    reading
       name-14    reading
       name-15    reading
       name-2     reading
       name-3     reading
       name-4     reading
       name-5     reading
       name-6     reading
       name-7     reading
       name-8     reading
       name-9     reading
       points-1   reading
       points-10  reading
       points-11  reading
       points-12  reading
       points-13  reading
       points-14  reading
       points-15  reading
       points-2   reading
       points-3   reading
       points-4   reading
       points-5   reading
       points-6   reading
       points-7   reading
       points-8   reading
       points-9   reading
     readingNum:
       goals-1    04
       goals-10   04
       goals-11   04
       goals-12   04
       goals-13   04
       goals-14   04
       goals-15   04
       goals-2    04
       goals-3    04
       goals-4    04
       goals-5    04
       goals-6    04
       goals-7    04
       goals-8    04
       goals-9    04
       matches-1  02
       matches-10 02
       matches-11 02
       matches-12 02
       matches-13 02
       matches-14 02
       matches-15 02
       matches-2  02
       matches-3  02
       matches-4  02
       matches-5  02
       matches-6  02
       matches-7  02
       matches-8  02
       matches-9  02
       name-1     01
       name-10    01
       name-11    01
       name-12    01
       name-13    01
       name-14    01
       name-15    01
       name-2     01
       name-3     01
       name-4     01
       name-5     01
       name-6     01
       name-7     01
       name-8     01
       name-9     01
       points-1   03
       points-10  03
       points-11  03
       points-12  03
       points-13  03
       points-14  03
       points-15  03
       points-2   03
       points-3   03
       points-4   03
       points-5   03
       points-6   03
       points-7   03
       points-8   03
       points-9   03
     readingOutdated:
     readingSubNum:
       goals-1    -1
       goals-10   -10
       goals-11   -11
       goals-12   -12
       goals-13   -13
       goals-14   -14
       goals-15   -15
       goals-2    -2
       goals-3    -3
       goals-4    -4
       goals-5    -5
       goals-6    -6
       goals-7    -7
       goals-8    -8
       goals-9    -9
       matches-1  -1
       matches-10 -10
       matches-11 -11
       matches-12 -12
       matches-13 -13
       matches-14 -14
       matches-15 -15
       matches-2  -2
       matches-3  -3
       matches-4  -4
       matches-5  -5
       matches-6  -6
       matches-7  -7
       matches-8  -8
       matches-9  -9
       name-1     -1
       name-10    -10
       name-11    -11
       name-12    -12
       name-13    -13
       name-14    -14
       name-15    -15
       name-2     -2
       name-3     -3
       name-4     -4
       name-5     -5
       name-6     -6
       name-7     -7
       name-8     -8
       name-9     -9
       points-1   -1
       points-10  -10
       points-11  -11
       points-12  -12
       points-13  -13
       points-14  -14
       points-15  -15
       points-2   -2
       points-3   -3
       points-4   -4
       points-5   -5
       points-6   -6
       points-7   -7
       points-8   -8
       points-9   -9
     requestReadings:
       update:
         goals-1    reading 04-1
         goals-10   reading 04-10
         goals-11   reading 04-11
         goals-12   reading 04-12
         goals-13   reading 04-13
         goals-14   reading 04-14
         goals-15   reading 04-15
         goals-2    reading 04-2
         goals-3    reading 04-3
         goals-4    reading 04-4
         goals-5    reading 04-5
         goals-6    reading 04-6
         goals-7    reading 04-7
         goals-8    reading 04-8
         goals-9    reading 04-9
         matches-1  reading 02-1
         matches-10 reading 02-10
         matches-11 reading 02-11
         matches-12 reading 02-12
         matches-13 reading 02-13
         matches-14 reading 02-14
         matches-15 reading 02-15
         matches-2  reading 02-2
         matches-3  reading 02-3
         matches-4  reading 02-4
         matches-5  reading 02-5
         matches-6  reading 02-6
         matches-7  reading 02-7
         matches-8  reading 02-8
         matches-9  reading 02-9
         name-1     reading 01-1
         name-10    reading 01-10
         name-11    reading 01-11
         name-12    reading 01-12
         name-13    reading 01-13
         name-14    reading 01-14
         name-15    reading 01-15
         name-2     reading 01-2
         name-3     reading 01-3
         name-4     reading 01-4
         name-5     reading 01-5
         name-6     reading 01-6
         name-7     reading 01-7
         name-8     reading 01-8
         name-9     reading 01-9
         points-1   reading 03-1
         points-10  reading 03-10
         points-11  reading 03-11
         points-12  reading 03-12
         points-13  reading 03-13
         points-14  reading 03-14
         points-15  reading 03-15
         points-2   reading 03-2
         points-3   reading 03-3
         points-4   reading 03-4
         points-5   reading 03-5
         points-6   reading 03-6
         points-7   reading 03-7
         points-8   reading 03-8
         points-9   reading 03-9
Attributes:
   alias      DEL Tabelle
   enableControlSet 1
   event-on-change-reading .*
   event-on-update-reading name-1
   group      Informationen
   icon       Wunderlist
   reading01Name name
   reading01RegOpt g
   reading01Regex \n    <td class="hw-table__team__name">(.*)<\/td>
   reading02Name matches
   reading02RegOpt g
   reading02Regex \n    <td class="hw-table__team__matches">(.*)<\/td>
   reading03Name points
   reading03RegOpt g
   reading03Regex \n    <td class="hw-table__team__points">(.*)<\/td>
   reading04Name goals
   reading04RegOpt g
   reading04Regex \n    <td class="hw-table__team__goals"><span>(.*)<\/span><\/td>
   readingOExpr $val =~ s/<[\d\D]+>//;;$val
   room       Information->Hockey
   stateFormat name-1
   timeout    10
   timestamp-on-change-reading .*