Hallo zusammen,
nicht lebensnotwendig, aber dennoch..
Habe mir einen Heizoelpreischeck mit HTTPMOD template eingebaut:
set HeizOelCheck attrTemplate fuel_oil_check_heizoel24
Nach dem Start meines FHEM's kommt nun:
2022.12.22 18:03:21 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2920.
2022.12.22 18:03:21 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2923.
2022.12.22 18:03:21 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2926.
Entweder ist das normal, dann passt der LogLevel nicht, oder es liegt doch ein Fehler vor..
Listing:
Internals:
BUSY 0
DEF https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard 43200
FUUID 63a42bcc-f33f-b6d9-6e88-ba25517b62260895
Interval 43200
MainURL https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
ModuleVersion 4.1.14 - 19.8.2022
NAME CheckOelPrice
NOTIFYDEV global
NR 698
NTFY_ORDER 50-CheckOelPrice
STATE <div style="text-align: left;;">2022-12-22 18:03:52: <a href="https://www.heizoel24.de/heizoel/angebotsliste?zipCode=97456&amount=2000&stations=1&product=1" rel="noopener noreferrer" target="_blank" style="font-weight:bold;;">120.37€</a>/100l (2000l = 2407.40€)</div>
TYPE HTTPMOD
eventCount 1
value
CompiledRegexes:
HttpUtils:
NAME
addr https://www.heizoel24.de:443
auth 0
buf
code 200
compress 1
conn
data
displayurl https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=1&oilgrade=standard
header
host www.heizoel24.de
httpheader HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server:
X-Powered-By:
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Date: Thu, 22 Dec 2022 17:03:50 GMT
Connection: close
Content-Length: 314
httpversion 1.0
hu_blocking 0
hu_filecount 1
hu_port 443
hu_portSfx
ignoreredirects 1
loglevel 4
path /DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=1&oilgrade=standard
protocol https
redirects 0
timeout 10
url https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=1&oilgrade=standard
sslargs:
QUEUE:
READINGS:
2022-12-22 18:03:52 Heizoelpreis 120.37
2022-12-22 11:06:24 attrTemplateVersion 20210626
REQUEST:
context reading
data
header
ignoreredirects 0
num unknown
retryCount 0
type update
url https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
defptr:
readingBase:
Heizoelpreis reading
readingNum:
Heizoelpreis 010
readingOutdated:
requestReadings:
update:
Heizoelpreis reading 010
Attributes:
enableControlSet 1
icon euro
model fuel_oil_check_heizoel24_v2
reading010Name Heizoelpreis
reading010OExpr $val =~ s/,/\./; $val;
reading010Regex ([\d\,]+)<\/price
replacement01Mode text
replacement01Regex %%PLZ%%
replacement01Value 97456
replacement02Mode text
replacement02Regex %%MENGE%%
replacement02Value 2000
replacement03Mode text
replacement03Regex %%ENTLADESTELLEN%%
replacement03Value 1
room Tankraum
stateFormat { my $price = 0.0;
$price = (AttrNum($name,"replacement02Value",0)*ReadingsNum($name,"Heizoelpreis",0))/100;
my $lastCheck = ReadingsTimestamp($name,"Heizoelpreis","");
my $ret = "<div style=\"text-align: left;;\">".$lastCheck.":";
my $link = "https://www.heizoel24.de/heizoel/angebotsliste?";
$link .= "zipCode=".AttrVal($name,"replacement01Value","");
$link .= "&amount=".AttrVal($name,"replacement02Value","");
$link .= "&stations=".AttrVal($name,"replacement03Value","");
$link .= "&product=1";
$ret .= " <a href=\"".$link."\" rel=\"noopener noreferrer\" target=\"_blank\" style=\"font-weight:bold;;\">";
$ret .= ReadingsVal($name,"Heizoelpreis","-");
$ret .= "€</a>/100l";
$ret .= " (".AttrVal($name,"replacement02Value","0")."l = ";
$ret .= sprintf("%.2f",$price);
$ret .= "€)</div>";
return $ret;
}
timeout 10
userattr replacement03Value:1,2,3,4,5,6,7,8,9,10
webCmd reread
Mit Stacktrace:
2022.12.22 18:56:54 3: CheckOelPrice: Defined with URL https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard and interval 43200 featurelevel 6.1
2022.12.22 18:56:54 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2920.
2022.12.22 18:56:54 1: stacktrace:
2022.12.22 18:56:54 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 18:56:54 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 18:56:54 1: main::CallFn called by fhem.pl (3198)
2022.12.22 18:56:54 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 18:56:54 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 18:56:54 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 18:56:54 1: main::CommandInclude called by fhem.pl (628)
2022.12.22 18:56:54 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2923.
2022.12.22 18:56:54 1: stacktrace:
2022.12.22 18:56:54 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 18:56:54 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 18:56:54 1: main::CallFn called by fhem.pl (3198)
2022.12.22 18:56:54 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 18:56:54 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 18:56:54 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 18:56:54 1: main::CommandInclude called by fhem.pl (628)
2022.12.22 18:56:54 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2926.
2022.12.22 18:56:54 1: stacktrace:
2022.12.22 18:56:54 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 18:56:54 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 18:56:54 1: main::CallFn called by fhem.pl (3198)
2022.12.22 18:56:54 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 18:56:54 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 18:56:54 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 18:56:54 1: main::CommandInclude called by fhem.pl (628)
Im Voraus Vielen Dank
Klaus
setze für das device mal verbose 5, dann sollte man im Log sehen, was HTTPMOD an der Stelle versucht, zu tun
Log Auszug mit verbose 5:
2022.12.22 20:07:01 3: CheckOelPrice: Defined with URL https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard and interval 43200 featurelevel 6.1
2022.12.22 20:07:01 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2920.
2022.12.22 20:07:01 1: stacktrace:
2022.12.22 20:07:01 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 20:07:01 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 20:07:01 1: main::CallFn called by fhem.pl (3198)
2022.12.22 20:07:01 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 20:07:01 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 20:07:01 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 20:07:01 1: main::CommandInclude called by fhem.pl (628)
2022.12.22 20:07:01 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2923.
2022.12.22 20:07:01 1: stacktrace:
2022.12.22 20:07:01 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 20:07:01 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 20:07:01 1: main::CallFn called by fhem.pl (3198)
2022.12.22 20:07:01 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 20:07:01 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 20:07:01 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 20:07:01 1: main::CommandInclude called by fhem.pl (628)
2022.12.22 20:07:01 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 512, <$fh> line 2926.
2022.12.22 20:07:01 1: stacktrace:
2022.12.22 20:07:01 1: main::__ANON__ called by ./FHEM/98_HTTPMOD.pm (512)
2022.12.22 20:07:01 1: HTTPMOD::AttrFn called by fhem.pl (3976)
2022.12.22 20:07:01 1: main::CallFn called by fhem.pl (3198)
2022.12.22 20:07:01 1: main::CommandAttr called by fhem.pl (1276)
2022.12.22 20:07:01 1: main::AnalyzeCommand called by fhem.pl (1127)
2022.12.22 20:07:01 1: main::AnalyzeCommandChain called by fhem.pl (1415)
2022.12.22 20:07:01 1: main::CommandInclude called by fhem.pl (628)
2022.12.22 20:07:01 5: CheckOelPrice: attr CheckOelPrice webCmd reread
2022.12.22 20:07:02 1: Including ./log/fhem.save
2022.12.22 20:07:05 3: Opening HMUART1 device /dev/ttyAMA0
2022.12.22 20:07:05 3: Setting HMUART1 serial parameters to 115200,8,N,1
2022.12.22 20:07:05 3: HMUART1 device opened
2022.12.22 20:07:05 3: Opening HMUART2 device 192.168.1.5:23
2022.12.22 20:07:05 3: Opening HMUART3 device 192.168.1.17:23
2022.12.22 20:07:23 3: Opening SolvisBen device 192.168.1.21:502
2022.12.22 20:07:23 0: Featurelevel: 6.1
2022.12.22 20:07:23 0: Server started with 622 defined entities (fhem.pl:26775/2022-12-04 perl:5.032001 os:linux user:fhem pid:11795)
2022.12.22 20:07:26 4: CheckOelPrice: GetUpdate called (update)
2022.12.22 20:07:26 4: CheckOelPrice: UpdateTimer called from GetUpdate with cmd next sets timer to call update function in 43200.0 sec at 08:07:26.629, interval 43200
2022.12.22 20:07:26 5: CheckOelPrice: AddToQueue adds type update to URL https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard, no data, no headers, retry 0, initial queue len: 0
2022.12.22 20:07:26 5: CheckOelPrice: HandleSendQueue called from AddToSendQueue, qlen = 1
2022.12.22 20:07:26 5: CheckOelPrice: Replace called for type update, regex (?^:%%PLZ%%), mode text, value 97456 input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
2022.12.22 20:07:26 5: CheckOelPrice: Replace: match for type update, regex (?^:%%PLZ%%), mode text, value 97456, input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard, result is https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
2022.12.22 20:07:26 5: CheckOelPrice: Replace called for type update, regex (?^:%%MENGE%%), mode text, value 2000 input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
2022.12.22 20:07:26 5: CheckOelPrice: Replace: match for type update, regex (?^:%%MENGE%%), mode text, value 2000, input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard, result is https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
2022.12.22 20:07:26 5: CheckOelPrice: Replace called for type update, regex (?^:%%ENTLADESTELLEN%%), mode text, value 1 input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard
2022.12.22 20:07:26 5: CheckOelPrice: Replace: match for type update, regex (?^:%%ENTLADESTELLEN%%), mode text, value 1, input: https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=%%PLZ%%&litre=%%MENGE%%&unloadingpoints=%%ENTLADESTELLEN%%&oilgrade=standard, result is https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=1&oilgrade=standard
2022.12.22 20:07:26 4: CheckOelPrice: HandleSendQueue sends update with timeout 10 to https://www.heizoel24.de/DailyPriceXml.ashx?zipcode=97456&litre=2000&unloadingpoints=1&oilgrade=standard, No Data, No Header
2022.12.22 20:07:27 3: HMUART2 device opened
2022.12.22 20:07:27 3: SolvisBen device opened
2022.12.22 20:07:27 3: HMUART3 device opened
2022.12.22 20:07:30 5: CheckOelPrice: ReadCallback called from __ANON__
2022.12.22 20:07:30 4: CheckOelPrice: Read callback: request type was update retry 0,
header: HTTP/1.1 200 OK
Cache-Control: private
Content-Type: text/xml; charset=utf-8
Server:
X-Powered-By:
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Date: Thu, 22 Dec 2022 19:07:30 GMT
Connection: close
Content-Length: 314, body length 314
2022.12.22 20:07:30 5: CheckOelPrice: Read callback: body
<?xml version="1.0" encoding="utf-8"?><result><plz>97456</plz><taxRate>19</taxRate><deliveries><delivery unloadingPoints="1" litre="2000"><price oilGrade="Heizöl Standard Schwefelarm" orderLink="https://www.heizoel24.de/bestellung/97456/1/2000/1/5,11,6,9,24/120,37">120,37</price></delivery></deliveries></result>
2022.12.22 20:07:30 4: CheckOelPrice: BodyDecode is not decoding the response body (charset utf-8, bodyDecode defaults to none)
2022.12.22 20:07:30 5: CheckOelPrice: GetCookies is looking for Cookies
2022.12.22 20:07:30 5: CheckOelPrice: ExtractSid called, context reading, num unknown
2022.12.22 20:07:30 4: CheckOelPrice: checking for redirects, code=200, ignore=0
2022.12.22 20:07:30 4: CheckOelPrice: no redirects to handle
2022.12.22 20:07:30 5: CheckOelPrice: Read callback sets LAST_REQUEST to update
2022.12.22 20:07:30 5: CheckOelPrice: CheckAuth decided no authentication required
2022.12.22 20:07:30 5: CheckOelPrice: UpdateReadingList created list of reading.* nums to parse during getUpdate as 010
2022.12.22 20:07:30 5: CheckOelPrice: Read starts parsing response to update with defined readings: 010
2022.12.22 20:07:30 5: CheckOelPrice: ExtractReading Heizoelpreis with regex /(?^:([\d\,]+)<\/price)/...
2022.12.22 20:07:30 5: CheckOelPrice: perl expression eval evaluated package main; my $timeDiff = $oRef->{'$timeDiff'};$val =~ s/,/\./; $val; to 120.37
2022.12.22 20:07:30 5: CheckOelPrice: ExtractReading for reading010-1 sets Heizoelpreis to 120.37
2022.12.22 20:07:30 5: CheckOelPrice: ExtractReading value as hex is 3132302e3337
2022.12.22 20:07:30 4: CheckOelPrice: Read response matched 1, unmatch 0 Reading(s)
2022.12.22 20:07:30 5: CheckOelPrice: Read response to update matched Heizoelpreis
2022.12.22 20:07:30 5: CheckOelPrice: HandleSendQueue called from ReadCallback, qlen = 0
2022.12.22 20:07:30 5: CheckOelPrice: HandleSendQueue found no usable entry in queue
2022.12.22 20:07:56 3: ZWave got config for fibaro/fgfs101zw5.xml from ./FHEM/lib/openzwave_deviceconfig.xml.gz
2022.12.22 20:07:57 2: AttrTemplates: got 254 entries
2022.12.22 20:08:02 3: ZWave got config for fibaro/fgcd001.xml from ./FHEM/lib/openzwave_deviceconfig.xml.gz
2022.12.22 20:08:08 3: ZWave got config for fibaro/fgwpfzw5.xml from ./FHEM/lib/openzwave_deviceconfig.xml.gz
Da das Template (wahrscheinlich) (mit) von mir beeinflusst ist, vermute ich den Grund des Warnings im stateFormat:
stateFormat { my $price = 0.0;
$price = (AttrNum($name,"replacement02Value",0)*ReadingsNum($name,"Heizoelpreis",0))/100;
my $lastCheck = ReadingsTimestamp($name,"Heizoelpreis","");
my $ret = "<div style=\"text-align: left;;\">".$lastCheck.":";
my $link = "https://www.heizoel24.de/heizoel/angebotsliste?";
$link .= "zipCode=".AttrVal($name,"replacement01Value","");
$link .= "&amount=".AttrVal($name,"replacement02Value","");
$link .= "&stations=".AttrVal($name,"replacement03Value","");
$link .= "&product=1";
$ret .= " <a href=\"".$link."\" rel=\"noopener noreferrer\" target=\"_blank\" style=\"font-weight:bold;;\">";
$ret .= ReadingsVal($name,"Heizoelpreis","-");
$ret .= "€</a>/100l";
$ret .= " (".AttrVal($name,"replacement02Value","0")."l = ";
$ret .= sprintf("%.2f",$price);
$ret .= "€)</div>";
return $ret;
}
Aber als perl-noob :-\ ist mir nicht schlüssig, was hier
uninitialized value $2 in concatenation (.) or string
die Ursache sein könnte. Oder es liegt am DEF.
Heißt jetzt was ?
Push
Die Warnung tritt im Zusammenhang mit einem replacementXXValue auf.
Das Einzige, das mir dazu in Deinem device auffällt: Warum gibt es das Attribut replacement03Value einmal als "normales" Attribut und einmal als userattr?
Laut Doku kann man replacement values folgendermaßen definieren:
- replacement[0-9]*Value
- (get|set)[0-9]*Replacement[0-9]*Value
Im 98_HTTPMOD.pm wird folgendermaßen die hintere Zahl ermittelt:
510 elsif ($aName =~ /((get|set)[0-9]*)?[Rr]eplacement([0-9]*)Value/) {
Problem: die hintere Zahl ist jedoch nicht $2, sondern $3
"Entschärft" man das (get|set), so ist die hintere Zahl $2
510 elsif ($aName =~ /((?:get|set)[0-9]*)?[Rr]eplacement([0-9]*)Value/) {
$2 oder $3 wären so oder so ähnlich möglich, aber nicht ohne Moduländerung ... $1 natürlich ebenfalls, da die vordere Zahl hier eigentlich keinerlei Bedeutung hätte.
***
userattr wird z.B. genutzt, wenn es um ein "eigentlich noch nicht vorhandenes" Attribut geht
... HTTPMOD stellt oft nur Schablonen als Attribut bereit
... Grund wird hier sein, dass man nur mögliche Werte für ein Attribut vorgeben will
Danke für die Info, und danke für die Verlinkung....
https://forum.fhem.de/index.php/topic,45176.msg1257506.html#msg1257506
(https://forum.fhem.de/index.php/topic,45176.msg1257506.html#msg1257506)
Ich habe gerade mal einen Test mit der neuen 98_HTTPMOD.pm von heute gemacht:
# $Id: 98_HTTPMOD.pm 27050 2023-01-14 11:32:01Z StefanStrobel $
Zeile 515:
if (AttrVal($name, "replacement${3}Mode", "text") eq "expression") {
Leider immer noch die Warnings:
2023.01.14 13:30:14 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 514, <$fh> line 2941.
2023.01.14 13:30:14 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 514, <$fh> line 2944.
2023.01.14 13:30:14 1: PERL WARNING: Use of uninitialized value $2 in concatenation (.) or string at ./FHEM/98_HTTPMOD.pm line 514, <$fh> line 2947.
Oder muss ich noch was ändern ?
Ich habe jetzt auch noch die Zeile 514 von:
Log3 $name, 5, "$name: validating attr $name $aName $aVal, check for replacement${2}Mode";
nach:
Log3 $name, 5, "$name: validating attr $name $aName $aVal, check for replacement${3}Mode";
geändert. Jetzt passt alles .., zumindest gibts keine Fehlermeldungen mehr.