From 81723dbe5882437623d329ef8072cc14a927e997 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 20 Jun 2024 16:30:48 +0200 Subject: [PATCH] . --- .idea/workspace.xml | 18 +++++--- scripts/import.php | 8 ++++ scripts/lib/insteon.php | 86 ------------------------------------ scripts/lib/lib.php | 4 -- scripts/lib/medialibrary.php | 2 +- scripts/lib/profile.php | 80 +++++++++++++++++++++++++-------- scripts/lib/tmdb.php | 2 +- scripts/tmdb.php | 2 +- 8 files changed, 83 insertions(+), 119 deletions(-) delete mode 100644 scripts/lib/insteon.php diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 182d281..6abd274 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,12 +5,14 @@ - - - - - + + + + + + + diff --git a/scripts/import.php b/scripts/import.php index da61750..eb9aee8 100644 --- a/scripts/import.php +++ b/scripts/import.php @@ -1,11 +1,18 @@ igbget('insteon_queue'); - if (!is_array($queue)) { - $queue = []; - } - $queue[] = $command; - $redis->igbset('insteon_queue', $queue); - $redis->publish('insteon_event', 'handle_queue'); -} - -function runInsteonCommand($command, $attempts = 10) -{ - if ($attempts <= 0) { - return; - } - - insteonClearBuffer(); - echo "\n" . '-- Command ' . $command . ' attempt #' . $attempts . ' --' . "\n"; - echo "command : " . _insteonCommand($command) . "\n"; - for ($i = 1; $i <= 100; $i++) { - usleep(1000000 * 0.05); - $buff = insteonBuffer(); - echo $buff . "\n"; - if (stristr($buff, '0250') || stristr($buff, '0258')) { - insteonClearBuffer(); - return; - } - } - runInsteonCommand($command, $attempts - 1); -} - -function _insteonCommand($command) -{ - global $insteonHasKnocked; - if (!$insteonHasKnocked) { - insteonKnock(); - } - return __insteonCommand($command); -} - -function insteonKnock() -{ - global $insteonHasKnocked; - $insteonHasKnocked = true; - __insteonCommand('1cjdW20oprxzHDZ.htm'); -} - - -function __insteonCommand($command) -{ - global $insteonBaseURL, $insteonAuth, $insteonCommandTimeout; - return getUrlContent($insteonBaseURL . '/' . $command, $insteonCommandTimeout, $insteonAuth); -} - -function insteonClearBuffer() -{ - return _insteonCommand('1?XB=M=1'); -} - -function _insteonBufferEmpty() -{ - return trim(insteonBuffer(), '0') === ''; -} - -function insteonBuffer() -{ - global $insteonHasKnocked; - $x = _insteonCommand('buffstatus.xml'); - if ($x !== false && is_object($x)) { - $xml = simplexml_load_string($x); - return (string)($xml->BS); - } else { - $insteonHasKnocked = false; - insteonKnock(); - return ''; - } -} \ No newline at end of file diff --git a/scripts/lib/lib.php b/scripts/lib/lib.php index cabf001..fba0d84 100644 --- a/scripts/lib/lib.php +++ b/scripts/lib/lib.php @@ -1,13 +1,9 @@