Skip to content

Commit

Permalink
Merge pull request #1058 from whitevast/patch-1
Browse files Browse the repository at this point in the history
Openable Homebridge
  • Loading branch information
sergejey authored Oct 2, 2022
2 parents 5b6fc7c + ec890e1 commit 21e048d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
8 changes: 4 additions & 4 deletions modules/devices/devices_links_actions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,16 @@
} elseif ($open_type == 'door' || $open_type == 'window' || $open_type == 'curtains' || $open_type == 'shutters') {
$payload['characteristic'] = 'CurrentPosition';
if (gg($device1['LINKED_OBJECT'] . '.status')) {
$payload['value'] = "100";
} else {
$payload['value'] = "0";
} else {
$payload['value'] = "100";
}
if ($debug_sync) {
DebMes("MQTT to_set : " . json_encode($payload), 'homebridge');
}
sg('HomeBridge.to_set', json_encode($payload));
//$payload['characteristic'] = 'TargetPosition';
//sg('HomeBridge.to_set', json_encode($payload));
$payload['characteristic'] = 'TargetPosition';
sg('HomeBridge.to_set', json_encode($payload));
unset($payload['service']);
}
}
Expand Down
8 changes: 5 additions & 3 deletions modules/devices/homebridgeSync.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,15 @@
} elseif ($open_type == 'door' || $open_type == 'window' || $open_type == 'curtains' || $open_type == 'shutters') {
$payload['characteristic'] = 'CurrentPosition';
if (gg($devices[$i]['LINKED_OBJECT'] . '.status')) {
$payload['value'] = "100";
$payload['value'] = "0"; // открыто на 0% (закрыто)
} else {
$payload['value'] = "0";
$payload['value'] = "100"; // открыто на 100% (открыто)
}
sg('HomeBridge.to_set', json_encode($payload));
$payload['characteristic'] = 'TargetPosition';
$payload['value'] = "100";
sg('HomeBridge.to_set', json_encode($payload));
$payload['characteristic'] = 'PositionState';
$payload['value'] = "2"; //0 - "Закрывается" 1 - "Открывается" 2 - нет отображения
sg('HomeBridge.to_set', json_encode($payload));
}
}
Expand Down
12 changes: 6 additions & 6 deletions modules/devices/processHomebridgeMQTT.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,29 +89,29 @@
if ($data['characteristic']=='CurrentPosition') {
$currentStatus = (int)gg($device['LINKED_OBJECT'] . '.status');
if ($currentStatus) {
$payload['value'] = 100;
} else {
$payload['value'] = 0;
} else {
$payload['value'] = 100;
}
}
} elseif ($open_type == 'window') {
$payload['service'] = 'Window';
if ($data['characteristic']=='CurrentPosition') {
$currentStatus = (int)gg($device['LINKED_OBJECT'] . '.status');
if ($currentStatus) {
$payload['value'] = 100;
} else {
$payload['value'] = 0;
} else {
$payload['value'] = 100;
}
}
} elseif ($open_type == 'curtains' || $open_type == 'shutters') {
$payload['service'] = 'WindowCovering';
if ($data['characteristic']=='CurrentPosition') {
$currentStatus = (int)gg($device['LINKED_OBJECT'] . '.status');
if ($currentStatus) {
$payload['value'] = 100;
} else {
$payload['value'] = 0;
} else {
$payload['value'] = 100;
}
}
}
Expand Down

0 comments on commit 21e048d

Please sign in to comment.