From f8968c06ea3cd8e6dae843342cde1897586c7dcb Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Thu, 26 Mar 2026 12:35:05 +0100 Subject: [PATCH] . --- .idea/dataSources.local.xml | 2 +- .idea/workspace.xml | 13 ++-- scripts/homeassistant_device_event.php | 12 +--- scripts/lib/scenes.php | 97 +++----------------------- scripts/lib/shield.php | 13 ++++ 5 files changed, 32 insertions(+), 105 deletions(-) diff --git a/.idea/dataSources.local.xml b/.idea/dataSources.local.xml index 73acb27..db80606 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 b0c0e8b..c532e12 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,9 +5,11 @@ + - - + + + - + @@ -416,6 +418,7 @@ + diff --git a/scripts/homeassistant_device_event.php b/scripts/homeassistant_device_event.php index ce2446f..d67aafd 100644 --- a/scripts/homeassistant_device_event.php +++ b/scripts/homeassistant_device_event.php @@ -77,18 +77,10 @@ function wcSwitch() execScene('wc/spa', true); setState('wc', 1); break; - case '1_hold': - case '2_hold': + case 'hold': - if (isJerome(false) && isVincent()) { - execScene('home/alert', true); - } else { - wcToggle(); - } - break; case 'single': - case '1_single': - case '2_single': + wcToggle(); wcToggle(); break; default: diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index 95290fd..5095edf 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -634,51 +634,19 @@ $scenes = [ 'wc/on' => [ ['type' => 'function', 'function' => 'wcOn'], ], - 'wc/morning' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'NC5ejamHGUNURj8'], - ['type' => 'function', 'function' => 'wcMusic', 'args' => [70]], - ], - 'wc/day' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'qfuu8z5QaJ6J26W'], - ['type' => 'function', 'function' => 'wcMusic', 'args' => [80]], - ], - 'wc/evening' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'h82j28eNu6ZHVhM'], - ['type' => 'function', 'function' => 'wcMusic', 'args' => [80]], - ], - 'wc/late' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'IGo4F5jRQXc1H95'], - ['type' => 'function', 'function' => 'wcMusic', 'args' => [70]], - ], - 'wc/night' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'eJy09JTEzCiIL1P'], - ], - 'wc/nightambiance' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => ['effect' => 'none']], - ['type' => 'scene', 'scene' => 'wc/night'], - ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['Nuit d\'été', $squeezeboxPlayers['WC'], 100, false]], - ], - 'wc/off' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => ['on' => false, 'effect' => 'none']], - ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['WC'], false]], - ['type' => 'state', 'key' => 'wc', 'value' => 0], - ['type' => 'function', 'function' => 'wcVMCOff'], - ], + +// 'wc/nightambiance' => [ +// ['type' => 'hue', 'group' => $wc, 'scene' => ['effect' => 'none']], +// ['type' => 'scene', 'scene' => 'wc/night'], +// ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['Nuit d\'été', $squeezeboxPlayers['WC'], 100, false]], +// ], + 'wc/spa' => [ ['type' => 'hue', 'group' => $wc, 'scene' => ['effect' => 'colorloop', 'on' => true, 'brightness' => 128]], ['type' => 'function', 'function' => 'squeezePlayByName', 'args' => ['Rivière', $squeezeboxPlayers['WC'], 100]], ['type' => 'function', 'function' => 'wcVMCOff'], ], - 'wc/silentmorning' => [ - ['type' => 'hue', 'group' => $wc, 'scene' => 'NC5ejamHGUNURj8'], - ['type' => 'function', 'function' => 'wcMusic', 'args' => [50]], - ], - 'wc/vmc/on' => [ - ['type' => 'function', 'function' => 'wcVMCOn'], - ], - 'wc/vmc/off' => [ - ['type' => 'ha', 'device' => HA_WC_VMC, 'command' => 'turn_off', 'priority' => true], - ], + 'sdb/ampli/on' => [ ['type' => 'ha', 'device' => HA_SDB_AMPLI, 'priority' => true], ], @@ -892,30 +860,6 @@ function chambreToggle($fromUserAction = false) } } -function wcMusic($volume) -{ - $d = date('w'); - if ($d == 4) { - $music = 'New Morning'; - } else if ($d == 2) { - $music = 'Radio Michel'; - } else if ($d == 5) { - $music = 'Samba'; - //$volume += 10; - } else { - $music = 'FIP'; - } - squeezePlayByName($music, 'WC', $volume, false); -} - -function wcToggle() -{ - if (getState('wc') == 1) { - execScene('wc/off', true); - } else { - wcOn(); - } -} function sdbToggle() { @@ -927,31 +871,6 @@ function sdbToggle() } } -function wcOn($vmc = true) -{ - $hour = getHour(); - if (getNightMode('chambre') && getNightMode('bureau')) { - $period = 'night'; - } else if (getNightMode() && !getNightMode('bureau')) { - $period = 'silentmorning'; - } else if ($hour > 0 && $hour < 6.75) { - $period = 'late'; - } else if ($hour >= 6.75 && $hour < 10) { - $period = 'morning'; - } else if ($hour >= 10 && $hour < 20) { - $period = 'day'; - } else { - $period = 'evening'; - } - execScene('wc/' . $period, true); - setState('wc', 1); - if ($vmc && $period != 'night' && $period !== 'silentmorning') { - wcVMCOn(); - } else { - wcVMCOff(0); - } -} - function cheminee($lightId, $room = 'salon', $program = 'fire', $brightness = 1) { $start = time(); diff --git a/scripts/lib/shield.php b/scripts/lib/shield.php index f92ccbb..09df2a7 100644 --- a/scripts/lib/shield.php +++ b/scripts/lib/shield.php @@ -2,6 +2,19 @@ $shieldConnect = false; +function getDevice($device = null) +{ + global $devices; + if (is_array($device) && isset($device['host'])) { + return $device; + } + if (null === $device) { + $device = config('DEVICE'); + } + return $devices[$device]; +} + + function shieldConnect($force = false, $device = null) { global $shieldConnect; -- 2.39.5