From 7ffa6dd27c0053e645e9a54729739a9e0cfa9845 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Fri, 25 Nov 2022 13:04:07 +0100 Subject: [PATCH] . --- .idea/dataSources.local.xml | 2 +- .idea/workspace.xml | 25 +++++++++++++------------ scripts/lib/scenes.php | 23 ++++++++++++++++++++++- scripts/lib/switchbot.php | 19 +++++++++++++++---- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index ac1846d..37718e2 100644 --- a/.idea/dataSources.local.xml +++ b/.idea/dataSources.local.xml @@ -1,6 +1,6 @@ - + " diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 9a82287..3ce24db 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,9 +3,6 @@ - - - @@ -1176,14 +1173,11 @@ - - - - 1639302540066 - 1639837981727 @@ -1521,7 +1515,14 @@ - diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index 05f3650..e9001df 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -687,12 +687,23 @@ $scenes = [ ], 'home/welcome/eco' => [ + ['type' => 'function', 'function' => 'welcomeEco'], + ], + + 'home/welcome/eco/salon' => [ ['type' => 'scene', 'scene' => 'cuisine/on'], ['type' => 'scene', 'scene' => 'salon/auto'], ['type' => 'ecomode', 'mode' => '0'], ['type' => 'scene', 'scene' => 'sdb/hotwater/auto'], ], + 'home/welcome/eco/homeoffice' => [ + ['type' => 'scene', 'scene' => 'cuisine/coffee/on'], + ['type' => 'scene', 'scene' => 'bureau/auto'], + ['type' => 'ecomode', 'mode' => '0'], + ['type' => 'scene', 'scene' => 'sdb/hotwater/auto'], + ], + 'home/welcome' => [ ['type' => 'scene', 'scene' => 'home/welcome/eco'], ['type' => 'scene', 'scene' => 'bureau/auto'], @@ -759,7 +770,7 @@ $scenes = [ ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['1']], ], 'sdb/hotwater/auto/force' => [ - ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['1',true]], + ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['1', true]], ], 'sdb/hotwater/eco' => [ ['type' => 'function', 'function' => 'hotwaterAutoMode', 'args' => ['0']], @@ -891,6 +902,16 @@ $scenes = [ ]; +function welcomeEco() +{ + $businessHour = [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]; + if (isWeekEnd() || !in_array(date('G'), $businessHour)) { + execScene('home/welcome/eco/salon'); + } else { + execScene('home/welcome/eco/homeoffice'); + } +} + function chambreRideaux($ouvre = true) { $device = 1756; diff --git a/scripts/lib/switchbot.php b/scripts/lib/switchbot.php index 05ee083..c740f77 100644 --- a/scripts/lib/switchbot.php +++ b/scripts/lib/switchbot.php @@ -30,9 +30,9 @@ function hotwaterCheckMode($force = false) $vincent = isVincent($force); $h = date('G'); - $d = date('N'); - $isWeek = $d < 6; - $maxLevel = $jerome ? "2" : '1'; + $isWeek = isWeekDay(); + + $maxLevel = '2'; $ecomode = (int)getState('ecomode', '0'); @@ -56,7 +56,7 @@ function hotwaterCheckMode($force = false) } } } - echo "\n\n" . 'V:' . $vincent . '/J:' . $jerome . '/H:' . $h . '/D:' . $d . '/W:' . $hot . "\n\n"; + echo "\n\n" . 'V:' . $vincent . '/J:' . $jerome . '/H:' . $h . '/WD:' . $isWeek . '/W:' . $hot . "\n\n"; hotwater($hot); } @@ -96,6 +96,17 @@ function hotwater($newState) return $res; } +function isWeekDay() +{ + $d = date('N'); + return $d < 6; +} + +function isWeekEnd() +{ + return !isWeekDay(); +} + function isVincent($force = false) { return remember('vincent_in_paris', 3600, function () { -- 2.39.5