From 13526ebc3b487d4009fd1ee1391319afa7124cc6 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Sun, 9 Jul 2023 21:13:06 +0200 Subject: [PATCH] . --- .idea/workspace.xml | 7 ++- scripts/homeassistant_device_event.php | 8 +-- scripts/lib/homeassistant.php | 1 + scripts/lib/scenes.php | 70 ++++++++++---------------- 4 files changed, 36 insertions(+), 50 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 70a3fd9..126f4b2 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,10 @@ + + + diff --git a/scripts/homeassistant_device_event.php b/scripts/homeassistant_device_event.php index 4b5ba5f..d83f629 100644 --- a/scripts/homeassistant_device_event.php +++ b/scripts/homeassistant_device_event.php @@ -53,7 +53,7 @@ function getCubeFace($id = null) { $id = $_GET['id']; } $id = str_replace('_action', '_side', $id); - return (int)getState('cube_face_' . $id, 1); + return (int)haGetState($id); } function wcSwitch() { @@ -103,7 +103,7 @@ function cubeBureau() { off('bureau'); break; case 'slide': - if ($face == 5) { + if ($face == 3) { haAction('script.klarstein_fan_toggle'); break; } @@ -115,14 +115,14 @@ function cubeBureau() { } break; case 'rotate_right': - if ($face == 5) { + if ($face == 3) { haAction('script.klarstein_fan_speed_up'); break; } volume(config('VOLUME_STEP'), '+'); break; case 'rotate_left': - if ($face == 5) { + if ($face == 3) { haAction('script.klarstein_fan_speed_down'); break; } diff --git a/scripts/lib/homeassistant.php b/scripts/lib/homeassistant.php index 566d561..1f42bad 100644 --- a/scripts/lib/homeassistant.php +++ b/scripts/lib/homeassistant.php @@ -8,6 +8,7 @@ const HA_ECO_BASIC = 'switch.ecomode_basic'; const HA_ECO_SUPER = 'switch.ecomode_super'; const HA_HOTTE = 'switch.hotte'; const HA_BAR = 'switch.bar'; +const HA_PLANETARIUM='switch.0xa4c138788071821e'; 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 344aaf8..1e0ae14 100644 --- a/scripts/lib/scenes.php +++ b/scripts/lib/scenes.php @@ -62,7 +62,6 @@ $scenes = [ ['type' => 'ecomode', 'mode' => '1'], ['type' => 'state', 'key' => 'chambre', 'value' => 0], ['type' => 'ha', 'device' => 'script.rideaux_chambre_ferme'], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'scene', 'scene' => 'chambre/deshumidificateur/off'], ['type' => 'phonetask', 'phone' => 'vincent', 'task' => 'Va Au Lit'], @@ -93,7 +92,6 @@ $scenes = [ ['type' => 'ecomode', 'mode' => '1'], ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]], ['type' => 'state', 'key' => 'chambre', 'value' => 0], - //['type' => 'insteon', 'command' => '0?1332=I=0=0'], // Lustre et tableau off ['type' => 'function', 'function' => 'bedbrightness', 'args' => [$bedlowscreenbrightness]], ['type' => 'ha', 'device' => 'script.rideaux_chambre_ferme'], ['type' => 'scene', 'scene' => 'sdb/off'], @@ -104,7 +102,7 @@ $scenes = [ 'chambre/sleep' => [ ['type' => 'scene', 'scene' => 'chambre/cheminee/smallfire'], ['type' => 'hue', 'group' => $chambre, 'scene' => '-P3feFyrTnFNfXi'], // Veilleuse + - ['type' => 'domoticz', 'scene' => 10, 'command' => true, 'priority' => true], + ['type' => 'ha', 'device' => 'scene.chambre_veilleuseplus'], ['type' => 'scene', 'scene' => 'chambre/sleep/base'], ['type' => 'delay', 'scene' => 'chambre/bed/off', 'delay' => 300], // Tout off dans 5 min ], @@ -112,30 +110,26 @@ $scenes = [ 'chambre/boreal' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'mwAGvt2n70oXCqA'], - ['type' => 'domoticz', 'scene' => 4, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], - ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], + ['type' => 'ha', 'device' => 'scene.chambre_boreal'], + ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/savane' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'ABqCuE-ob-sw2vQ'], - ['type' => 'domoticz', 'scene' => 5, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_savane'], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/focus' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Ne6uJnnoPO9yRhl'], - ['type' => 'domoticz', 'scene' => 6, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_focus'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], - ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], + ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/chillout' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => '03gdSwPyZ9sbZVg'], - ['type' => 'domoticz', 'scene' => 7, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_chillout'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -146,80 +140,72 @@ $scenes = [ 'chambre/reading' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'BNiNQjxiWNbKRaH'], - ['type' => 'domoticz', 'scene' => 8, 'command' => true, 'priority' => true], - // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_reading'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/tonic' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Tlcft9sPK492cJA'], - ['type' => 'domoticz', 'scene' => 9, 'command' => true, 'priority' => true], - // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_tonic'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], - ['type' => 'scene', 'scene' => 'chambre/cheminee/cold'], + ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/moon' => [ ['type' => 'hue', 'group' => $chambre, 'scene' => '5PKfoOn8ss17o2l'], // Clair de lune - ['type' => 'domoticz', 'scene' => 11, 'command' => true, 'priority' => true], + ['type' => 'ha', 'device' => 'scene.chambre_clairdelune'], ['type' => 'scene', 'scene' => 'chambre/sleepbase'], ], 'chambre/party' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'qvQXHDodBPa0cZf'], - ['type' => 'domoticz', 'scene' => 12, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1119=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_party'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/flowers' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'VtGPKtpQ7DF-RCd'], - ['type' => 'domoticz', 'scene' => 13, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_flowers'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/tropical' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'Mqq8VMsmPQtzEQ0'], - ['type' => 'domoticz', 'scene' => 14, 'command' => true, 'priority' => true], - // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_tropical'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/beach' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'HfMaPG92lEOUDB0'], - ['type' => 'domoticz', 'scene' => 15, 'command' => true, 'priority' => true], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_beach'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/nightlights' => [ ['type' => 'hue', 'group' => $chambre, 'scene' => 'JNieZpDHu5fbMyf'], - ['type' => 'domoticz', 'scene' => 16, 'command' => true, 'priority' => true], + ['type' => 'ha', 'device' => 'scene.chambre_summernight'], ], 'chambre/summernight' => [ ['type' => 'scene', 'scene' => 'chambre/nightlights'], - //['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_summernight'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/lounge' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'XGuSVQ3RCd7JUBC'], - ['type' => 'domoticz', 'scene' => 17, 'command' => true, 'priority' => true], - // ['type' => 'insteon', 'command' => '0?1131=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_lounge'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], 'chambre/full' => [ ['type' => 'nightmode', 'mode' => '0'], ['type' => 'hue', 'group' => $chambre, 'scene' => 'ZkiQbNQDXJz9-OC'], - ['type' => 'domoticz', 'scene' => 18, 'command' => true, 'priority' => true], - // ['type' => 'insteon', 'command' => '0?1132=I=0=0'], + ['type' => 'ha', 'device' => 'scene.chambre_full'], ['type' => 'function', 'function' => 'bedbrightness', 'args' => [255]], ['type' => 'scene', 'scene' => 'chambre/cheminee'], ], @@ -232,21 +218,17 @@ $scenes = [ ['type' => 'state', 'key' => 'chambre', 'value' => 0], ['type' => 'state', 'key' => 'chambreOff', 'value' => 1], ['type' => 'hue', 'group' => $chambre, 'scene' => array('on' => false)], - // ['type' => 'insteon', 'command' => '0?1332=I=0=0'], - ['type' => 'domoticz', 'scene' => 19, 'command' => false, 'priority' => true], + ['type' => 'ha', 'device' => 'scene.chambre_off'], ['type' => 'function', 'function' => 'chambreAuto', 'args' => [false]], ], 'chambre/cheminee' => [ - ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true], + ['type' => 'ha', 'device' => "scene.chambre_cheminee"], ], 'chambre/cheminee/smallfire' => [ - ['type' => 'domoticz', 'scene' => 44, 'command' => true, 'priority' => true], - ], - 'chambre/cheminee/cold' => [ - ['type' => 'domoticz', 'scene' => 43, 'command' => true, 'priority' => true], + ['type' => 'ha', 'device' => "scene.chambre_cheminee_small"], ], 'chambre/cheminee/off' => [ - ['type' => 'domoticz', 'scene' => 43, 'command' => false, 'priority' => true], + ['type' => 'ha', 'device' => 'light.chambre_cheminee', 'command' => 'turn_off'], ], 'chambre/toggle' => [ ['type' => 'function', 'function' => 'chambreToggle'], @@ -1073,13 +1055,13 @@ function checkPlanetarium($periodicOffCheck = true) { if ($periodicOffCheck) { $min = intval(date('i')); if ($min % 30 == 0) { - domoticzSwitch($device, false); + haAction(HA_PLANETARIUM, 'turn_off'); sleep(5); } } - domoticzSwitch($device, true); + haAction(HA_PLANETARIUM); } else { - domoticzSwitch($device, false); + haAction(HA_PLANETARIUM, 'turn_off'); } } -- 2.39.5