2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-04-07 19:04:20 +00:00

55_DWD_OpenData: contrib 1.17.7

git-svn-id: https://svn.fhem.de/fhem/trunk@29260 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2024-10-18 11:22:45 +00:00
parent a856165b89
commit 039d054c56

View File

@ -910,10 +910,8 @@ sub Attr {
my ($command, $name, $attribute, $value) = @_; my ($command, $name, $attribute, $value) = @_;
my $hash = $::defs{$name}; my $hash = $::defs{$name};
for ($command) { if ($command eq 'set') { # V 1.17.7: change "when" to "if" - https://forum.fhem.de/index.php?msg=1319475
when ("set") { if ($attribute eq "disable") {
for ($attribute) {
when ("disable") {
# enable/disable polling # enable/disable polling
if ($::init_done) { if ($::init_done) {
if ($value) { if ($value) {
@ -925,7 +923,7 @@ sub Attr {
} }
} }
} }
when ("forecastRefresh") { elsif ($attribute eq "forecastRefresh") {
if (!(defined($value) && looks_like_number($value) && $value >= 1 && $value <= 6)) { if (!(defined($value) && looks_like_number($value) && $value >= 1 && $value <= 6)) {
my $oldRefresh = ::AttrVal($name, 'forecastRefresh', 6); my $oldRefresh = ::AttrVal($name, 'forecastRefresh', 6);
if ($::init_done && (($oldRefresh < 6 && $value >= 6) || ($oldRefresh >= 6 && $value < 6))) { if ($::init_done && (($oldRefresh < 6 && $value >= 6) || ($oldRefresh >= 6 && $value < 6))) {
@ -934,7 +932,7 @@ sub Attr {
} }
} }
} }
when ("forecastResolution") { elsif ($attribute eq "forecastResolution") {
if (defined($value) && looks_like_number($value) && $value > 0) { if (defined($value) && looks_like_number($value) && $value > 0) {
my $oldForecastResolution = ::AttrVal($name, 'forecastResolution', 6); my $oldForecastResolution = ::AttrVal($name, 'forecastResolution', 6);
if ($::init_done && defined($oldForecastResolution) && $oldForecastResolution != $value) { if ($::init_done && defined($oldForecastResolution) && $oldForecastResolution != $value) {
@ -944,59 +942,54 @@ sub Attr {
return "invalid value for forecastResolution (possible values are 1, 3 and 6)"; return "invalid value for forecastResolution (possible values are 1, 3 and 6)";
} }
} }
when ("downloadTimeout") { elsif ($attribute eq "downloadTimeout") {
if (!(defined($value) && looks_like_number($value) && $value >= DOWNLOAD_TIMEOUT_MIN && $value <= DOWNLOAD_TIMEOUT_MAX)) { if (!(defined($value) && looks_like_number($value) && $value >= DOWNLOAD_TIMEOUT_MIN && $value <= DOWNLOAD_TIMEOUT_MAX)) {
return "invalid value for downloadTimeout (" . DOWNLOAD_TIMEOUT_MIN . " .. " . DOWNLOAD_TIMEOUT_MAX . ")"; return "invalid value for downloadTimeout (" . DOWNLOAD_TIMEOUT_MIN . " .. " . DOWNLOAD_TIMEOUT_MAX . ")";
} }
} }
when ("forecastStation") { elsif ($attribute eq "forecastStation") {
my $oldForecastStation = ::AttrVal($name, 'forecastStation', undef); my $oldForecastStation = ::AttrVal($name, 'forecastStation', undef);
if ($::init_done && defined($oldForecastStation) && $oldForecastStation ne $value) { if ($::init_done && defined($oldForecastStation) && $oldForecastStation ne $value) {
::CommandDeleteReading(undef, "$name ^fc.*"); ::CommandDeleteReading(undef, "$name ^fc.*");
} }
} }
when ("forecastWW2Text") { elsif ($attribute eq "forecastWW2Text") {
if ($::init_done && !$value) { if ($::init_done && !$value) {
::CommandDeleteReading(undef, "$name ^fc.*wwd\$"); ::CommandDeleteReading(undef, "$name ^fc.*wwd\$");
} }
} }
when ("timezone") { elsif ($attribute eq "timezone") {
if (defined($value) && length($value) > 0) { if (defined($value) && length($value) > 0) {
$hash->{'.TZ'} = $value; $hash->{'.TZ'} = $value;
} else { } else {
return "timezone (e.g. Europe/Berlin) required"; return "timezone (e.g. Europe/Berlin) required";
} }
} }
}
} }
elsif ($command eq 'del') {
when ("del") { if ($attribute eq "disable") {
for ($attribute) {
when ("disable") {
::readingsSingleUpdate($hash, 'state', 'defined', 1); ::readingsSingleUpdate($hash, 'state', 'defined', 1);
::InternalTimer(gettimeofday() + 3, 'DWD_OpenData::Timer', $hash, 0); ::InternalTimer(gettimeofday() + 3, 'DWD_OpenData::Timer', $hash, 0);
} }
when ("forecastResolution") { elsif ($attribute eq "forecastResolution") {
my $oldForecastResolution = ::AttrVal($name, 'forecastResolution', 6); my $oldForecastResolution = ::AttrVal($name, 'forecastResolution', 6);
if ($oldForecastResolution != 6) { if ($oldForecastResolution != 6) {
::CommandDeleteReading(undef, "$name ^fc.*"); ::CommandDeleteReading(undef, "$name ^fc.*");
} }
} }
when ("forecastStation") { elsif ($attribute eq "forecastStation") {
::CommandDeleteReading(undef, "$name ^fc.*"); ::CommandDeleteReading(undef, "$name ^fc.*");
} }
when ("forecastResolution") { elsif ($attribute eq "forecastResolution") {
::CommandDeleteReading(undef, "$name ^fc.*"); ::CommandDeleteReading(undef, "$name ^fc.*");
} }
when ("forecastWW2Text") { elsif ($attribute eq "forecastWW2Text") {
::CommandDeleteReading(undef, "$name ^fc.*wwd\$"); ::CommandDeleteReading(undef, "$name ^fc.*wwd\$");
} }
when ("timezone") { elsif ($attribute eq "timezone") {
$hash->{'.TZ'} = $hash->{FHEM_TZ}; $hash->{'.TZ'} = $hash->{FHEM_TZ};
} }
}
} }
}
return undef; return undef;
} }
@ -3157,6 +3150,9 @@ sub DWD_OpenData_Initialize {
# #
# CHANGES # CHANGES
# #
# 18.10.2024 (version 1.17.7) DS_Starter
# 1.17.7: bugfix: change attr "when" to "if" - https://forum.fhem.de/index.php?msg=1319475
#
# 17.10.2024 (version 1.17.6) DS_Starter # 17.10.2024 (version 1.17.6) DS_Starter
# feature: Timer - quarter 3 # feature: Timer - quarter 3
# #