From: Vincent Date: Sun, 22 Nov 2020 19:40:00 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=a5610fc9dacce27af444873d3c80d28d0b1678bb;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 5e5be9a..07b3a21 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,8 @@ + + @@ -1296,12 +1298,12 @@ - + - + @@ -1329,11 +1331,11 @@ - + - + diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index d05bc0e..7c3bebc 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -116,7 +116,9 @@ function cronRooms($cronmin) updateCourAuto(); } checkPlanetarium(); - checkWCVMC(); + if ($cronmin % 2) { + checkWCVMC(); + } } function cronFlowerPower($cronmin) diff --git a/scripts/lib/insteon.php b/scripts/lib/insteon.php index e9289f1..1a6c129 100644 --- a/scripts/lib/insteon.php +++ b/scripts/lib/insteon.php @@ -17,7 +17,7 @@ function insteonCommand($command) $redis->publish('insteon_event', 'handle_queue'); } -function runInsteonCommand($command, $attempts = 3) +function runInsteonCommand($command, $attempts = 10) { if ($attempts <= 0) { return; @@ -26,8 +26,8 @@ function runInsteonCommand($command, $attempts = 3) insteonClearBuffer(); echo "\n" . '-- Command ' . $command . ' attempt #' . $attempts . ' --' . "\n"; echo "command : " . _insteonCommand($command) . "\n"; - for ($i = 1; $i <= 5; $i++) { - usleep(1000000 * 0.01); + for ($i = 1; $i <= 100; $i++) { + usleep(1000000 * 0.05); $buff = insteonBuffer(); echo $buff . "\n"; if (stristr($buff, '0250') || stristr($buff, '0258')) { diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index c63b8e9..6244bd7 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -62,7 +62,7 @@ $scenes = [ ['type' => 'ecomode', 'mode' => '1'], ['type' => 'state', 'key' => 'chambre', 'value' => 0], ['type' => 'scene', 'scene' => 'chambre/rideaux/close'], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'], ['type' => 'scene', 'scene' => 'chambre/raspberry/off'], @@ -94,7 +94,7 @@ $scenes = [ ['type' => 'ecomode', 'mode' => '1'], ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]], ['type' => 'state', 'key' => 'chambre', 'value' => 0], - ['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off + //['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'scene', 'scene' => 'chambre/rideaux/close'], ['type' => 'scene', 'scene' => 'sdb/off'], @@ -115,7 +115,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'mwAGvt2n70oXCqA'], ['type' => 'domoticz', 'scene' => 4, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], ], 'chambre/savane' => [ @@ -123,7 +123,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'ABqCuE-ob-sw2vQ'], ['type' => 'domoticz', 'scene' => 5, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/focus' => [ @@ -131,7 +131,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Ne6uJnnoPO9yRhl'], ['type' => 'domoticz', 'scene' => 6, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], ], @@ -140,7 +140,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => '03gdSwPyZ9sbZVg'], ['type' => 'domoticz', 'scene' => 7, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -149,7 +149,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'BNiNQjxiWNbKRaH'], ['type' => 'domoticz', 'scene' => 8, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -158,7 +158,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Tlcft9sPK492cJA'], ['type' => 'domoticz', 'scene' => 9, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], ], @@ -173,7 +173,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'qvQXHDodBPa0cZf'], ['type' => 'domoticz', 'scene' => 12, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1119=I=0=0'], + //['type' => 'insteon', 'command' => '0?1119=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -182,7 +182,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'VtGPKtpQ7DF-RCd'], ['type' => 'domoticz', 'scene' => 13, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -191,7 +191,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Mqq8VMsmPQtzEQ0'], ['type' => 'domoticz', 'scene' => 14, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -200,7 +200,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'HfMaPG92lEOUDB0'], ['type' => 'domoticz', 'scene' => 15, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -211,7 +211,7 @@ $scenes = [ 'chambre/summernight' => [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'scene', 'scene' => 'chambre/nightlights'], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -220,7 +220,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'XGuSVQ3RCd7JUBC'], ['type' => 'domoticz', 'scene' => 17, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -229,7 +229,7 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => 'ZkiQbNQDXJz9-OC'], ['type' => 'domoticz', 'scene' => 18, 'command' => true, 'priority' => true], - ['type' => 'insteon', 'command' => '0?1132=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1132=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -242,7 +242,7 @@ $scenes = [ ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]], ['type' => 'state', 'key' => 'chambre', 'value' => 0], ['type' => 'hue', 'group' => $chambre, 'scene' => array('on' => false, 'brightness' => 0)], - ['type' => 'insteon', 'command' => '0?1332=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1332=I=0=0'], ['type' => 'domoticz', 'scene' => 19, 'command' => false, 'priority' => true], ], @@ -274,10 +274,10 @@ $scenes = [ ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 20, 'hue' => 0, 'saturation' => 255, 'transitionTime' => 1)], ], 'chambre/vincent/crepuscule' => [ - ['type' => 'insteon', 'command' => '3?0262261ED00F1300=I=3'], + // ['type' => 'insteon', 'command' => '3?0262261ED00F1300=I=3'], ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 60, 'hue' => '0', 'saturation' => 255, 'transitionTime' => 10)], ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => false, 'brightness' => 0, 'transitionTime' => 10 * 60)], - ['type' => 'insteon', 'command' => '3?0262261ED00F11FF=I=3'], + //['type' => 'insteon', 'command' => '3?0262261ED00F11FF=I=3'], ], 'chambre/vincent/aube' => [ ['type' => 'hue', 'light' => $litvincent, 'scene' => array('on' => true, 'brightness' => 0, 'hue' => '46920', 'saturation' => 255, 'transitionTime' => 0)], @@ -332,13 +332,13 @@ $scenes = [ ], 'salon/on' => [ ['type' => 'hue', 'group' => $salon, 'scene' => 'Gte8sl76rzAD1wO'], - ['type' => 'insteon', 'command' => '0?113=I=0=0'], + //['type' => 'insteon', 'command' => '0?113=I=0=0'], ['type' => 'scene', 'scene' => 'salon/cheminee', 'delay' => 1], ['type' => 'hue', 'group' => $salon, 'scene' => 'Gte8sl76rzAD1wO'], ], 'salon/off' => [ ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false)], - ['type' => 'insteon', 'command' => '0?133=I=0=0'], + //['type' => 'insteon', 'command' => '0?133=I=0=0'], ['type' => 'function', 'function' => 'chemineeOff', 'args' => ['salon']], ['type' => 'hue', 'group' => $salon, 'scene' => array('on' => false)], ['type' => 'scene', 'scene' => 'salon/fan/off'], @@ -346,7 +346,7 @@ $scenes = [ 'salon/cinemabase' => [ ['type' => 'scene', 'scene' => 'cuisine/tamise'], ['type' => 'ecomode', 'mode' => '0'], - ['type' => 'insteon', 'command' => '0?1111=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1111=I=0=0'], ], 'salon/cineclub' => [ ['type' => 'hue', 'group' => $salon, 'scene' => 'xpCjXtV3u7O1kYu'], @@ -361,13 +361,13 @@ $scenes = [ 'salon/tamise' => [ ['type' => 'ecomode', 'mode' => '0'], ['type' => 'hue', 'group' => $salon, 'scene' => 'RbjnIcLtcDuHbfU'], - ['type' => 'insteon', 'command' => '0?1130=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1130=I=0=0'], ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.8]], ['type' => 'hue', 'group' => $salon, 'scene' => 'RbjnIcLtcDuHbfU'], ], 'salon/lecturenocture' => [ ['type' => 'hue', 'group' => $salon, 'scene' => 'HZiYyM6hMUMkmiY'], - ['type' => 'insteon', 'command' => '0?1113=I=0=0'], + // ['type' => 'insteon', 'command' => '0?1113=I=0=0'], ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.25]], ['type' => 'hue', 'group' => $salon, 'scene' => 'HZiYyM6hMUMkmiY'], ], @@ -518,7 +518,7 @@ $scenes = [ ['type' => 'domoticz', 'device' => '391', 'command' => 'Toggle', 'priority' => true], ], 'insteon/off' => [ - ['type' => 'insteon', 'command' => '0?135=I=0=0'], + // ['type' => 'insteon', 'command' => '0?135=I=0=0'], ], 'home/off' => [ ['type' => 'scene', 'scene' => 'home/hueoff'], @@ -814,6 +814,7 @@ function sdbToggle() function wcOn($vmc = true) { + $hour = getHour(); if (getNightMode()) { $period = 'night'; @@ -1039,14 +1040,29 @@ function updateCourAuto() function wcVMCOn() { + setState('lastVMCOn', time()); // Start VMC insteonCommand('0?1134=I=0=0'); } -function wcVMCOff($timeout = 600) +function wcVMCOff($timeout = 'auto') { - setState('wcVMCOff', max(getState('wcVMCOff', -1), time() + $timeout)); - if ($timeout === 0) { + if ($timeout === 'auto') { + $d = time() - getState('lastVMCOn'); + if ($d <= 60) { + $timeout = 0; + } else if ($d > 60 && $d <= 120) { + $timeout = 60; + } else if ($d > 120 && $d <= 300) { + $timeout = 300; + } else { + $timeout = 600; + } + } + $t = time() + $timeout; + $max = max(getState('wcVMCOff', -1), $t); + setState('wcVMCOff', $max); + if ($max <= time()) { execScene('wc/vmc/off'); } } @@ -1055,7 +1071,7 @@ function checkWCVMC() { $offtime = getState('wcVMCOff', -1); $time = time(); - if ($offtime == -1 || $offtime > $time) { + if ($offtime == -1 || $offtime > $time || getState('lastVMCOn') > $offtime) { return; } execScene('wc/vmc/off');