Show quoted text> Looks like the format Weather Underground shows temperature in my
> have changed recently. Attached is a (not great) patch for
> getting temperature working again.
A little regression in your patch.
You use the same regex for °C and °F so the same value is put in
temperature_celsius and temperature_fahrenheit.
Replace the regex "/(-?([?[0-9]*\.?[0-9]+))/i"
by :
* /(-?([?[0-9]*\.?[0-9]+))°c/i) for celsius
* /(-?([?[0-9]*\.?[0-9]+))°f/i) for fahrenheit
seems to work better
(but I'm not sure that the "°(c|f)" format is always used)
See corrected patch file enclosed.
diff --git a/Weather-Underground-3.02/Underground.pm b/Weather-Underground-3.02/Underground.pm
index 3506d03..f334ce4 100644
--- a/Weather-Underground-3.02/Underground.pm
+++ b/Weather-Underground-3.02/Underground.pm
@@ -443,7 +443,7 @@ sub get_weather {
$ua->timeout($self->{timeout});
}
$oldagent = $ua->agent();
- $ua->agent("Weather::Underground version $VERSION");
+ $ua->agent("curl version $VERSION");
$document = get($self->{_url});
$ua->agent($oldagent);
@@ -763,8 +763,10 @@ sub _state2result {
}
$stateref->{"content_TEMPERATURE"} =~ s/\s//g;
- ($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i);
- ($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i);
+ #($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i);
+ #($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i);
+ ($temperature_celsius) = ($stateref->{"content_TEMPERATURE"} =~ /(-?([?[0-9]*\.?[0-9]+))°c/i);
+ ($temperature_fahrenheit) = ($stateref->{"content_TEMPERATURE"} =~ /(-?([?[0-9]*\.?[0-9]+))°f/i);
if (!length($temperature_celsius) && length($temperature_fahrenheit)) {
$temperature_celsius = ($temperature_fahrenheit - 32) / 1.8;
}
@@ -773,8 +775,10 @@ sub _state2result {
}
$stateref->{"content_DEW_POINT"} =~ s/\s//g;
- ($dewpoint_celsius) = ($stateref->{"content_DEW_POINT"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?c/i);
- ($dewpoint_fahrenheit) = ($stateref->{"content_DEW_POINT"} =~ /(-?(?:\d|\.)+)[^a-z0-9]*?f/i);
+ ($dewpoint_celsius) = ($stateref->{"content_DEW_POINT"} =~ /(-?([?[0-9]*\.?[0-9]+))°c/i);
+
+ ($dewpoint_fahrenheit) = ($stateref->{"content_DEW_POINT"} =~ /(-?([?[0-9]*\.?[0-9]+))°f/i);
+
if (!length($dewpoint_celsius) && length($dewpoint_fahrenheit)) {
$dewpoint_celsius = ($dewpoint_fahrenheit - 32) / 1.8;
}