From: Vincent Vanwaelscappel Date: Wed, 9 Nov 2022 16:59:04 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=35e81dd5a44c46bcbe287b872d6313b2e26fd6b6;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 09aa7a6..044a998 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,7 +3,10 @@ - + + + + diff --git a/config/rooms.php b/config/rooms.php index 460c7bf..d0f21dc 100644 --- a/config/rooms.php +++ b/config/rooms.php @@ -67,6 +67,7 @@ function salon() ['type' => 'light', 'scene' => 'salon/tamise', 'label' => 'Tamisé'], ['type' => 'light', 'scene' => 'salon/lecturenocture', 'label' => 'Lecture nocturne'], ['type' => 'light', 'scene' => 'salon/cheminee', 'label' => 'Cheminée'], + ['type' => 'light', 'scene' => 'salon/theatre', 'label' => 'Théâtre'], ['type' => 'light', 'scene' => 'salon/bar/toggle', 'label' => 'Bar'], ]; $all = array_merge($favorites, [['type' => 'separator', 'label' => 'Projecteur'], diff --git a/scripts/domoticz_device_event.php b/scripts/domoticz_device_event.php index 50cbfb3..c7af342 100644 --- a/scripts/domoticz_device_event.php +++ b/scripts/domoticz_device_event.php @@ -27,7 +27,6 @@ if (in_array($device, $cubesalon)) { require_once "import.php"; - if ($device === 6894) { domoticzCmd(6898, 'Toggle'); } elseif ($device == 6895) { @@ -80,7 +79,11 @@ if ($device === 6894) { setState('wc', 1); break; case 'Long_Click': - execScene('home/alert', true); + if (isJerome(false) && isVincent()) { + execScene('home/alert', true); + } else { + wcToggle(); + } break; case 'Click': default: diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index f6d5d2a..3aa03da 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -406,6 +406,15 @@ $scenes = [ ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.8]], ['type' => 'scene', 'scene' => 'cuisine/on', 'repeat' => 2], ], + 'salon/theatre' => [ + ['type' => 'ecomode', 'mode' => '0'], + ['type' => 'domoticz', 'scene' => 53, 'command' => true, 'priority' => true], + ['type' => 'hue', 'group' => $salon, 'scene' => 'xWNIeznSzek8dKS', 'repeat' => 2], + ['type' => 'state', 'key' => 'salon', 'value' => 'theatre'], + // ['type' => 'insteon', 'command' => '0?1130=I=0=0'], + ['type' => 'function', 'function' => 'chemineeOn', 'args' => ['salon', 'fire', 0.8]], + ['type' => 'scene', 'scene' => 'cuisine/on', 'repeat' => 2], + ], 'salon/lecturenocture' => [ ['type' => 'function', 'function' => 'salonAuto', 'args' => [false]], ['type' => 'domoticz', 'scene' => 49, 'command' => true, 'priority' => true], diff --git a/scripts/lib/switchbot.php b/scripts/lib/switchbot.php index 2a4ddc4..6879c75 100644 --- a/scripts/lib/switchbot.php +++ b/scripts/lib/switchbot.php @@ -113,14 +113,16 @@ function _isVincent() return true; } -function isJerome() +function isJerome($strict = true) { - return remember('jerome_in_paris', 3600, function () { - return _isJerome(); + $key = 'jerome_in_paris' . ($strict ? '' : '_1'); + + return remember($key, 3600, function () use ($strict) { + return _isJerome($strict); }, true); } -function _isJerome() +function _isJerome($strict = true) { $today = new DateTime('now'); $yesterday = new DateTime('now'); @@ -128,7 +130,7 @@ function _isJerome() $tomorrow = new DateTime('now'); $tomorrow->add(new DateInterval('P1D')); - $dates = [$yesterday, $today, $tomorrow]; + $dates = $strict ? [$yesterday, $today, $tomorrow] : [$today]; foreach ($dates as $date) { $events = searchIcalEventDay('dplacements-jrme', $date);