-
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.
* Добавлена поддержка очистителя воздуха Mi Air Purifier 2S: * получение текущего статуса и параметров (power, aqi, average_aqi, humidity, temperature, illumination, mode, favorite_level, filter1_life, use_time, purify_volume, led, buzzer, child_lock); * включение/выключение (power); * смена режима работы (auto, silent, favorite); * управление скоростью вращения вентилятора в режиме favorite (favorite_level); * управление led-индикатором (led); * управление звуковым сигналом (buzzer); * управление родительским контролем (child_lock). * Добавлена поддержка шлюза Aqara AC Companion Gateway: * получение номера zigbee-канала; * получение пароля для взаимодействия в режиме разработчика; * получение статуса радио (состояние, громкость, текущий трек); * управление громкостью радио; * управление воспроизведением радио (on, off, toggle, prev, next); * воспроизведение заданной радиостанции; * добавление новой радиостанции в список избранного; * удаление радиостанции из списка избранного; * получение списка суб-устройств; * удаление (отвязывание) суб-устройств; * перевод шлюза в режим сопряжения для добавления нового суб-устройства. * Добавлен механизм встроенной справки.
- Loading branch information
1 parent
0ea629e
commit 2b2e54c
Showing
32 changed files
with
258 additions
and
78 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
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.4b | ||
* @version 1.5b | ||
*/ | ||
|
||
if ($this->owner->name == 'panel') { | ||
|
@@ -47,7 +47,7 @@ | |
} | ||
|
||
$commands = array('online', 'command', 'message'); | ||
if ($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
if (($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
$commands[] = 'add_program'; | ||
$commands[] = 'del_program'; | ||
} | ||
|
@@ -140,7 +140,7 @@ | |
SQLExec("DELETE FROM miio_commands WHERE ID='" . (int)$delete_id . "'"); | ||
} | ||
|
||
if ($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
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 { | ||
|
@@ -178,53 +178,39 @@ | |
if ($properties[$i]['LINKED_OBJECT'] && $properties[$i]['LINKED_PROPERTY']) { | ||
addLinkedProperty($properties[$i]['LINKED_OBJECT'], $properties[$i]['LINKED_PROPERTY'], $this->name); | ||
} | ||
|
||
if (file_exists(DIR_MODULES . 'devices/devices.class.php')) { | ||
if ($properties[$i]['TITLE'] == 'power') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'buzzer') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'wifi_led') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'usb_on') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'bright') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'cct') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'ct') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'nl_br') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'rgb') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'rgb'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'temperature') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'sensor_temp'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'humidity') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'sensor_humidity'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'current') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'sensor_current'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'power_consume_rate') { | ||
$properties[$i]['SDEVICE_TYPE'] = 'sensor_power'; | ||
} | ||
if ($properties[$i]['TITLE'] == 'power') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'buzzer') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'wifi_led') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'usb_on') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'led') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'child_lock') $properties[$i]['SDEVICE_TYPE'] = 'relay'; | ||
elseif ($properties[$i]['TITLE'] == 'bright') $properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
elseif ($properties[$i]['TITLE'] == 'cct') $properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
elseif ($properties[$i]['TITLE'] == 'ct') $properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
elseif ($properties[$i]['TITLE'] == 'nl_br') $properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
elseif ($properties[$i]['TITLE'] == 'rgb') $properties[$i]['SDEVICE_TYPE'] = 'rgb'; | ||
elseif ($properties[$i]['TITLE'] == 'temperature') $properties[$i]['SDEVICE_TYPE'] = 'sensor_temp'; | ||
elseif ($properties[$i]['TITLE'] == 'humidity') $properties[$i]['SDEVICE_TYPE'] = 'sensor_humidity'; | ||
elseif ($properties[$i]['TITLE'] == 'illumination') $properties[$i]['SDEVICE_TYPE'] = 'sensor_light'; | ||
elseif ($properties[$i]['TITLE'] == 'current') $properties[$i]['SDEVICE_TYPE'] = 'sensor_current'; | ||
elseif ($properties[$i]['TITLE'] == 'power_consume_rate') $properties[$i]['SDEVICE_TYPE'] = 'sensor_power'; | ||
elseif ($properties[$i]['TITLE'] == 'aqi') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'average_aqi') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'favorite_level') $properties[$i]['SDEVICE_TYPE'] = 'dimmer'; | ||
elseif ($properties[$i]['TITLE'] == 'filter1_life') $properties[$i]['SDEVICE_TYPE'] = 'sensor_percentage'; | ||
elseif ($properties[$i]['TITLE'] == 'f1_hour_used') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'use_time') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'motor1_speed') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'purify_volume') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
elseif ($properties[$i]['TITLE'] == 'f1_hour') $properties[$i]['SDEVICE_TYPE'] = 'sensor_state'; | ||
} | ||
} | ||
$out['PROPERTIES'] = $properties; | ||
} | ||
|
||
if ($this->tab == 'gwradio' && $rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
if ($this->tab == 'gwradio' && (($rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($rec['DEVICE_TYPE'] == 'lumi.acpartner.v3'))) { | ||
|
||
$new_id = 0; | ||
global $delete_id; | ||
|
@@ -271,6 +257,16 @@ | |
|
||
} | ||
|
||
if ($this->tab == 'help') { | ||
$out['LANG'] = SETTINGS_SITE_LANGUAGE; | ||
$out['HELP_PATH'] = DIR_TEMPLATES . 'xiaomimiio/help/' . SETTINGS_SITE_LANGUAGE . '/help_' . $rec['DEVICE_TYPE'] . '.html'; | ||
// Проверим наличие файла-справки для текущего языка МДМ | ||
if (!file_exists($out['HELP_PATH'])) { | ||
// если файла нет, то выводим файл-справку на русском языке | ||
$out['HELP_PATH'] = DIR_TEMPLATES . 'xiaomimiio/help/ru/help_' . $rec['DEVICE_TYPE'] . '.html'; | ||
} | ||
} | ||
|
||
if (is_array($rec)) { | ||
foreach($rec as $k => $v) { | ||
if (!is_array($v)) { | ||
|
@@ -279,4 +275,14 @@ | |
} | ||
} | ||
|
||
//DebMes(serialize($out), 'xiaomimiio'); | ||
/* | ||
{s:6:"API_IP";s:0:""; s:15:"API_DISC_PERIOD";i:120; s:14:"API_LOG_DEBMES";i:1; s:13:"API_LOG_CYCLE";i:1; s:12:"API_LOG_MIIO";i:0; s:8:"CYCLERUN";i:0; s:14:"SET_DATASOURCE";i:1; s:12:"CONTROLPANEL";i:1; s:4:"LANG";s:2:"ru";} | ||
*/ | ||
|
||
//DebMes(serialize($rec), 'xiaomimiio'); | ||
/* | ||
{s:2:"ID";s:2:"33"; s:5:"TITLE";s:18:"Mi Air Purifier 2S"; s:2:"IP";s:13:"192.168.1.200"; s:5:"TOKEN";s:0:""; s:3:"MAC"; s:0:""; s:11:"DEVICE_TYPE";s:21:"zhimi.airpurifier.ma2"; s:16:"DEVICE_TYPE_CODE";s:0:""; s:9:"TIME_DIFF";s:1:"0"; s:5:"MODEL";s:0:""; s:6:"HW_VER";s:0:""; s:6:"SERIAL";s:0:""; s:8:"SETTINGS";s:0:""; s:13:"UPDATE_PERIOD";s:1:"0"; s:11:"NEXT_UPDATE";s:0:""; s:7:"UPDATED";s:0:"";} | ||
*/ | ||
|
||
outHash($rec, $out); |
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 |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
* @package project | ||
* @author <[email protected]> | ||
* @copyright 2017-2018 Agaphonov Dmitri aka skysilver <[email protected]> (c) | ||
* @version 1.4b | ||
* @version 1.5b | ||
*/ | ||
|
||
define ('MIIO_YEELIGHT_WHITE_BULB_PROPS', 'power,bright'); | ||
|
@@ -26,6 +26,8 @@ | |
|
||
define ('MIIO_ZHIMI_HUMIDIFIER_PROPS', 'power,mode,temp_dec,humidity,buzzer,led_b'); | ||
|
||
define ('MIIO_ZHIMI_AIRPURIFIER_MA2_PROPS', 'power,aqi,average_aqi,humidity,temp_dec,bright,mode,favorite_level,filter1_life,use_time,purify_volume,led,buzzer,child_lock'); | ||
|
||
define ('MIIO_MIWIFISPEAKER_V1_PROPS', 'umi,volume,rel_time'); | ||
|
||
define ('MIIO_MIVACUUM_1_STATE_CODES', serialize (array('0' => 'Unknown', | ||
|
@@ -404,7 +406,7 @@ function discover($ip = '') { | |
|
||
if ($dev_rec['DEVICE_TYPE'] != '') { | ||
$this->requestStatus($dev_rec['ID']); | ||
if ($dev_rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
if (($dev_rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($dev_rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
$this->processCommand($dev_rec['ID'], 'add_program', ''); | ||
$this->processCommand($dev_rec['ID'], 'del_program', ''); | ||
} | ||
|
@@ -465,7 +467,7 @@ function requestInfo($device_id) { | |
function requestStatus($device_id) { | ||
|
||
$device_rec = SQLSelectOne("SELECT * FROM miio_devices WHERE ID=" . (int)$device_id); | ||
|
||
if ($device_rec['DEVICE_TYPE'] == 'philips.light.bulb') { | ||
// | ||
$props = explode(',', MIIO_PHILIPS_LIGHT_BULB_PROPS); | ||
|
@@ -519,7 +521,7 @@ function requestStatus($device_id) { | |
$props[$i] = '"' . $props[$i] . '"'; | ||
} | ||
$this->addToQueue($device_id, 'get_prop', '[' . implode(',', $props) . ']'); | ||
} elseif ($device_rec['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
} elseif (($device_rec['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($device_rec['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
// | ||
$this->addToQueue($device_id, 'get_prop_fm', '[]'); | ||
if ($this->view_mode == 'propupd_miio_devices') { | ||
|
@@ -575,6 +577,14 @@ function requestStatus($device_id) { | |
$props[$i] = '"' . $props[$i] . '"'; | ||
} | ||
$this->addToQueue($device_id, 'get_prop', '[' . implode(',', $props) . ']'); | ||
} elseif ($device_rec['DEVICE_TYPE'] == 'zhimi.airpurifier.ma2') { | ||
// | ||
$props = explode(',', MIIO_ZHIMI_AIRPURIFIER_MA2_PROPS); | ||
$total = count($props); | ||
for ($i = 0; $i < $total; $i++) { | ||
$props[$i] = '"' . $props[$i] . '"'; | ||
} | ||
$this->addToQueue($device_id, 'get_prop', '[' . implode(',', $props) . ']'); | ||
} elseif ($device_rec['DEVICE_TYPE'] == 'yeelink.light.bslamp1') { | ||
// | ||
$props = explode(',', MIIO_YEELIGHT_BSLAMP1_PROPS); | ||
|
@@ -592,7 +602,7 @@ function requestStatus($device_id) { | |
} | ||
$this->addToQueue($device_id, 'get_prop', '[' . implode(',', $props) . ']'); | ||
} | ||
|
||
} | ||
|
||
/** | ||
|
@@ -769,7 +779,7 @@ function propertySetHandle($object, $property, $value) { | |
} | ||
// TO-DO: Если у-во yeelight, то используем дополнительные опции команды (effect, duration, mode). | ||
} elseif ($properties[$i]['TITLE'] == 'buzzer') { | ||
// Команда на включение и выключение | ||
// Команда на включение и выключение пищалки | ||
if ($value) { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_buzzer', '["on"]'); | ||
} else { | ||
|
@@ -864,9 +874,29 @@ function propertySetHandle($object, $property, $value) { | |
if ($value < 1) $value = 1; | ||
if ($value > 100) $value = 100; | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'vol_down', "[$value]"); | ||
} elseif ($properties[$i]['TITLE'] == 'led') { | ||
// | ||
if ($value) { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_led', '["on"]'); | ||
} else { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_led', '["off"]'); | ||
} | ||
} elseif ($properties[$i]['TITLE'] == 'child_lock') { | ||
// | ||
if ($value) { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_child_lock', '["on"]'); | ||
} else { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_child_lock', '["off"]'); | ||
} | ||
} elseif ($properties[$i]['TITLE'] == 'favorite_level') { | ||
// | ||
$value = (int)$value; | ||
if ($value < 0) $value = 0; | ||
if ($value > 100) $value = 100; | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_level_favorite', "[$value]"); | ||
} | ||
|
||
if($properties[$i]['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
if(($properties[$i]['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($properties[$i]['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
if ($properties[$i]['TITLE'] == 'current_volume') { | ||
// Изменение громкости | ||
$value = (int)$value; | ||
|
@@ -924,6 +954,15 @@ function propertySetHandle($object, $property, $value) { | |
} | ||
} | ||
|
||
if($properties[$i]['DEVICE_TYPE'] == 'zhimi.airpurifier.ma2') { | ||
if ($properties[$i]['TITLE'] == 'mode') { | ||
// Изменение режима (silent, auto, favorite) | ||
if ($value == 'silent' || $value == 'auto' || $value == 'favorite') { | ||
$this->addToQueue($properties[$i]['DEVICE_ID'], 'set_mode', '["' . $value . '"]'); | ||
} | ||
} | ||
} | ||
|
||
SQLExec("UPDATE miio_commands SET VALUE='".DBSafe($value)."' WHERE ID=".$properties[$i]['ID']); | ||
//TO-DO: также обновлять поле UPDATED | ||
} | ||
|
@@ -1035,7 +1074,7 @@ function processMessage($message, $command, $device_id) { | |
$res_commands[] = array('command' => 'message', 'value' => $message); | ||
|
||
|
||
if ($device['DEVICE_TYPE'] == 'lumi.gateway.v3') { | ||
if (($device['DEVICE_TYPE'] == 'lumi.gateway.v3') || ($device['DEVICE_TYPE'] == 'lumi.acpartner.v3')) { | ||
if ($command == 'get_prop_fm' && is_array($data['result'])) { | ||
foreach($data['result'] as $key => $value) { | ||
$res_commands[] = array('command' => $key, 'value' => $value); | ||
|
@@ -1198,6 +1237,19 @@ function processMessage($message, $command, $device_id) { | |
$res_commands[] = array('command' => $key, 'value' => $value); | ||
$i++; | ||
} | ||
} elseif ($device['DEVICE_TYPE'] == 'zhimi.airpurifier.ma2' && $command == 'get_prop' && is_array($data['result'])) { | ||
$props = explode(',', MIIO_ZHIMI_AIRPURIFIER_MA2_PROPS); | ||
$i = 0; | ||
foreach($props as $key) { | ||
$value = $data['result'][$i]; | ||
if ($key == 'temp_dec') { | ||
$value = $value / 10; | ||
$key = 'temperature'; | ||
} | ||
if ($key == 'bright') $key = 'illumination'; | ||
$res_commands[] = array('command' => $key, 'value' => $value); | ||
$i++; | ||
} | ||
} elseif ($device['DEVICE_TYPE'] == 'yeelink.light.bslamp1' && $command == 'get_prop' && is_array($data['result'])) { | ||
$props = explode(',', MIIO_YEELIGHT_BSLAMP1_PROPS); | ||
$i = 0; | ||
|
@@ -1221,7 +1273,7 @@ function processMessage($message, $command, $device_id) { | |
foreach ($res_commands as $c) { | ||
$cmd = $c['command']; | ||
$val = $c['value']; | ||
if ($cmd == 'power' || $cmd == 'wifi_led' || $cmd == 'buzzer') { | ||
if ($cmd == 'power' || $cmd == 'wifi_led' || $cmd == 'buzzer' || $cmd == 'led' || $cmd == 'child_lock') { | ||
if ($val == 'on') $val = 1; | ||
else if ($val == 'off') $val = 0; | ||
} | ||
|
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<br/> | ||
<br/> | ||
<#LANG_XIMI_APP_IN_DEVELOPMENT#> |
Oops, something went wrong.