From: Vincent Vanwaelscappel Date: Thu, 31 Aug 2023 07:56:30 +0000 (+0200) Subject: . X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=3a8adcf8dafc2097490f09af2c5773e51644733a;p=tortuga-home.git . --- diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a51dd6b..6972eed 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,10 +5,11 @@ - - + + + diff --git a/scripts/homeassistant_device_event.php b/scripts/homeassistant_device_event.php index 5fe2226..5794451 100644 --- a/scripts/homeassistant_device_event.php +++ b/scripts/homeassistant_device_event.php @@ -16,6 +16,9 @@ const HA_CUBE_SALON_3 = 'sensor.0x00158d00058a55da_action'; switch ($_GET['id']) { + case HA_SALON_PROJ_SENSOR: + $action = 'projSensor'; + $forceConfig = 'salon'; case HA_SWITCH_WC: $action = 'wcSwitch'; $forceConfig = 'wc'; @@ -52,6 +55,13 @@ require_once "import.php"; $action(); +function projSensor() +{ + if ($_GET['state'] === 'off') { + epson(false, true); + } +} + function getCubeFace($id = null) { if (null === $id) { diff --git a/scripts/lib/denon.php b/scripts/lib/denon.php index a66038e..b87dca6 100644 --- a/scripts/lib/denon.php +++ b/scripts/lib/denon.php @@ -177,6 +177,9 @@ function denonAVROff() function epson($on = true, $force = false) { profile('Epson ' . $on); + if (haGetState(HA_SALON_PROJ_SENSOR) === 'off') { + $on = false; + } $currentState = getState('EpsonPowerState', '0') === '1'; if (!$force && $currentState === $on) { diff --git a/scripts/lib/ecomode.php b/scripts/lib/ecomode.php index 23faa46..bdea404 100644 --- a/scripts/lib/ecomode.php +++ b/scripts/lib/ecomode.php @@ -28,6 +28,7 @@ function disableSuperEcoMode() function nightmode($mode) { setState('night', (!!$mode) ? '1' : '0'); + haAction('input_boolean.nightmode', (!!$mode) ? 'turn_on' : 'turn_off'); } function getNightMode($device = null) diff --git a/scripts/lib/homeassistant.php b/scripts/lib/homeassistant.php index f5269a4..253cfd0 100644 --- a/scripts/lib/homeassistant.php +++ b/scripts/lib/homeassistant.php @@ -16,6 +16,8 @@ const HA_OFFICE_SCREEN='cover.office_screen'; const HA_OFFICE_MAIN_SCREEN = 'switch.0xa4c138787633f01d'; const HA_OFFICE_PLANE_SCREENS = 'switch.0xa4c138ba535d2cc5'; +const HA_SALON_PROJ_SENSOR='binary_sensor.0x00158d00094363cc_contact'; + function haGetState($id, $attribute = null) { //ID to read - for example sensor.foo diff --git a/scripts/lib/scenes.php b/scripts/lib/scenes.php index a513e8c..467b6d1 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -634,13 +634,15 @@ $scenes = [ ['type' => 'ha', 'device' => HA_OFFICE_SCREEN, 'command' => 'open_cover'], ], 'bureau/rideaux/close' => [ - ['type' => 'ha', 'device' => HA_OFFICE_CURTAIN, 'command' => 'close_cover'], + ['type' => 'function', 'function' => 'bureauRideau', 'args' => ['close_cover']], + ], 'bureau/rideaux/open' => [ - ['type' => 'ha', 'device' => HA_OFFICE_CURTAIN, 'command' => 'open_cover'], + ['type' => 'function', 'function' => 'bureauRideau', 'args' => ['open_cover']], + ], 'bureau/rideaux/toggle' => [ - ['type' => 'ha', 'device' => HA_OFFICE_CURTAIN, 'command' => 'toggle'], + ['type' => 'function', 'function' => 'bureauRideau', 'args' => ['toggle']], ], 'insteon/off' => [ // ['type' => 'insteon', 'command' => '0?135=I=0=0'], @@ -906,6 +908,14 @@ function welcomeEco() } } +function bureauRideau($cmd) +{ + if (haGetState('binary_sensor.0x00124b002933744d_contact') == 'on') { + return; + } + haAction(HA_OFFICE_CURTAIN, $cmd); +} + function execScene($name, $fromUserAction = false, $transitionTime = null) { global $scenes;