From: vincent Date: Sat, 22 Jan 2022 15:13:17 +0000 (+0100) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=ffee6c3b736a8e339829f6bff21fb90272f166b4;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index c697114..dff337d 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,8 @@ + + diff --git a/scripts/cron/cron.php b/scripts/cron/cron.php index f818101..55620f6 100644 --- a/scripts/cron/cron.php +++ b/scripts/cron/cron.php @@ -14,6 +14,7 @@ function cronOneLoop($cronmin) cronMagnet($cronmin); if ($cronmin % 5 == 0) { + cronHotWater($cronmin); cronTraffic($cronmin, false); cronVelib($cronmin); cronGuest($cronmin); @@ -53,6 +54,11 @@ function cronOneLoop($cronmin) _logSection('End Loop (min:' . $cronmin . ')'); } +function cronHotWater($cronmin) +{ + hotwaterCheckMode(); +} + function cronMagnet($cronmin) { _logSection('Magnet links'); diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index 79f270d..20211fa 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -322,6 +322,7 @@ $scenes = [ ['type' => 'function', 'function' => 'stopAllSqueezebox'], ['type' => 'nightmode', 'mode' => '1'], ['type' => 'ecomode', 'mode' => '1'], + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']], ], 'home/music/synchro/soiree' => [ ['type' => 'function', 'function' => 'syncMusic', 'args' => [['Salon', 'Cuisine', 'Bureau', 'WC']]], @@ -645,6 +646,7 @@ $scenes = [ 'home/off' => [ ['type' => 'scene', 'scene' => 'home/hueoff'], ['type' => 'ecomode', 'mode' => '2'], + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']], //['type' => 'scene', 'scene' => 'cuisine/off'], ['type' => 'scene', 'scene' => 'salon/off'], ['type' => 'scene', 'scene' => 'cour/off'], @@ -729,16 +731,20 @@ $scenes = [ ['type' => 'domoticz', 'device' => '476', 'command' => false, 'priority' => true], ], 'sdb/hotwater/eco' => [ + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']], ['type' => 'function', 'function' => 'hotwater', 'args' => ['1']], ], 'sdb/hotwater/max' => [ + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']], ['type' => 'function', 'function' => 'hotwater', 'args' => ['2']], ], 'sdb/hotwater/off' => [ + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['0']], ['type' => 'function', 'function' => 'hotwater', 'args' => ['0']], ], 'sdb/off' => [ ['type' => 'state', 'key' => 'sdb', 'value' => 0], + ['type' => 'function', 'key' => 'hotwaterAutoMode', 'args' => ['1']], ['type' => 'domoticz', 'scene' => 20, 'command' => false, 'priority' => true], ['type' => 'function', 'function' => 'stopSqueezeboxPlayer', 'args' => [$squeezeboxPlayers['Salle de bains'], false]], ], diff --git a/scripts/lib/switchbot.php b/scripts/lib/switchbot.php index 6e2c55e..61ee59b 100644 --- a/scripts/lib/switchbot.php +++ b/scripts/lib/switchbot.php @@ -12,6 +12,38 @@ function switchbot($device, $command = 'press') return $res; } +function hotwaterAutoMode($mode) +{ + $mode = $mode ? '1' : '0'; + setState('hotwater_auto_mode', $mode); + if ($mode) { + hotwaterCheckMode(); + } +} + +function hotwaterCheckMode() +{ + + if (getState('hotwater_auto_mode', '1') == '0') { + return; + } + + if (getSqueezePlayerStatus('Salle de bains')) { + $hot = '2'; + } else { + $ecomode = getState('ecomode', '0'); + if ($ecomode == '0') { + $hot = '1'; + } else if ($ecomode == '2') { + $hot = '0'; + } else if ($ecomode == '1') { + $h = date('G'); + $hot = ($h > 6 && $h < 10) ? '1' : '0'; + } + } + hotwater($hot); +} + function hotwater($newState) { // 0 : OFF