]> _ Git - tortuga-home.git/commitdiff
.
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jul 2023 07:10:29 +0000 (09:10 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 5 Jul 2023 07:10:29 +0000 (09:10 +0200)
.idea/workspace.xml
scripts/homeassistant.php
scripts/lib/harmony.php
scripts/lib/homeassistant.php
scripts/lib/scenes.php

index f8034d5bfaf06eaa2df9166bd9121b33d7f5d168..29fdf77eec3090a9437c32e0c5032e17ae65dd52 100644 (file)
@@ -9,6 +9,7 @@
       <change beforePath="$PROJECT_DIR$/scripts/homeassistant.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/homeassistant.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/harmony.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/harmony.php" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/scripts/lib/homeassistant.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/homeassistant.php" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/scripts/lib/scenes.php" beforeDir="false" afterPath="$PROJECT_DIR$/scripts/lib/scenes.php" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
       <workItem from="1687359859243" duration="1495000" />
       <workItem from="1688295154056" duration="11039000" />
       <workItem from="1688414368761" duration="11417000" />
-      <workItem from="1688478993471" duration="3221000" />
+      <workItem from="1688478993471" duration="43245000" />
     </task>
     <task id="LOCAL-00502" summary=".">
       <created>1641726946298</created>
       <option name="project" value="LOCAL" />
       <updated>1687259667913</updated>
     </task>
-    <option name="localTasksCounter" value="552" />
+    <option name="localTasksCounter" value="553" />
     <servers />
   </component>
   <component name="TypeScriptGeneratedFilesManager">
index 7ced31d30bca26867b19b9948d2f48edc912edd7..06a3dbdebb52e8538168e140290cdd8738b7b958 100644 (file)
@@ -1,7 +1,9 @@
 <?php
 require_once "import.php";
 if (!isset($_GET['action']) || $_GET['action'] === 'state') {
-       print_r(haGetState($_GET['id'],$_GET['attribute']??null));
+       print_r(haGetState($_GET['id'], $_GET['attribute'] ?? null));
 } else {
-       print_r(haAction($_GET['id'], $_GET['action']));
+       $data = $_GET;
+       unset($data['id'], $data['action'], $data['c']);
+       print_r(haAction($_GET['id'], $_GET['action'], null, $data));
 }
\ No newline at end of file
index 63a662262f1c3116a96f2b3fbd6151e34a7e27f4..7a9c2a36868f6e0c28eb62d29f346b988d3d8906 100644 (file)
@@ -1,12 +1,12 @@
 <?php
 
-$harmonymap = ['musique' => 'Musique', 'tv' => 'TV', 'switch' => 'Switch', 'poweroff' => 'Power Off'];
+$harmonymap = ['musique' => 'Musique', 'tv' => 'TV', 'switch' => 'Switch', 'poweroff' => 'power_off'];
 function harmonyActivity($activity) {
        global $harmonymap;
-       if($activity=='off'){
-               $activity='poweroff';
+       if ($activity == 'off') {
+               $activity = 'poweroff';
        }
-       if ($activity == 'poweroff' ) {
+       if ($activity == 'poweroff') {
                setPlaying('mycanal', 'bureau');
        }
        $wait = 0;
@@ -23,13 +23,12 @@ function harmonyActivity($activity) {
                shieldWakeup('bureau');
        }
 
-
-       haAction("select.bureau_activities", $harmonymap[$activity]);
+       haAction("select.bureau_activities", 'select_option', null, ['option' => $harmonymap[$activity]]);
        if ($wait > 0) {
                sleep($wait);
        }
        if ($activity == 'tv') {
-               runAtEnd('sleep(15);/*harmonyDeviceCommand(\'sony-projecteur\', \'power-on\');*/');
+               runAtEnd('sleep(15);haAction(\'script.bureau_projector_on\');');
        }
 }
 
@@ -45,9 +44,4 @@ function getCurrentHarmonyActivity() {
 
 function stopHarmony() {
        harmonyActivity('off');
-}
-
-function harmonyDeviceCommand($device, $command) {
-//     haEvent();
-//     return harmonyRequest('devices/' . $device . '/commands/' . $command, 'POST');
 }
\ No newline at end of file
index 2332fc1453c24f81e23ebcbf465cbc70ac09ef03..4c33dd3dfd991376169570973aaddb3b9aa96247 100644 (file)
@@ -39,11 +39,12 @@ function haGetState($id, $attribute = null) { //ID to read - for example sensor.
 }
 
 
-function haAction($id, $action = 'turn_on', $domain = null) {
+function haAction($id, $action = 'turn_on', $domain = null, $data = []) {
+       $data['entity_id'] = $id;
        $opts = [
                "http" => [
                        "method" => "POST",
-                       'content' => json_encode(['entity_id' => $id]),
+                       'content' => json_encode($data),
                        "header" =>
                                "Content-Type: application/json\r\n" .
                                "Authorization: Bearer " . HA_KEY . "\r\n"
@@ -56,7 +57,7 @@ function haAction($id, $action = 'turn_on', $domain = null) {
        }
 
        $ctx = stream_context_create($opts);
-       $data = @file_get_contents(HA_URL . 'api/services/' . $domain . '/' . $action, false, $ctx);
+       $data = file_get_contents(HA_URL . 'api/services/' . $domain . '/' . $action, false, $ctx);
        if (!$data)
                return false;
        $data = json_decode($data);
index 7f6280a3515519977a95bfd2573daf0db8e082e8..1b8de03b898e3113305c2ed345006243f7de5054 100644 (file)
@@ -472,7 +472,7 @@ $scenes = [
                ['type' => 'domoticz', 'device' => '3529', 'command' => true, 'priority' => true],
        ],
        'bureau/fan/toggle' => [
-               ['type' => 'function', 'function' => 'harmonyDeviceCommand', 'args' => ['klarstein-whisperwind', 'power-toggle']],
+               ['type' => 'ha', 'device' => 'script.klarstein_fan_toggle'],
        ],
        'bureau/auto' => [
                ['type' => 'function', 'function' => 'bureauAuto', 'args' => [true]],
@@ -900,7 +900,7 @@ $scenes = [
                ['type' => 'ha', 'device' => HA_ECO_SUPER, 'command' => 'turn_off'],
        ],
        'ecomode/notsuper' => [
-               ['type' => 'ha', 'device' => HA_ECO_SUPER, 'command' => 'turn_on'],
+               ['type' => 'ha', 'device' => HA_ECO_SUPER],
        ],
        'ecomode/on' => [
                ['type' => 'scene', 'scene' => 'ecomode/basic'],
@@ -908,7 +908,7 @@ $scenes = [
        ],
        'ecomode/off' => [
                ['type' => 'scene', 'scene' => 'ecomode/notsuper'],
-               ['type' => 'ha', 'device' => HA_ECO_BASIC, 'command' => 'turn_on'],
+               ['type' => 'ha', 'device' => HA_ECO_BASIC],
        ],
 ];
 
@@ -1009,7 +1009,7 @@ function execScene($name, $fromUserAction = false, $transitionTime = null) {
                        }
                        domoticzSwitch($action['device'], $action['command'], isset($action['switchtype']) ? $action['switchtype'] : 'light', $action['priority'] ?? false);
                } else if ($action['type'] === 'ha') {
-                       haAction($action['device'], $action['command']);
+                       haAction($action['device'], $action['command'] ?? null);
                } else if ($action['type'] == 'ir') {
                        irsend($action['room'], $action['device'], $action['command']);
                } else if ($action['type'] == 'ifttt') {