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);
|
shutDown
|
Выключение системы
$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 -h now');",15);
|
termostat1
|
Водонагреватель
$rele_stat=gg('Relay05.status');
$temp_min=gg('termo_knopka.rmin');
$temp_max=gg('termo_knopka.rmax');
$temp_real=gg('ESP826600fe772a.dsw2');
$status_knopka=gg('termo_knopka.status');
$status_triggerGIST=gg('termo_knopka.gist');
if ($status_knopka=='1' && $temp_real < $temp_max && $status_triggerGIST=='1'){
sg('Relay05.status','1');
}
if ($temp_real >= $temp_max){
sg('termo_knopka.gist','0');
sg('Relay05.status','0');
}
if ($temp_real <= $temp_min){
sg('termo_knopka.gist','1');
}
if ($status_knopka=='0'){
sg('Relay05.status','0');
sg('termo_knopka.gist','1');
}
|
termostat1_water_in
|
Вода на входе
$rele_stat=gg('Relay02.status');
$temp_min=gg('termo_knopka_water_in.rmin');
$temp_max=gg('termo_knopka_water_in.rmax');
$temp_real=gg('ESP826600fe772a.dsw1');
$status_knopka=gg('termo_knopka_water_in.status');
$status_triggerGIST=gg('termo_knopka_water_in.gist');
if ($status_knopka=='1' && $temp_real < $temp_max && $status_triggerGIST=='1'){
sg('Relay02.status','1');
}
if ($temp_real >= $temp_max){
sg('termo_knopka_water_in.gist','0');
sg('Relay02.status','0');
}
if ($temp_real <= $temp_min){
sg('termo_knopka_water_in.gist','1');
}
if ($status_knopka=='0'){
sg('Relay02.status','0');
sg('termo_knopka_water_in.gist','1');
}
|
termostat_obogrev
|
Обогреватель
$rele_stat=gg('Relay03.status');
$temp_min=gg('termo_knopka_obogrev.rmin');
$temp_max=gg('termo_knopka_obogrev.rmax');
$temp_real=gg('ESP826600fe772a.dsw3');
$status_knopka=gg('termo_knopka_obogrev.status');
$status_triggerGIST=gg('termo_knopka_obogrev.gist');
if ($status_knopka=='1' && $temp_real < $temp_max && $status_triggerGIST=='1'){
sg('Relay03.status','1');
}
if ($temp_real >= $temp_max){
sg('termo_knopka_obogrev.gist','0');
sg('Relay03.status','0');
}
if ($temp_real <= $temp_min){
sg('termo_knopka_obogrev.gist','1');
}
if ($status_knopka=='0'){
sg('Relay03.status','0');
sg('termo_knopka_obogrev.gist','1');
}
|
ENERGY
|
cm('RadioSetting.Control', array('stop'));
say('Включаю радио Энерджи',1);
cm('RadioSetting.Control', array('sta:ENERGY'));
cm('RadioSetting.Control',array('play'));
setGlobal("RadioSetting.RadioLedOn",1);
|
Radio Off
|
cm('RadioSetting.Control',array('cmd'=>'stop'));
setGlobal("Radio.RadioLedOn",0);
say('Радио выключено',1);
|
Radio On
|
cm('RadioSetting.Control','stop');
say('Включаю радио');
cm('RadioSetting.Control',array('cmd'=>'play'));
setGlobal("RadioSetting.RadioLedOn",1);
|
Vol+
|
$vol = gg("ThisComputer.volumeLevel");
if ($vol < 100){
cm('RadioSetting.Control',array('vol'=> $vol+10 ));
} else {
cm('RadioSetting.Control',array('vol'=> 100 ));
}
setGlobal('ThisComputer.volumeLevel', $vol+10);
|
Vol-
|
$vol = gg("ThisComputer.volumeLevel");
if ($vol > 10){
cm('RadioSetting.Control',array('vol'=> $vol-10 ));
} else {
cm('RadioSetting.Control',array('vol'=> 0 ));
}
setGlobal('ThisComputer.volumeLevel', $vol-10);
|
Соль FM
|
cm('RadioSetting.Control', array('sta:СОЛЬ FM'));
cm('RadioSetting.Control', array('play'));
cm('RadioSetting.Control', array('vol30'));
|
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());
|
tellWeather
|
Говорит фактическую погоду
say('Температура в помещении '.gg('ESP826600fe772a.dsw3').' градусов цельсия, влажность '.gg('ESP826600fe772a.dhth1').' процентов.',2);
say('На улице '.gg('ow_fact.temperature').' градусов, '.gg('ow_fact.weather_type').', ветер '.gg('ow_fact.wind_speed').' метров в секунду, влажность '.gg('ow_fact.humidity').' процентов.',2);
|
turnOffEverything
|
Выключить все приборы
$objects=array('Switch1','Switch2','Switch3');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
|
Отправка в Телеграм
|
$value=getGlobal ("ESP826600fe772a.gpiout12");
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$telegram_module->sendMessageToUser(736831627, "Вкл-Выкл ".$value);
//$telegram_module->sendMessageToAdmin("Вкл-Выкл ".$value);
//$telegram_module->sendMessageToAll("Вкл-Выкл ".$value);
|