Abfrage Heizölpreis HTTPMOD

Begonnen von subseven, 09 Januar 2020, 16:51:01

Vorheriges Thema - Nächstes Thema

sash.sc

Ich möchte ja nicht Heizöl anfragen, sondern dad Rohöl.
Raspi 4B+ Bullseye ;LaCrosse; HomeMatic; MapleCUL; ZigBee; Signalduino ESP32 ; Shellys; MQTT2; Grafana mit Influxdb

TomLee

Ok, sry dafür, bin nur halb dabei und immer noch am essen.

Und am Template orientieren geht auch nicht ?

sash.sc

Raspi 4B+ Bullseye ;LaCrosse; HomeMatic; MapleCUL; ZigBee; Signalduino ESP32 ; Shellys; MQTT2; Grafana mit Influxdb

TomLee

Wenns net unbedingt esyoil sein muss:

defmod Brent HTTPMOD https://www.finanzen.net/rohstoffe/oelpreis/euro
attr Brent reading01Name Brent
attr Brent reading01Regex Brent:[\w\W\n]*?(\d+\,\d+)

sash.sc

Raspi 4B+ Bullseye ;LaCrosse; HomeMatic; MapleCUL; ZigBee; Signalduino ESP32 ; Shellys; MQTT2; Grafana mit Influxdb

TomLee

Zitat von: sash.sc am 02 September 2022, 21:55:46
Danke

... reich ich einfach mal so weiter. An die Person die mich erst auf das Verständnis des "Ausdruck", irgendwo hier in einem anderen Beitrag im Forum, gebracht hat.

sash.sc

#96
@TomLee

Habe es jetzt mal umgesetzt. Läuft auch. Habe nur das Problem mit den komma. Influxdb klappt das wohl so nicht.
Kann man das komma durch einen Punkt ersetzen?

Gruß Sascha
Raspi 4B+ Bullseye ;LaCrosse; HomeMatic; MapleCUL; ZigBee; Signalduino ESP32 ; Shellys; MQTT2; Grafana mit Influxdb

TomLee

Für die Kommandozeile:

attr Brent reading01OExpr $val =~ s/\,/./g;; return $val;;

Bartimaus

Zitat von: TomLee am 01 September 2022, 22:09:37
Wenns net unbedingt esyoil sein muss:

defmod Brent HTTPMOD https://www.finanzen.net/rohstoffe/oelpreis/euro
attr Brent reading01Name Brent
attr Brent reading01Regex Brent:[\w\W\n]*?(\d+\,\d+)


Hi,

mit dieser Abfrage hat das bis Dezember 2022 noch funktioniert.
Da die Seite per se noch funktioniert, müsste wahrscheinlich das Regex angepasst werden....

Wärst Du bitte mal so nett das zu prüfen ? Ich steh mit Regex auf dem Kriegsfuss
LG
B.


FHEM@Intel-J4105@Debian-LXC, CUL1101,FS20,IT,DS18B20,DS2413(Heizungslogger),DS2423(Stromlogger)Homematic,HM-LAN,ZWave,MiniCULs,Shelly

TomLee

 ;D Lustig, als ob ich einen Plan von Regexp hätte..

Keine Ahnung wie der Quelltext vorher war, den Ausdruck würd ich mir jetzt selbst so anpassen:

defmod Brent HTTPMOD https://www.finanzen.net/rohstoffe/oelpreis/euro
attr Brent reading01Name Brent
attr Brent reading01Regex snapshot-value-fst-current-0[\w\W\n]*?(\d+\,\d+)


Der Ausdruck sollte eigentlich greifen es werden aber keine Readings geschrieben, darum hab ich mal auf verbose 5 gestellt und sehe das im Log:

2023.02.03 17:01:10 5: Brent: set called with reread
2023.02.03 17:01:10 4: Brent: GetUpdate called (reread)
2023.02.03 17:01:10 5: Brent: AddToQueue adds type update to URL https://www.finanzen.net/rohstoffe/oelpreis/euro, no data, no headers, retry 0, initial queue len: 0
2023.02.03 17:01:10 5: Brent: HandleSendQueue called from AddToSendQueue, qlen = 1
2023.02.03 17:01:10 4: Brent: HandleSendQueue sends update with timeout 2 to https://www.finanzen.net/rohstoffe/oelpreis/euro, No Data, No Header
2023.02.03 17:01:11 5: Brent: ReadCallback called from __ANON__
2023.02.03 17:01:11 4: Brent: Read callback: request type was update retry 0,
header: HTTP/1.0 403 Forbidden
Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 297
Expires: Fri, 03 Feb 2023 16:01:11 GMT
Date: Fri, 03 Feb 2023 16:01:11 GMT
Connection: close, body length 297
2023.02.03 17:01:11 5: Brent: Read callback: body
<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http://www.finanzen.net/rohstoffe/oelpreis/euro" on this server.<P>
Reference #18.546656b8.1675440071.74c1ed22
</BODY>
</HTML>

2023.02.03 17:01:11 4: Brent: BodyDecode is not decoding the response body (charset not found, bodyDecode defaults to none)
2023.02.03 17:01:11 5: Brent: GetCookies is looking for Cookies
2023.02.03 17:01:11 5: Brent: ExtractSid called, context reading, num unknown
2023.02.03 17:01:11 4: Brent: checking for redirects, code=403, ignore=0
2023.02.03 17:01:11 4: Brent: no redirects to handle
2023.02.03 17:01:11 5: Brent: Read callback sets LAST_REQUEST to update
2023.02.03 17:01:11 5: Brent: CheckAuth decided no authentication required
2023.02.03 17:01:11 5: Brent: Read starts parsing response to update with defined readings: 01
2023.02.03 17:01:11 5: Brent: ExtractReading Brent with regex /(?^:snapshot-value-fst-current-0[\w\W\n]*?(\d+\,\d+))/...
2023.02.03 17:01:11 5: Brent: ExtractReading Brent did not match
2023.02.03 17:01:11 4: Brent: Read response to update didn't match any Reading
2023.02.03 17:01:11 5: Brent: HandleSendQueue called from ReadCallback, qlen = 0
2023.02.03 17:01:11 5: Brent: HandleSendQueue found no usable entry in queue


Ich hab keine Ahnung warum es zu diesem You don't have permission to access kommt.

TomLee

#100
Da keiner was dazu bisher gesagt hat, hier eine Alternative den Wert bei ariva.de auszulesen.

defmod Brent HTTPMOD https://www.ariva.de/brent_crude_rohoel_ice_rolling-kurs 1200
attr Brent reading01Name Brent
attr Brent reading01OExpr $val =~ s/\,/./g;; return $val;;
attr Brent reading01Regex In.Euro</a>:.[\w\W\n]*?(\d+\,\d+)

sash.sc

Da fragst du aber den Rohöl Preis ab. Der dürfte sich zum Heizöl unterscheiden
Raspi 4B+ Bullseye ;LaCrosse; HomeMatic; MapleCUL; ZigBee; Signalduino ESP32 ; Shellys; MQTT2; Grafana mit Influxdb

TomLee

Ist zwar hier OT, aber nach dem Rohölpreis hat Bartimaus doch auch gefragt ?

Bartimaus

Erstmal Danke an @TomLee für den neuen Link/Regex !

@sash.sc ,

das ist korrekt, den Heizölpreis frage ich separat über Check24 ab...

LG
B.


FHEM@Intel-J4105@Debian-LXC, CUL1101,FS20,IT,DS18B20,DS2413(Heizungslogger),DS2423(Stromlogger)Homematic,HM-LAN,ZWave,MiniCULs,Shelly

cotecmania

Hallo,

gibt es ein aktuelles funktionierendes Template für Heizöl ?

Gruss
Joe
FHEM auf RaspberryPI B (buster)
2xCUL868 für MAX/Slow_RF, HM-LAN, JeeLink
MAX!/HM-Thermostate, FS20/HM-Rolladenschalter, FS20-EM, LevelJet-Ölstandsmessung, PCA301, IT, KM271, IPCAM, FireTAB10 FTUI