From 7c5385d006fe6bcc847a09cf7032ba155ddd7352 Mon Sep 17 00:00:00 2001 From: Vincent Date: Tue, 31 Dec 2019 11:21:27 +0100 Subject: [PATCH] . --- .idea/workspace.xml | 29 +++++++++++++++-------------- scripts/cron/cron.php | 4 ++++ scripts/domoticz_status.php | 2 +- scripts/lib/domoticz.php | 9 ++++++++- scripts/lib/weatherstation.php | 3 ++- 5 files changed, 30 insertions(+), 17 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b698364..4834f42 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,9 +2,10 @@ - - + + + @@ -1184,12 +1185,12 @@ - - + + - + diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index edefe84..766a6fd 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -143,6 +143,9 @@ function cronSqueezeFavorites($cronmin) function toNumber($val, $round = false) { + if ($val === false) { + return '--'; + } $val = preg_replace('/[^0-9-.]/', '', $val); $val = floatval($val); if ($round) { @@ -170,6 +173,7 @@ function cronWeather($cronmin) $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(1032), true); $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(1025), true); $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(1026), true); + $res['backyard_pressure'] = toNumber(getDomoticzDeviceStatus(1027), true); $res['pressure'] = round($weather['Pressure']['Metric']['Value']); $res['pressureTendency'] = $weather['PressureTendency']['Code']; $res['precipitations24'] = round($weather['PrecipitationSummary']['Past24Hours']['Metric']['Value']); diff --git a/scripts/domoticz_status.php b/scripts/domoticz_status.php index 97c6ff6..222bc2a 100644 --- a/scripts/domoticz_status.php +++ b/scripts/domoticz_status.php @@ -1,4 +1,4 @@ 'devices', 'rid' => $device]); $res = json_decode($res->getBody(), true); - + try { + $update = new DateTime($res['result'][0]['LastUpdate']); + $now = new DateTime(); + if ($update->diff($now)->days > 0) { + return false; + } + } catch (Exception $e) { + } return $res['result'][0]['Data']; } diff --git a/scripts/lib/weatherstation.php b/scripts/lib/weatherstation.php index 50df817..3482c0d 100644 --- a/scripts/lib/weatherstation.php +++ b/scripts/lib/weatherstation.php @@ -4,6 +4,7 @@ function weatherStationScreenSaver() $weather = json_decode(file_get_contents(ROOT . '/cache/weather.json'), true); $pressureTendency = $weather['pressureTendency'] == 'F' ? 'down' : 'up'; + $pressure = $weather['outdoor_pressure'] == '--' ? $weather['backyard_pressure'] : $weather['outdoor_pressure']; $res = '
'; $res .= '
'; @@ -19,7 +20,7 @@ function weatherStationScreenSaver() $res .= '
' . $weather['max'] . '°C
'; $res .= '
'; $res .= '
'; - $res .= ' ' . $weather['precipitations24'] . ' mm | ' . $weather['backyard_pressure'] . ' hPa | ' . $weather['outdoor_humidity'] . '%
'; + $res .= ' ' . $weather['precipitations24'] . ' mm | ' . $pressure . ' hPa | ' . $weather['outdoor_humidity'] . '%
'; $res .= '
' . $weather['backyard_temp'] . ' °C | ' . $weather['backyard_humidity'] . '%'; $res .= '
'; $res .= ''; -- 2.39.5