<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">
<?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
<?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;
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\');');
}
}
function stopHarmony() {
harmonyActivity('off');
-}
-
-function harmonyDeviceCommand($device, $command) {
-// haEvent();
-// return harmonyRequest('devices/' . $device . '/commands/' . $command, 'POST');
}
\ No newline at end of file
}
-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"
}
$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);
['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]],
['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'],
],
'ecomode/off' => [
['type' => 'scene', 'scene' => 'ecomode/notsuper'],
- ['type' => 'ha', 'device' => HA_ECO_BASIC, 'command' => 'turn_on'],
+ ['type' => 'ha', 'device' => HA_ECO_BASIC],
],
];
}
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') {