From b66e4718933617a68dc2e1e4e25c7989f9a744a2 Mon Sep 17 00:00:00 2001 From: Vincent Date: Fri, 10 Apr 2020 13:47:02 +0200 Subject: [PATCH] . --- .idea/workspace.xml | 49 +++++++++++++++++++++---------------- scripts/cron/cron.php | 27 +------------------- scripts/flowerpower.php | 18 +------------- scripts/lib/flowerpower.php | 19 ++++++++++++++ scripts/lib/lib.php | 14 +++++++++++ scripts/lib/tmdb.php | 2 -- 6 files changed, 63 insertions(+), 66 deletions(-) create mode 100644 scripts/lib/flowerpower.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 01ab381..5fe25e4 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,11 @@ + + + + @@ -1221,37 +1229,36 @@ - - + - - + + + + + - - + - - + + - - + - diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index c49c566..fa65093 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -91,19 +91,7 @@ function cronBackyard($cronmin) function cronFlowerPower($cronmin) { - $fp = explode("\n", trim(`sudo /usr/local/bin/flowerpower`)); - $map = [2 => 1467, 0 => 1468]; - foreach ($map as $k => $v) { - $newValue = $fp[$k]; - if ($v === 1467) { - $newValue = (float)$newValue; - $currentValue = toNumber(getDomoticzDeviceStatus(1467), false); - if (abs($currentValue - $newValue) > 30 || $newValue == 0 || $newValue > 60 || $newValue < -50) { - return; - } - } - domoticzCmd(['param' => 'udevice', 'idx' => $v, 'nvalue' => 0, 'svalue' => $newValue]); - } + updateFlowerPower(); } function cronMediaLibrary($cronmin) @@ -163,19 +151,6 @@ function cronSqueezeFavorites($cronmin) } } -function toNumber($val, $round = false) -{ - if ($val === false) { - return '--'; - } - $val = preg_replace('/[^0-9-.]/', '', $val); - $val = floatval($val); - if ($round) { - $val = round($val, $round === true ? 0 : $round); - } - return $val; -} - function cronWeather($cronmin) { $place = 2608449; diff --git a/scripts/flowerpower.php b/scripts/flowerpower.php index ed74171..bb74c8f 100644 --- a/scripts/flowerpower.php +++ b/scripts/flowerpower.php @@ -1,20 +1,4 @@ $d) { - foreach ($d as $name => $value) { - if ($name == 'calibratedAirTemperature') { - setState('airtemperature', $value); - } - $insert = array('device' => $device, 'name' => $name, 'value' => $value); - $table->insert($insert); - } - } -} \ No newline at end of file +updateFlowerPower(); \ No newline at end of file diff --git a/scripts/lib/flowerpower.php b/scripts/lib/flowerpower.php new file mode 100644 index 0000000..59ee32c --- /dev/null +++ b/scripts/lib/flowerpower.php @@ -0,0 +1,19 @@ + 1467, 0 => 1468]; + foreach ($map as $k => $v) { + $newValue = $fp[$k]; + if ($v === 1467) { + $newValue = (float)$newValue; + $currentValue = toNumber(getDomoticzDeviceStatus(1467), false); + if (abs($currentValue - $newValue) > 30 || $newValue == 0 || $newValue > 60 || $newValue < -50) { + echo 'Out of bounds'; + return; + } + } + domoticzCmd(['param' => 'udevice', 'idx' => $v, 'nvalue' => 0, 'svalue' => $newValue]); + } +} \ No newline at end of file diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index 60de273..2eb3ef3 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -41,6 +41,7 @@ require_once ROOT . '/scripts/lib/ssh.php'; require_once ROOT . '/scripts/lib/cachemedia.php'; require_once ROOT . '/scripts/lib/ifttt.php'; require_once ROOT . '/scripts/lib/router.php'; +require_once ROOT . '/scripts/lib/flowerpower.php'; profile('Loaded libraries', __FILE__, __LINE__); @@ -525,4 +526,17 @@ function isProcessRunning($process) return false; } return true; +} + +function toNumber($val, $round = false) +{ + if ($val === false) { + return '--'; + } + $val = preg_replace('/[^0-9-.]/', '', $val); + $val = floatval($val); + if ($round) { + $val = round($val, $round === true ? 0 : $round); + } + return $val; } \ No newline at end of file diff --git a/scripts/lib/tmdb.php b/scripts/lib/tmdb.php index 14e1670..471eff0 100644 --- a/scripts/lib/tmdb.php +++ b/scripts/lib/tmdb.php @@ -288,8 +288,6 @@ class mediaLibrary if (file_exists($x264)) { $p = $x264; } - - return str_replace('/volume1/Share', '', $p); } -- 2.39.5