From: Vincent Date: Wed, 20 Nov 2019 09:41:51 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=8dc2c7d75ba40e3c8d8bbe28fa54b5b3163344ab;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 8d9c643..3357e50 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,10 +2,12 @@ + + - - + + diff --git a/js/home.js b/js/home.js index f1896cd..b0b45b2 100644 --- a/js/home.js +++ b/js/home.js @@ -682,7 +682,7 @@ function updateWeather() { w.find('.icon-day').html(''); w.find('.icon-night').html(''); w.find('.temp-max').text(data.max + '°C'); - w.find('.temp').text(data.temp + '°C'); + w.find('.temp').text(data.outdoor_temp + '°C'); w.attr('data-init', 1); resize(); }); diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index 692d60a..cd5d682 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -11,10 +11,10 @@ function cronOneLoop($cronmin) if ($cronmin % 5 == 0) { cronTraffic($cronmin, false); cronVelib($cronmin); + cronWeather($cronmin); cronBackyard($cronmin); } if ($cronmin % 10 == 0) { - cronWeather($cronmin); cronSqueezeFavorites($cronmin); } @@ -135,9 +135,18 @@ function cronSqueezeFavorites($cronmin) } } -function cronWeather($cronmin) +function toNumber($val, $round = false) { + $val = preg_replace('/[^0-9-.]/', '', $val); + $val = floatval($val); + if ($round) { + $val = round($val); + } + return $val; +} +function cronWeather($cronmin) +{ $place = 2608449; $cache = ROOT . '/cache/accuweather.json'; @@ -150,6 +159,11 @@ function cronWeather($cronmin) $weather = json_decode(file_get_contents($cache), true); $weather = $weather[0]; $res['temp'] = round(($weather['Temperature']['Metric']['Value']/* + getState('airtemperature')*/)); + $res['outdoor_temp'] = toNumber(getDomoticzDeviceStatus(12, 'zigate'),true); + $res['outdoor_humidity'] = toNumber(getDomoticzDeviceStatus(13, 'zigate'),true); + $res['outdoor_pressure'] = toNumber(getDomoticzDeviceStatus(14, 'zigate'),true); + $res['backyard_temp'] = toNumber(getDomoticzDeviceStatus(5, 'zigate'),true); + $res['backyard_humidity'] = toNumber(getDomoticzDeviceStatus(6, 'zigate'),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 new file mode 100644 index 0000000..97c6ff6 --- /dev/null +++ b/scripts/domoticz_status.php @@ -0,0 +1,4 @@ + 'command', 'passcode' => '']; $params = array_merge($default, $params); - return httpRequest('http://192.168.13.60:8084/json.htm', 'GET', $params); + if ($params['hardware'] == 'rflink') { + $ip = '192.168.13.60'; + } else if ($params['hardware'] == 'zigate') { + $ip = '192.168.13.68'; + } + unset($params['hardware']); + + return httpRequest('http://' . $ip . ':8084/json.htm', 'GET', $params); } -function domoticzSwitch($device, $cmd, $type = 'light', $priority = false) +function domoticzSwitch($device, $cmd, $type = 'light', $priority = false, $hardware = 'rflink') { - return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0'], $priority); + return domoticzCmd(['idx' => $device, 'switchcmd' => $cmd ? 'On' : 'Off', 'param' => 'switch' . $type, 'level' => '0', 'hardware' => $hardware], $priority); } function domoticzCmd($command, $priority = false) @@ -21,11 +28,20 @@ function domoticzCmd($command, $priority = false) if (!is_array($queue)) { $queue = []; } - if($priority){ - array_unshift($queue,$command); - }else{ - array_push($queue,$command); + if ($priority) { + array_unshift($queue, $command); + } else { + array_push($queue, $command); } $redis->igbset($queue_name, $queue); $redis->publish('domoticz_event', 'handle_queue'); -} \ No newline at end of file + return true; +} + +function getDomoticzDeviceStatus($device, $hardware = 'rflink') +{ + $res = runDomoticzCommand(['type' => 'devices', 'rid' => $device, 'hardware' => $hardware]); + $res = json_decode($res->getBody(),true); + + return $res['result'][0]['Data']; +} diff --git a/scripts/lib/weatherstation.php b/scripts/lib/weatherstation.php index 40525fe..e0175cf 100644 --- a/scripts/lib/weatherstation.php +++ b/scripts/lib/weatherstation.php @@ -15,10 +15,13 @@ function weatherStationScreenSaver() $res .= ''; $res .= '
'; $res .= '
' . $weather['min'] . '°C
'; - $res .= '
' . $weather['temp'] . '°C
'; + $res .= '
' . $weather['outdoor_temp'] . '°C ' . $weather['temp'] . '°C
'; $res .= '
' . $weather['max'] . '°C
'; $res .= '
'; - $res .= '
' . $weather['precipitations24'] . ' mm | ' . $weather['pressure'] . ' hPa
'; + $res .= '
'; + $res .= ' ' . $weather['precipitations24'] . ' mm | ' . $weather['outdoor_pressure'] . ' hPa | ' . $weather['outdoor_humidity'] . '%
'; + $res .= ' ' . $weather['backyard_temp'] . ' °C | ' . $weather['backyard_humidity'] . '%'; + $res .= '
'; $res .= ''; $res .= '
'; foreach ($weather['forecasts'] as $forecast) {