-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v.0.5-beta [Версия для тестирования]
* Добавлена поддержка умения **temperature**. * Добавлена возможность переопределить диапазон значений и шаг изменения величины для умений volume, channel, temperature, brightness. * Изменено время жизни токена доступа OAuth с 12 часов до 7 дней.
- Loading branch information
1 parent
e965fae
commit dd4518b
Showing
7 changed files
with
206 additions
and
24 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* Главный класс модуля Yandex Home | ||
* @author <[email protected]> | ||
* @copyright 2019 Agaphonov Dmitri aka skysilver <[email protected]> (c) | ||
* @version 0.4b 2019/06/20 | ||
* @version 0.5b 2019/07/01 | ||
*/ | ||
|
||
const PREFIX_CAPABILITIES = 'devices.capabilities.'; | ||
|
@@ -337,6 +337,7 @@ function edit_yandexhome_devices(&$out, $id) | |
|
||
// Поддерживаемые метрики (возможности) устройств. | ||
$out['DEVICES_INSTANCE'] = array_values($this->devices_instance); | ||
$out['DEVICES_INSTANCE_JSON'] = json_encode($this->devices_instance, JSON_UNESCAPED_UNICODE); | ||
|
||
// Список местоположений (комнат) в системе. | ||
$out['LOCATIONS'] = SQLSelect('SELECT ID, TITLE FROM locations ORDER BY TITLE'); | ||
|
@@ -387,13 +388,16 @@ function edit_yandexhome_devices(&$out, $id) | |
$old_dev_traits = json_decode($rec['TRAITS'], true); | ||
// Новые (в формате json). | ||
$rec['TRAITS'] = gr('traits_json'); | ||
// Новые (в формате json). | ||
// Новые (массив). | ||
$new_dev_traits = json_decode($rec['TRAITS'], true); | ||
if ($rec['TRAITS'] == '' || count($new_dev_traits) == 0) { | ||
$out['ERR_TRAITS'] = 1; | ||
$ok = 0; | ||
} | ||
|
||
// Конфигурация умений. | ||
$devices_instance = json_decode(gr('instance_json'), true); | ||
|
||
// Если обязательные поля заполнены, то сохраняем конфигурацию устройства. | ||
if ($ok) { | ||
if ($rec['ID']) { | ||
|
@@ -403,8 +407,8 @@ function edit_yandexhome_devices(&$out, $id) | |
foreach ($new_dev_traits as $trait) { | ||
$parameters = []; | ||
$trait_type = PREFIX_CAPABILITIES . $this->devices_instance[$trait['type']]['capability']; | ||
if (isset($this->devices_instance[$trait['type']]['parameters'])) { | ||
$parameters = $this->devices_instance[$trait['type']]['parameters']; | ||
if (isset($devices_instance[$trait['type']]['parameters'])) { | ||
$parameters = $devices_instance[$trait['type']]['parameters']; | ||
if ($trait['type'] != 'rgb' && $trait['type'] != 'temperature_k') { | ||
$parameters['instance'] = $trait['type']; | ||
} | ||
|
@@ -421,9 +425,15 @@ function edit_yandexhome_devices(&$out, $id) | |
if ($check && $trait_type == PREFIX_CAPABILITIES.'color_setting') { | ||
$traits[$check]['parameters'] = array_merge ($traits[$check]['parameters'], $parameters); | ||
} else { | ||
if (isset($this->devices_instance[$trait['type']]['retrievable'])) { | ||
$retrievable = $this->devices_instance[$trait['type']]['retrievable']; | ||
} else { | ||
$retrievable = true; | ||
} | ||
$traits[] = [ | ||
'type' => $trait_type, | ||
'parameters' => $parameters | ||
'parameters' => $parameters, | ||
'retrievable' => $retrievable | ||
]; | ||
} | ||
} | ||
|
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