camImagesProcess
|
Сортировка изображений с веб-камеры
$src='/var/www/media/webcam'; // откуда брать фотографии
clearTimeout('camImagesTimer');
$base_path='/var/www/dvr/unsorted';
$dst='/var/www/dvr/sorted';
safe_exec('chown pi:pi -Rf '.$base_path.'/*');
safe_exec('chmod 0777 -f '.$base_path.'/*');
setTimeout('camImagesTimer','runScript("camImagesProcess");',10*60);
if (is_dir($base_path)) {
if ($dir = @opendir($base_path)) {
while (($file = readdir($dir)) !== false) {
if ($file!='.' && $file!='..' && is_dir($base_path.'/'.$file)) {
$src=$base_path.'/'.$file;
echo $src.'<br/>';
processLine($src." -> ".$dst."/%Y/%m - %F/%d/".$file);
}
}
closedir($dir);
}
} else {
echo "Cannot open $base_path";
}
processLine("CLEAR ".$dst." 30 DAYS OLD");
|
checkFreeSpace
|
Проверка свободного места на диске
$max_usage=90; //%
$output=array();
exec('df',$output);
//var_dump($output);
$problems=0;
$problems_details='';
foreach($output as $line) {
if (preg_match('/(\d+)% (\/.+)/',$line,$m))
$proc=$m[1];
$path=$m[2];
if ($proc>$max_usage) {
$problems++;
$problems_details.="$path: $proc; ";
}
//echo "$path: $proc%<br/>";
}
sg("ThisComputer.SpaceProblems",$problems);
sg("ThisComputer.SpaceProblems_Details",$problems_details);
setTimeOut('checkFreeSpace','runScript("checkFreeSpace");',5*60);
|
rebootSystem
|
Перезапуск системы
$filename = ROOT . '/database_backup/db.sql';
$mysqlDumpPath = "/usr/bin/mysqldump";
$mysqlDumpParam = " --user=" . DB_USER . " --password=" . DB_PASSWORD;
$mysqlDumpParam .= " --no-create-db --add-drop-table --databases " . DB_NAME;
if (file_exists($filename)) rename($filename, $filename . '.prev');
exec($mysqlDumpPath . $mysqlDumpParam . " > " . $filename);
say("Подготовка к перезагрузке",2);
setTimeout("shutdownTimer","safe_exec('shutdown -r now');",15);
|
1 канал спальня
|
callMethod('Button02.pressed');
|
Hourly
|
Выполняется каждый час
|
motionDetected
|
Сработал детектор движения на веб-камере
DebMes("Motion detected: ".serialize($params));
callMethod('MotionSensorCam.motionDetected');
setTimeOut('motionDetectedTimer','runScript("camImagesProcess");',10);
if (getGlobal('ThisComputer'.'.'.'WebCamMotionAuto')) {
setTimeOut('stopWebCamDetection', " runScript('manageWebCamMotion', array('stop'=>'1'));", (int)('60'));
}
|
NobodyHome
|
Срабатывает, когда никого дома нет
say('Включаю режим экономии', 2);
callMethod('EconomMode'.'.'.'activate');
if (getGlobal('ThisComputer'.'.'.'WebCamMotionAuto')) {
runScript('manageWebCamMotion', array('start'=>'1'));
}
|
SomebodyHome
|
Срабатывает в том случае, когда кто-то появился дома
callMethod('EconomMode'.'.'.'deactivate');
say('Здравствуйте!', 2);
runScript('reportStatus', array());
if (getGlobal('ThisComputer'.'.'.'WebCamMotionAuto')) {
setTimeOut('stopWebCamDetection', " runScript('manageWebCamMotion', array('stop'=>'1'));", (int)('60'));
}
|
startUp
|
Система загружена
say('Система загружена', 2);
runScript('tellIPAddress', array());
|
turnOffEverything
|
Выключить все приборы
$objects=array('Switch1','Switch2','Switch3');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
|
Переход на пульт кухня
|
|
Выкл в коридоре без сигналки
|
callMethod('XiRelay180.turnoff'); /*Выкл розетка планшет*/
usleep(500000);
callMethod('XiRelay178.turnoff'); /*Выкл свет ванна*/
usleep(500000);
callMethod('XiRelay181.turnoff'); /*Выкл вентилятор ванна*/
usleep(500000);
callMethod('XiRelay179.turnoff'); /*Выкл свет туалет*/
usleep(500000);
callMethod('Button148.pressed'); /*ТВ Выкл кухня*/
usleep(500000);
callMethod('XiRelay150.turnoff'); /*Выкл кухня подсветка*/
usleep(500000);
callMethod('XiRelay151.turnoff'); /*Выкл кухня люстра*/
usleep(500000);
callMethod('XiRelay210.turnoff'); /*Балкон бра*/
usleep(500000);
callMethod('XiRelay209.turnoff'); /*балкон люстры*/
usleep(500000);
callMethod('XiRelay155.turnoff'); /*Выкд детская подсветка*/
usleep(500000);
callMethod('XiRelay156.turnoff'); /*Выкл детская люстра*/
usleep(500000);
callMethod('XiRelay153.turnoff'); /*Выкл зал подсветка*/
usleep(500000);
callMethod('XiRelay154.turnoff'); /*Выкл зал Люстра*/
usleep(500000);
callMethod('XiRelay158.turnoff'); /*Выкл кухня RG*/
usleep(500000);
callMethod('XiRelay159.turnoff'); /*Выкл Кухня столешница*/
usleep(500000);
callMethod('XiRelay167.turnoff'); /*Выкл люстра спальня*/
usleep(500000);
callMethod('XiRelay169.turnoff'); /*Выкл спальня БРА 1*/
usleep(500000);
callMethod('XiRelay170.turnoff'); /*Выкл спальня БРА 2*/
usleep(500000);
callMethod('Button124.pressed'); /*Выкл кондиционер*/
usleep(500000);
callMethod('Button186.pressed'); /*Выкл ТВ в зале*/
usleep(500000);
callMethod('Button176.pressed'); /*Выкл ТВ в спальне*/
usleep(500000);
callMethod('Button126.pressed'); /*Выкл DENON*/
usleep(500000);
callMethod('Relay166.turnoff'); /*Выкл розетка утюг*/
usleep(500000);
callMethod('XiRelay150.turnoff'); /*Выкл кухня подсветка*/
usleep(500000);
callMethod('XiRelay151.turnoff'); /*Выкл кухня люстра*/
usleep(500000);
callMethod('XiRelay155.turnoff'); /*Выкд детская подсветка*/
usleep(500000);
callMethod('XiRelay156.turnoff'); /*Выкл детская люстра*/
usleep(500000);
callMethod('XiRelay153.turnoff'); /*Выкл зал подсветка*/
usleep(500000);
callMethod('XiRelay154.turnoff'); /*Выкл зал Люстра*/
usleep(500000);
callMethod('XiRelay158.turnoff'); /*Выкл кухня RG*/
usleep(500000);
callMethod('XiRelay159.turnoff'); /*Выкл Кухня столешница*/
usleep(500000);
callMethod('XiRelay167.turnoff'); /*Выкл люстра спальня*/
usleep(500000);
callMethod('XiRelay169.turnoff'); /*Выкл спальня БРА 1*/
usleep(500000);
callMethod('XiRelay170.turnoff'); /*Выкл спальня БРА 2*/
usleep(500000);
callMethod('Button124.pressed'); /*Выкл кондиционер*/
usleep(500000);
callMethod('Button126.pressed'); /*Выкл DENON*/
usleep(500000);
callMethod('Relay166.turnoff'); /*Выкл розетка утюг*/
usleep(500000);
callMethod('XiRelay180.turnoff'); /*Выкл розетка планшет*/
usleep(500000);
setTimeOut('btn157', "callMethod('XiRelay157.turnoff');", 20); /*выкл свет коридор*/
setTimeOut('btn148', "callMethod('Button148.pressed');", 30); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 31); /*Выкл ТВ в зале*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 32); /*Выкл ТВ в спальне*/
setTimeOut('btn147', "callMethod('Button147.pressed');", 40); /*Выкл все гирлянды*/
setTimeOut('btn147', "callMethod('Button147.pressed');", 50); /*Выкл все гирлянды*/
setTimeOut('btn148', "callMethod('Button148.pressed');", 61); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 62); /*Выкл ТВ в зале*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 63); /*Выкл ТВ в спальне*/
|
Выключатель в коридоре с сигнализацией
|
callMethod('Relay228.turnoff'); /*Выкл экран планшета*/
usleep(500000);
callMethod('XiRelay178.turnoff'); /*Выкл свет ванна*/
usleep(500000);
callMethod('XiRelay181.turnoff'); /*Выкл вентилятор ванна*/
usleep(500000);
callMethod('XiRelay179.turnoff'); /*Выкл свет туалет*/
usleep(500000);
callMethod('Button148.pressed'); /*ТВ Выкл кухня*/
usleep(500000);
callMethod('XiRelay150.turnoff'); /*Выкл кухня подсветка*/
usleep(500000);
callMethod('XiRelay151.turnoff'); /*Выкл кухня люстра*/
usleep(500000);
callMethod('XiRelay210.turnoff'); /*Балкон бра*/
usleep(500000);
callMethod('XiRelay209.turnoff'); /*балкон люстры*/
usleep(500000);
callMethod('XiRelay155.turnoff'); /*Выкд детская подсветка*/
usleep(500000);
callMethod('XiRelay156.turnoff'); /*Выкл детская люстра*/
usleep(500000);
callMethod('XiRelay153.turnoff'); /*Выкл зал подсветка*/
usleep(500000);
callMethod('XiRelay154.turnoff'); /*Выкл зал Люстра*/
usleep(500000);
callMethod('XiRelay158.turnoff'); /*Выкл кухня RG*/
usleep(500000);
callMethod('XiRelay159.turnoff'); /*Выкл Кухня столешница*/
usleep(500000);
callMethod('XiRelay167.turnoff'); /*Выкл люстра спальня*/
usleep(500000);
callMethod('XiRelay169.turnoff'); /*Выкл спальня БРА 1*/
usleep(500000);
callMethod('XiRelay170.turnoff'); /*Выкл спальня БРА 2*/
usleep(500000);
callMethod('Button124.pressed'); /*Выкл кондиционер*/
usleep(500000);
callMethod('Button186.pressed'); /*Выкл ТВ в зале*/
usleep(500000);
callMethod('Button238.pressed'); /*Выкл ТВ в зале 2*/
usleep(500000);
callMethod('Button176.pressed'); /*Выкл ТВ в спальне*/
usleep(500000);
callMethod('Button126.pressed'); /*Выкл DENON*/
usleep(500000);
callMethod('Relay166.turnoff'); /*Выкл розетка утюг*/
usleep(500000);
callMethod('XiRelay150.turnoff'); /*Выкл кухня подсветка*/
usleep(500000);
callMethod('XiRelay151.turnoff'); /*Выкл кухня люстра*/
usleep(500000);
callMethod('XiRelay155.turnoff'); /*Выкд детская подсветка*/
usleep(500000);
callMethod('XiRelay156.turnoff'); /*Выкл детская люстра*/
usleep(500000);
callMethod('XiRelay153.turnoff'); /*Выкл зал подсветка*/
usleep(500000);
callMethod('XiRelay154.turnoff'); /*Выкл зал Люстра*/
usleep(500000);
callMethod('Button240.pressed'); /*Выкл кондер зал*/
usleep(500000);
callMethod('XiRelay158.turnoff'); /*Выкл кухня RG*/
usleep(500000);
callMethod('XiRelay159.turnoff'); /*Выкл Кухня столешница*/
usleep(500000);
callMethod('XiRelay167.turnoff'); /*Выкл люстра спальня*/
usleep(500000);
callMethod('XiRelay169.turnoff'); /*Выкл спальня БРА 1*/
usleep(500000);
callMethod('XiRelay170.turnoff'); /*Выкл спальня БРА 2*/
usleep(500000);
callMethod('Button124.pressed'); /*Выкл кондиционер*/
usleep(500000);
callMethod('Button126.pressed'); /*Выкл DENON*/
usleep(500000);
callMethod('Relay166.turnoff'); /*Выкл розетка утюг*/
usleep(500000);
callMethod('Relay228.turnoff'); /*Выкл экран планшета*/
usleep(500000);
setTimeOut('btn157', "callMethod('XiRelay157.turnoff');", 20); /*выкл свет коридор*/
setTimeOut('btn148', "callMethod('Button148.pressed');", 30); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 31); /*Выкл ТВ в зале*/
setTimeOut('btn186', "callMethod('Button238.pressed');", 32); /*Выкл ТВ в зале 2*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 33); /*Выкл ТВ в спальне*/
setTimeOut('btn147', "callMethod('Button147.pressed');", 40); /*Выкл все гирлянды*/
setTimeOut('btn182', "callMethod('Relay182.turnon');", 41); /*Сигнализация коридор*/
setTimeOut('btn183', "callMethod('Relay183.turnon');", 43); /*Сигнализация зал*/
setTimeOut('btn184', "callMethod('Relay184.turnon');", 45); /*Сигнализация детская*/
setTimeOut('btn187', "callMethod('Relay187.turnon');", 47); /*Сигнализация раздел*/
setTimeOut('btn147', "callMethod('Button147.pressed');", 50); /*Выкл все гирлянды*/
setTimeOut('btn148', "callMethod('Button148.pressed');", 61); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 62); /*Выкл ТВ в зале*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 63); /*Выкл ТВ в спальне*/
setTimeOut('btn182', "callMethod('Relay182.turnon');", 71); /*Сигнализация коридор*/
setTimeOut('btn183', "callMethod('Relay183.turnon');", 73); /*Сигнализация зал*/
setTimeOut('btn184', "callMethod('Relay184.turnon');", 75); /*Сигнализация детская*/
setTimeOut('btn187', "callMethod('Relay187.turnon');", 77); /*Сигнализация раздел*/
|
Выключить все устройства кроме кондера
|
callMethod('XiRelay157.turnoff'); /*Выкл коридор свет*/
usleep(500000);
callMethod('XiRelay180.turnoff'); /*Выкл розетка планшет*/
usleep(500000);
callMethod('XiRelay178.turnoff'); /*Выкл свет ванна*/
usleep(500000);
callMethod('XiRelay181.turnoff'); /*Выкл вентилятор ванна*/
usleep(500000);
callMethod('XiRelay179.turnoff'); /*Выкл свет туалет*/
usleep(500000);
callMethod('Button212.pressed'); /*Гирлянда коридор выкл*/
usleep(500000);
callMethod('XiRelay150.turnoff'); /*Выкл кухня подсветка*/
usleep(500000);
callMethod('XiRelay151.turnoff'); /*Выкл кухня люстра*/
usleep(500000);
callMethod('XiRelay158.turnoff'); /*Выкл кухня RG*/
usleep(500000);
callMethod('XiRelay159.turnoff'); /*Выкл Кухня столешница*/
usleep(500000);
callMethod('Button148.pressed'); /*ТВ Выкл кухня*/
usleep(500000);
callMethod('Button214.pressed'); /*Гирлянда кухня выкл*/
usleep(500000);
callMethod('XiRelay210.turnoff'); /*Балкон бра*/
usleep(500000);
callMethod('XiRelay209.turnoff'); /*балкон люстры*/
usleep(500000);
callMethod('XiRelay153.turnoff'); /*Выкл зал подсветка*/
usleep(500000);
callMethod('XiRelay154.turnoff'); /*Выкл зал Люстра*/
usleep(500000);
callMethod('Button186.pressed'); /*Выкл ТВ в зале*/
usleep(500000);
callMethod('Button126.pressed'); /*Выкл DENON*/
usleep(500000);
callMethod('XiRelay175.turnoff'); /*Гирлянда зал выкл*/
usleep(500000);
callMethod('XiRelay155.turnoff'); /*Выкл детская подсветка*/
usleep(500000);
callMethod('XiRelay156.turnoff'); /*Выкл детская люстра*/
usleep(500000);
callMethod('Button216.pressed'); /*Гирлянда детская выкл*/
usleep(500000);
callMethod('XiRelay167.turnoff'); /*Выкл люстра спальня*/
usleep(500000);
callMethod('XiRelay169.turnoff'); /*Выкл спальня БРА 1*/
usleep(500000);
callMethod('XiRelay170.turnoff'); /*Выкл спальня БРА 2*/
usleep(500000);
callMethod('Button176.pressed'); /*Выкл ТВ в спальне*/
usleep(500000);
callMethod('XiRelay157.turnoff'); /*Выкл коридор свет*/
usleep(500000);
callMethod('Relay166.turnoff'); /*Выкл розетка утюг*/
usleep(500000);
callMethod('Button218.pressed'); /*Гирлянда спальня шкаф выкл */
usleep(500000);
callMethod('XiRelay160.turnoff'); /*Гирлянда спальня окно выкл*/
usleep(500000);
setTimeOut('btn148', "callMethod('Button148.pressed');", 30); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 31); /*Выкл ТВ в зале*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 32); /*Выкл ТВ в спальне*/
setTimeOut('btn148', "callMethod('Button148.pressed');", 61); /*ТВ Выкл кухня*/
setTimeOut('btn186', "callMethod('Button186.pressed');", 62); /*Выкл ТВ в зале*/
setTimeOut('btn176', "callMethod('Button176.pressed');", 63); /*Выкл ТВ в спальне*/
|
Для формата дата
|
SQLExec('
CREATE TABLE IF NOT EXISTS `sys_date_format` (
`ID` int(10) UNSIGNED NOT NULL,
`TITLE` varchar(100) NOT NULL DEFAULT \'\',
`FORMAT` varchar(255) NOT NULL DEFAULT \'\',
`LINKED_OBJECT` varchar(100) NOT NULL DEFAULT \'\',
`LINKED_PROPERTY` varchar(100) NOT NULL DEFAULT \'\'
) ENGINE=MyISAM DEFAULT CHARSET=utf8;');
SQLExec('
INSERT INTO `sys_date_format` (`TITLE`, `FORMAT`, `LINKED_OBJECT`, `LINKED_PROPERTY`) VALUES
(\'Часы\', \'H\', \'ThisComputer\', \'timeNowH\'),
(\'Минуты\', \'i\', \'ThisComputer\', \'timeNowM\'),
(\'Время\', \'H:i\', \'ThisComputer\', \'timeNow\'),
(\'Дата\', \'d1\', \'ThisComputer\', \'dateNow\'),
(\'День недели\', \'n1\', \'ThisComputer\', \'DayOfWeek\');
');
|
Доброе утро
|
if (!getGlobal("Relay182.status")) {
callMethod("XiRelay180.turnOn");
callMethod("XiRelay157.turnOn");
eval('sg(\'Button36.alive\', 1);');
callMethod("XiRelay151.turnOn");
callMethod("XiRelay150.turnOn");
callMethod("XiRelay159.turnOn");
callMethod("XiRelay167.turnOn");
eval('sg(\'Button01.alive\', 1);');
}
|
Сцена каналы кухня
|
|