Hauptmenü

Parsen

Begonnen von LotharRappsilber, 30 Oktober 2023, 14:51:39

Vorheriges Thema - Nächstes Thema

TomLee

#15
Hier mal ein Beispiel was ich mir gebastelt hab, hat aber auch Optimierungspotential.
Du müsstest nur TYPE=HTTPMOD:number,quote:r2 anpassen:
defmod rg_Boerse readingsGroup TYPE=HTTPMOD:number,quote:r2,percent,win\
<hr>\
rg_Boerse:$sum(:1)@SU,<>,<>,$sum(:4)@SUM\
<hr>
attr rg_Boerse alwaysTrigger 2
attr rg_Boerse noheading 1
attr rg_Boerse nolinks 1
attr rg_Boerse room Boerse->Aktien
attr rg_Boerse valueFormat {"number" => '%.0f',"quote" => '%.2f', "percent" => '%.2f' , "win" => '%.2f',"SUM" => '%.2f' }
attr rg_Boerse valueStyle style="text-align:right"
attr rg_Boerse valueSuffix { "quote" => '&#8364;;&nbsp', "percent" => '&nbsp;;&#037;;&nbsp;;' }

setstate rg_Boerse 2023-10-31 15:59:58 SUM x.x

LotharRappsilber

versteh ich leider nicht! Mein Code sieht folgendermaßen aus, am Beispiel von Adidas:

define Aktie_Adidas HTTPMOD https://www.boerse.de/aktien/Adidas-Aktie/DE000A1EWWW0 300
setuuid Aktie_Adidas 653fe35c-f33f-9284-5f78-84a811e0fa148801
attr Aktie_Adidas alias Adidas
attr Aktie_Adidas reading01Name Kurs
attr Aktie_Adidas reading01OExpr $val =~ s/\,/./g;; $val
attr Aktie_Adidas reading01Regex content="(\d+\.\d+)"
attr Aktie_Adidas reading02Name Prozent
attr Aktie_Adidas reading02OExpr $val =~ s/\,/./g;; $val
attr Aktie_Adidas reading02Regex .*data-sign="">(-?\d+\,\d+).*?%<\/span>
attr Aktie_Adidas room Boerse
attr Aktie_Adidas stateFormat Kurs, Prozent
attr Aktie_Adidas timeout 5
FB 7590, FHEM, 1xCCU2, 6xDECT200, 1xDECT201, 1xHMIP-SWO-PL, 1xHMIP-PS, 1xDECT301,  2xHM-LC-Sw1-PL