Skip to content

Commit

Permalink
Merge pull request sergejey#458 from sergejey/alpha
Browse files Browse the repository at this point in the history
Alpha
  • Loading branch information
sergejey authored Jan 5, 2019
2 parents 9c1f3f1 + f9688ce commit 0fdd61b
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 2 deletions.
5 changes: 5 additions & 0 deletions languages/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -1207,6 +1207,11 @@
'DEVICES_LINK_SWITCH_IT_DESCRIPTION' => 'Control another devices when action triggered',
'DEVICES_LINK_SWITCH_IT_PARAM_ACTION_DELAY' => 'Delay (seconds)',

'DEVICES_LINK_SWITCH_TIMER' => 'Turn on for some time',
'DEVICES_LINK_SWITCH_TIMER_DESCRIPTION' => 'Turn on another devices for some time when action triggered',
'DEVICES_LINK_SWITCH_TIMER_PARAM_ACTION_DELAY' => 'For how long (seconds)',
'DEVICES_LINK_SWITCH_TIMER_PARAM_DARKTIME' => 'Only when it\'s dark',

'DEVICES_LINK_SET_COLOR' => 'Set Color',
'DEVICES_LINK_SET_COLOR_DESCRIPTION' => 'Change color when action triggered',
'DEVICES_LINK_SET_COLOR_PARAM_ACTION_COLOR' => 'Color',
Expand Down
5 changes: 5 additions & 0 deletions languages/ru.php
Original file line number Diff line number Diff line change
Expand Up @@ -1203,6 +1203,11 @@
'DEVICES_LINK_SWITCH_IT_DESCRIPTION' => 'Управление другим устройством по событию',
'DEVICES_LINK_SWITCH_IT_PARAM_ACTION_DELAY' => 'Задержка выполнения (секунд)',

'DEVICES_LINK_SWITCH_TIMER' => 'Включить на время',
'DEVICES_LINK_SWITCH_TIMER_DESCRIPTION' => 'Включить другое устройство на некоторое время по событию',
'DEVICES_LINK_SWITCH_TIMER_PARAM_ACTION_DELAY' => 'Включить на какое время (секунд)',
'DEVICES_LINK_SWITCH_TIMER_PARAM_DARKTIME' => 'Только в тёмное время',

'DEVICES_LINK_SET_COLOR' => 'Установить цвет',
'DEVICES_LINK_SET_COLOR_DESCRIPTION' => 'Установить цвет по событию',
'DEVICES_LINK_SET_COLOR_PARAM_ACTION_COLOR' => 'Цвет',
Expand Down
10 changes: 10 additions & 0 deletions modules/devices/devices_links_actions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@
if ((int)$settings['action_delay'] > 0) {
$action_string = 'setTimeout(\'' . $timer_name . '\',\'' . $action_string . '\',' . (int)$settings['action_delay'] . ');';
}
} elseif ($link_type=='switch_timer') {
$action_string='';
if ($settings['darktime']) {
$action_string.='if (gg("DarknessMode.active")) {';
}
$action_string.= 'callMethod("' . $object . '.turnOn' . '");';
$action_string.= 'setTimeout(\'' . $timer_name . '\',\'' . 'callMethod("' . $object . '.turnOff' . '");' . '\',' . (int)$settings['action_delay'] . ');';
if ($settings['darktime']) {
$action_string.='}';
}
} elseif ($link_type=='set_color') {
$action_string='callMethod("'.$object.'.setColor'.'",array("color"=>"'.$settings['action_color'].'"));';
if ((int)$settings['action_delay']>0) {
Expand Down
22 changes: 22 additions & 0 deletions modules/devices/devices_structure_links.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,28 @@

$this->device_links=array(
'SMotions,SButtons'=>array(
array(
'LINK_NAME'=>'switch_timer',
'LINK_TITLE'=>LANG_DEVICES_LINK_SWITCH_TIMER,
'LINK_DESCRIPTION'=>LANG_DEVICES_LINK_SWITCH_TIMER_DESCRIPTION,
'TARGET_CLASS'=>'SControllers',
'PARAMS'=>array(
array(
'PARAM_NAME'=>'action_delay',
'PARAM_TITLE'=>LANG_DEVICES_LINK_SWITCH_TIMER_PARAM_ACTION_DELAY,
'PARAM_TYPE'=>'num'
),
array(
'PARAM_NAME'=>'darktime',
'PARAM_TITLE'=>LANG_DEVICES_LINK_SWITCH_TIMER_PARAM_DARKTIME,
'PARAM_TYPE'=>'select',
'PARAM_OPTIONS'=>array(
array('TITLE'=>LANG_NO,'VALUE'=>'0'),
array('TITLE'=>LANG_YES,'VALUE'=>'1')
)
)
)
),
array(
'LINK_NAME'=>'switch_it',
'LINK_TITLE'=>LANG_DEVICES_LINK_SWITCH_IT,
Expand Down
4 changes: 3 additions & 1 deletion objects/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
include_once(DIR_MODULES . "application.class.php");
include_once("./load_settings.php");

$session = new session("prj");
if (gr('prj')) {
$session = new session("prj");
}

if ($argv[1] != '') {
$commandLine = 1;
Expand Down
2 changes: 1 addition & 1 deletion scripts/cycle_scheduler.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
echo date("H:i:s") . " running " . basename(__FILE__) . PHP_EOL;

while (1) {
if (time() - $checked_time > 5) {
if ((time()-$checked_time)>5) {
$checked_time = time();
setGlobal((str_replace('.php', '', basename(__FILE__))) . 'Run', time(), 1);
}
Expand Down

0 comments on commit 0fdd61b

Please sign in to comment.