-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Для Aqara AC Companion добавлен функционал чтения (обучения) IR-команд, отправки IR-команд (метрика ir_play), управления встроенным реле (метрика power), получения потребляемой мощности (метрика load_power). * Передача параметров *NEW_VALUE* и *OLD_VALUE* в привязанный метод. * Мелкие исправления.
- Loading branch information
1 parent
be68471
commit 316ce17
Showing
9 changed files
with
407 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
/* | ||
* @author <[email protected]> | ||
* @copyright 2017-2018 Agaphonov Dmitri aka skysilver <[email protected]> (c) | ||
* @version 1.8b | ||
* @version 1.8.5b | ||
*/ | ||
|
||
if ($this->owner->name == 'panel') { | ||
|
@@ -17,7 +17,7 @@ | |
|
||
$this->getConfig(); | ||
$ok = 1; | ||
|
||
if ($this->tab == '') { | ||
|
||
global $title; | ||
|
@@ -33,10 +33,10 @@ | |
$out['ERR_IP'] = 1; | ||
$ok = 0; | ||
} | ||
|
||
global $token; | ||
$rec['TOKEN'] = $token; | ||
|
||
global $device_type; | ||
$rec['DEVICE_TYPE'] = $device_type; | ||
|
||
|
@@ -45,21 +45,23 @@ | |
if ($rec['UPDATE_PERIOD'] > 0) { | ||
$rec['NEXT_UPDATE'] = date('Y-m-d H:i:s'); | ||
} | ||
|
||
$commands = array('online', 'command', 'message'); | ||
if (($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
$commands[] = 'add_program'; | ||
$commands[] = 'del_program'; | ||
} | ||
if ($rec['DEVICE_TYPE'] == 'chuangmi.ir.v2') { | ||
if ($rec['DEVICE_TYPE'] == 'chuangmi.ir.v2' || $rec['DEVICE_TYPE'] == 'lumi.acpartner.v3') { | ||
$commands[] = 'ir_play'; | ||
//$commands[] = 'freq'; | ||
} | ||
if ($rec['DEVICE_TYPE'] == 'xiaomi.wifispeaker.v1') { | ||
$commands[] = 'vol_up'; | ||
$commands[] = 'vol_down'; | ||
} | ||
|
||
if ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3') { | ||
$commands[] = 'power'; | ||
$commands[] = 'load_power'; | ||
} | ||
} | ||
|
||
if ($ok) { | ||
|
@@ -95,7 +97,13 @@ | |
if ($rec['TOKEN'] != '' && $rec['IP'] != '') { | ||
$this->requestInfo($rec['ID']); | ||
// а также, если определен тип устройства, то запросим текущие параметры (статус). | ||
if ((int)$update_period == 0 && $rec['DEVICE_TYPE'] != '') $this->requestStatus($rec['ID']); | ||
if ($rec['DEVICE_TYPE'] != '') { | ||
$this->requestStatus($rec['ID']); | ||
if (($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
$this->addToQueue($rec['ID'], 'get_lumi_dpf_aes_key', '[]'); | ||
$this->addToQueue($rec['ID'], 'get_zigbee_channel', '[]'); | ||
} | ||
} | ||
// Если тип устройства не указан, то пробуем получить тип устройства из miIO.info | ||
if ($rec['DEVICE_TYPE'] == '') { | ||
if ($this->config['API_LOG_DEBMES']) DebMes('Try to get device model from miIO.info for the device ' . $rec['IP'], 'xiaomimiio'); | ||
|
@@ -135,44 +143,46 @@ | |
|
||
$new_id = 0; | ||
global $delete_id; | ||
|
||
if ($delete_id) { | ||
SQLExec("DELETE FROM miio_commands WHERE ID='" . (int)$delete_id . "'"); | ||
} | ||
|
||
if (($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
// Для шлюза на вкладку data выводим только определенные свойства, т.к. для свойств радио есть отдельная вкладка | ||
$properties = SQLSelect("SELECT * FROM miio_commands WHERE DEVICE_ID='" . $rec['ID'] . "' AND TITLE IN ('online','command','message','lumi_dpf_aes_key','zigbee_channel') ORDER BY ID"); | ||
} else { | ||
$properties = SQLSelect("SELECT * FROM miio_commands WHERE DEVICE_ID='" . $rec['ID'] . "' ORDER BY ID"); | ||
} | ||
|
||
|
||
if ($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
// Для шлюза на вкладку data выводим только определенные свойства, т.к. для свойств радио есть отдельная вкладка | ||
$properties = SQLSelect("SELECT * FROM miio_commands WHERE DEVICE_ID='" . $rec['ID'] . "' AND TITLE IN ('online','command','message','lumi_dpf_aes_key','zigbee_channel') ORDER BY ID"); | ||
} else if ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3') { | ||
$properties = SQLSelect("SELECT * FROM miio_commands WHERE DEVICE_ID='" . $rec['ID'] . "' AND TITLE IN ('online','command','message','lumi_dpf_aes_key','zigbee_channel', 'ir_play', 'power', 'load_power') ORDER BY ID"); | ||
} else { | ||
$properties = SQLSelect("SELECT * FROM miio_commands WHERE DEVICE_ID='" . $rec['ID'] . "' ORDER BY ID"); | ||
} | ||
|
||
$total = count($properties); | ||
|
||
for($i = 0; $i < $total; $i++) { | ||
if ($properties[$i]['ID'] == $new_id) continue; | ||
|
||
if ($this->mode == 'update') { | ||
|
||
global ${'linked_object'.$properties[$i]['ID']}; | ||
$properties[$i]['LINKED_OBJECT'] = trim(${'linked_object'.$properties[$i]['ID']}); | ||
|
||
global ${'linked_property'.$properties[$i]['ID']}; | ||
$properties[$i]['LINKED_PROPERTY'] = trim(${'linked_property'.$properties[$i]['ID']}); | ||
|
||
global ${'linked_method'.$properties[$i]['ID']}; | ||
$properties[$i]['LINKED_METHOD'] = trim(${'linked_method'.$properties[$i]['ID']}); | ||
|
||
SQLUpdate('miio_commands', $properties[$i]); | ||
|
||
$old_linked_object = $properties[$i]['LINKED_OBJECT']; | ||
$old_linked_property = $properties[$i]['LINKED_PROPERTY']; | ||
|
||
if ($old_linked_object && $old_linked_object != $properties[$i]['LINKED_OBJECT'] && $old_linked_property && $old_linked_property != $properties[$i]['LINKED_PROPERTY']) { | ||
removeLinkedProperty($old_linked_object, $old_linked_property, $this->name); | ||
} | ||
} | ||
|
||
$properties[$i]['VALUE'] = str_replace('",','", ',$properties[$i]['VALUE']); | ||
|
||
if ($properties[$i]['LINKED_OBJECT'] && $properties[$i]['LINKED_PROPERTY']) { | ||
|
@@ -280,7 +290,6 @@ | |
} else { | ||
$out['LAN_KEY'] = ''; | ||
} | ||
//$out['LAN_KEY'] = ''; | ||
} | ||
|
||
if ($this->tab == 'help') { | ||
|
Oops, something went wrong.