From b7e097d252d1eb7ae491de482ae94755e9962da3 Mon Sep 17 00:00:00 2001 From: "Ch. Damsky" Date: Fri, 3 Nov 2023 11:40:24 +0100 Subject: [PATCH] v1.40 --- NetatmoWeatherDevice/module.php | 44 ++++++++++++++++++++++++--------- README.md | 1 + library.json | 2 +- libs/CommonStubs | 2 +- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/NetatmoWeatherDevice/module.php b/NetatmoWeatherDevice/module.php index f918faa..4a8e23a 100644 --- a/NetatmoWeatherDevice/module.php +++ b/NetatmoWeatherDevice/module.php @@ -1008,8 +1008,8 @@ private function update_Wunderground($netatmo, $device) } // Messwerte für Wunderground bereitstellen + $last_measure = 0; $pressure = ''; - $time_utc = ''; $temp = ''; $humidity = ''; $rain = ''; @@ -1027,8 +1027,14 @@ private function update_Wunderground($netatmo, $device) return; } + if (isset($dashboard['time_utc'])) { + $last_measure = $dashboard['time_utc']; + } else { + $last_measure = time(); + $this->SendDebug(__FUNCTION__, 'missing "time_utc", use current timestamp', 0); + } + $pressure = $this->GetArrayElem($dashboard, 'AbsolutePressure', 0); - $time_utc = $dashboard['time_utc']; $modules = $this->GetArrayElem($device, 'modules', ''); if ($modules == '') { @@ -1066,7 +1072,7 @@ private function update_Wunderground($netatmo, $device) } } - $param = '&dateutc=' . rawurlencode(date('Y-m-d G:i:s', $time_utc)); + $param = '&dateutc=' . rawurlencode(date('Y-m-d G:i:s', $last_measure)); if ($temp > 0) { $param .= '&tempf=' . rawurlencode($this->celsius2farenheit($temp)); } @@ -1205,7 +1211,12 @@ private function eval_Station($netatmo, $device) return $statuscode; } - $last_measure = $dashboard['time_utc']; + if (isset($dashboard['time_utc'])) { + $last_measure = $dashboard['time_utc']; + } else { + $last_measure = time(); + $this->SendDebug(__FUNCTION__, 'missing "time_utc", use current timestamp', 0); + } // letzte Kommunikation der Station mit Netatmo $last_contact = $device['last_status_store']; @@ -1269,7 +1280,12 @@ private function eval_Station($netatmo, $device) if (isset($module['dashboard_data'])) { $dashboard = $module['dashboard_data']; - $last_measure = $dashboard['time_utc']; + if (isset($dashboard['time_utc'])) { + $last_measure = $dashboard['time_utc']; + } else { + $last_measure = time(); + $this->SendDebug(__FUNCTION__, 'missing "time_utc", use current timestamp', 0); + } } else { $last_measure = 0; } @@ -1374,7 +1390,12 @@ private function eval_NAMain($netatmo, $device) $temp_trend = $this->GetArrayElem($dashboard, 'temp_trend', ''); $pressure_trend = $this->GetArrayElem($dashboard, 'pressure_trend', ''); - $last_measure = $dashboard['time_utc']; + if (isset($dashboard['time_utc'])) { + $last_measure = $dashboard['time_utc']; + } else { + $last_measure = time(); + $this->SendDebug(__FUNCTION__, 'missing "time_utc", use current timestamp', 0); + } $msg = "base-module \"$module_name\": Temperature=$Temperature, CO2=$CO2, Humidity=$Humidity, Noise=$Noise, Pressure=$Pressure, AbsolutePressure=$AbsolutePressure"; $this->SendDebug(__FUNCTION__, $msg, 0); @@ -1488,13 +1509,12 @@ private function eval_NAModule($netatmo, $device) break; } - if (isset($dashboard['time_utc']) == false) { - $msg = "instance $this->InstanceID: defect dasboard=" . print_r($dashboard, true); - $this->LogMessage($msg, KL_NOTIFY); - $this->SendDebug(__FUNCTION__, $msg, 0); + if (isset($dashboard['time_utc'])) { + $last_measure = $dashboard['time_utc']; + } else { + $last_measure = time(); + $this->SendDebug(__FUNCTION__, 'missing "time_utc", use current timestamp', 0); } - - $last_measure = $dashboard['time_utc']; if ($with_last_measure) { $this->SetValue('LastMeasure', $last_measure); } diff --git a/README.md b/README.md index cd8728b..0fcbdbd 100644 --- a/README.md +++ b/README.md @@ -427,6 +427,7 @@ GUIDs - 1.40 @ 15.10.2023 13:51 - Neu: Ermittlung von Speicherbedarf und Laufzeit (aktuell und für 31 Tage) und Anzeige im Panel "Information" - Fix: die Statistik der ApiCalls wird nicht mehr nach uri sondern nur noch host+cmd differenziert + - Fix: Fehler abgefangen, das unter unklaren Umständen "time_utc" manchmal nicht übermittelt wird - update submodule CommonStubs - 1.39 @ 15.08.2023 10:03 diff --git a/library.json b/library.json index 7915220..aa4a60b 100644 --- a/library.json +++ b/library.json @@ -8,5 +8,5 @@ }, "version": "1.40", "build": 0, - "date": 1697370675 + "date": 1699005477 } diff --git a/libs/CommonStubs b/libs/CommonStubs index eed2055..0e6bad7 160000 --- a/libs/CommonStubs +++ b/libs/CommonStubs @@ -1 +1 @@ -Subproject commit eed205506110e614f6895d771f814d6d682aa471 +Subproject commit 0e6bad718400d532832999a423cde853496ce1c9