Свойства класса:
Методы класса:
if ($this->getProperty('online')=='1') {
$this->setProperty('status',1);
}else if ($this->getProperty('online')=='2') {
$this->setProperty('status',0);
}Объекты класса:
Методы класса:
Объекты класса:
$this->setProperty('status','0');
$this->callMethod('switch');sg('RMPro.TVonoff',1);
if($this->getProperty('status')=='1'){
$this->setProperty('status','1');
}else{
$this->setProperty('status','0');
}$this->setProperty('status','1');
$this->callMethod('switch');Методы класса:
$ot=substr($this->object_title,0,2);
if($this->getProperty('status')){
sg('RMPro.'.$ot.'on',1);
} else {
sg('RMPro.'.$ot.'off',1);
}$ot=substr($this->object_title,0,2);
$this->setProperty('status',0);
sg('RMPro.'.$ot.'off',1);
sleep(1);$ot=substr($this->object_title,0,2);
$this->setProperty('status',1);
sg('RMPro.'.$ot.'on',1);
sleep(1);Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty('volumeLevel',$params['VALUE']);
if (IsWindowsOs()) {
$volume=round(65535*$params['VALUE']/100);
safe_exec('..\\apps\\nircmd\\nircmdc setsysvolume '.$volume);
} else {
safe_exec('amixer sset PCM,0 '.$params['VALUE'].'%');
}
say("Изменилась громкость до ".$params['VALUE']." процентов");if ($params['inUse']) {
$this->setProperty('inUse',$params['inUse']);
}
$ot=$this->object_title;
clearTimeOut($ot."_idle");
setTimeOut($ot."_idle","setGlobal('$ot.inUse',0);",10*60);Объекты класса:
exec("c:\shdn.bat");
$this->setProperty('online',0);magicPacket('50:E5:49:42:03:29');
function magicPacket($mac,$addr='255.255.255.255',$socket_number=7) {
//split up the mac address based upon the colons in the string
$addr_byte = explode(':', $mac);
$hw_addr = '';
for ($a=0; $a <6; $a++)
$hw_addr .=chr(hexdec($addr_byte[$a])); //convert the hex to its decimal equivalent, encode as a character, and repeat 16 times
$msg = str_repeat(chr(255),6); //FF in decimal is 255, which is then encoded as a char as with our mac address
for ($a = 1; $a <= 16; $a++)
$msg .= $hw_addr;
$s = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); //create our socket
if ($s == false) {
echo "Error creating socket!\n";
echo "Error code is '".socket_last_error($s)."'- " . socket_strerror(socket_last_error($s));
return false;
}
else {
// setting a broadcast option to socket:
//$opt_ret = socket_set_option($s, 1, 6, TRUE);
$opt_ret = socket_set_option($s,SOL_SOCKET,SO_BROADCAST,true);
if($opt_ret <0) {
echo "setsockopt() failed, error: " . strerror($opt_ret) ."\n";
return false;
}
if(socket_sendto($s, $msg, strlen($msg), 0, $addr,$socket_number)) {
socket_close($s);
return true;
}
else {
return false;
}
}
}
$this->setProperty('online',1);$command=$params['command'];
$short_command='';
$dt=recognizeTime($command,$short_command);
if (preg_match('/скажи сколько врем/uis',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say('Сейчас '.timeNow(),2);
} elseif (preg_match('/сколько время/uis',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята');
echo $short_command;
return;
}
say('Сейчас '.timeNow());
} elseif (preg_match('/повтори (.+)/uis',$command,$m) || preg_match('/скажи (.+)/uis',$command,$m)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say($m[1],2);
} else {
say('Неизвестная команда...',2);
}say("Отключено питание");Свойства класса:
Методы класса:
//$params["USER_OBJECT"]
//$params["USER_OBJECT"]
Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty('updated',time());
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=2*60*60;
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);Объекты класса:
Свойства класса:
Методы класса:
if ($params['status']) {
$this->setProperty('status',$params['status']);
}
//say($params['NEW_VALUE']);
if ($params['NEW_VALUE'] != $params['OLD_VALUE']) {
$this->setProperty('updatedTimestamp',time());
}
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=24*60*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);Объекты класса:
if ($params['NEW_VALUE'] =='1' && $params['OLD_VALUE']=='0' && timeBetween(timeConvert(gg('SunSetTime'))-60*60, timeConvert(gg('SunRiseTime'))+60*60)){
callMethod('h2.turnOn');
}Свойства класса:
Методы класса:
//if ($params['NEW_VALUE']==1 && $params['OLD_VALUE']==0) {
// say ('Обнаружено движение');
//} else if ($params['NEW_VALUE']==0 && $params['OLD_VALUE']==1) {
// say ('Движение прекратилось');
//}
if ($this->object_title=='WebCamK' && (getGlobal('NobodyHomeMode.active') || getGlobal('NightMode.active'))) {
return;
//say("1");
}
//if ($params){
// say($this->object_title);
//}
if ($params['NEW_VALUE']==1 && $params['OLD_VALUE']==0 || $params['status']==1) {
$this->setProperty('updatedTimestamp',time());
$this->setProperty('motionDetected',1);
clearTimeOut($this->object_title.'_detected');
setTimeOut($this->object_title.'_detected',"setGlobal('".$this->object_title.".motionDetected',0);",5*60);
$linked_room=$this->getProperty('LinkedRoom');
//say($linked_room);
if ($linked_room!='') {
callMethod($linked_room.'.onActivity');
//say($linked_room.'.onActivity');
}
if ($this->object_title=='sensorMovement3' || $this->object_title=='sensorMovementRemote1' || $this->object_title=='sensorMovementRemote2') {
//|| $this->object_title=='sensorMovement5'
return; // не реагируем на движение в спальне, по ip-сенсорам и по сенсору на втром этаже
}
$last_register=registeredEventTime('inhouseMovement'); // проверяем когда в последний раз срабатывало событие "движение внутри дома"
registerEvent('inhouseMovement',$this->name,2); // регистрируем событие "движение внутри дома"
//if (timeBetween('05:00', '12:00') && ((time()-$last_register)>2*60*60)) {
//runScript('Greeting'); // запускаем скрипт "доброе утро"
//}
}Объекты класса:
Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty('active',1);$this->setProperty('active',0);Объекты класса:
setGlobal('minMsgLevel','2');
setGlobal('minMsgLevel','1');
setGlobal('NobodyHomeMode.active',0);
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date('H:i'));
if ($this->getProperty('active')=='1') {
say("Режим ".$this->getProperty('title')." активирован.");
$this->SetProperty('statusText','Ночной режим.');
if (gg('usrAtHome')){
setGlobal('NobodyHomeMode.active',2);
}
runScript('turnOffEverything');
} elseif ($this->getProperty('active')=='0'){
say("Режим ".$this->getProperty('title')." выключен.");
setGlobal('minMsgLevel','1');
$this->SetProperty('statusText','');
}$this->setProperty("updated",time());
$this->setProperty("updatedTime",date('H:i'));
if ($this->getProperty('active')=='1') {
say("Режим ".$this->getProperty('title')." активирован.");
} elseif ($this->getProperty('active')=='0'){
say("Режим ".$this->getProperty('title')." выключен.");
}/*$objects=getObjectsByProperty('groupSunrise','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
*/
/* begin injection of {SDevices} */
//require(DIR_MODULES.'devices/darknessmode_deactivate.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
//require(DIR_MODULES.'devices/darknessmode_activate.php');
/* end injection of {SDevices} */if ($this->getProperty('active')=='1') {
say("Режим ".$this->getProperty('title')." активирован.");
$this->SetProperty('statusText','Никого нет.');
runScript('turnOffEverything');
} elseif ($this->getProperty('active')=='0' && $this->getProperty('statusText')!='Все спят.'){
say("Режим ".$this->getProperty('title')." выключен.");
$this->SetProperty('statusText','Дома.');
runScript('welcome');
} elseif ($this->getProperty('active')=='0' && $this->getProperty('statusText')=='Все спят.'){
$this->SetProperty('statusText','Дома.');
}elseif ($this->getProperty('active')=='2'){
$this->SetProperty('statusText','Все спят.');
}
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date('H:i'));$objects=getObjectsByProperty('groupEco','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
$objects=getObjectsByProperty('allOffGroup','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/econommode_activate.php');
/* end injection of {SDevices} */if (gg('DarknessMode.active')) {
$objects=getObjectsByProperty('greetingOnGroup','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOn');
}
}
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/econommode_deactivate.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
$this->setProperty('updated',time());
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=24*60*60;
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);$this->setProperty("status",0);$this->setProperty("status",1);Объекты класса:
//если бра включается
//say('0');
if ($params['NEW_VALUE'] =='0' && $params['OLD_VALUE']=='1'){
//say('1');
//счистаем пользователей кроме Димы и Оли
$usr=getObjectsByClass("Users");
$total=count($usr);
for($i=0;$i<$total;$i++) {
if ($usr[$i]['TITLE']!='admin' && $usr[$i]['TITLE']!='lama'){
$u = $u + gg($usr[$i]['TITLE'].'.atHome');
}
}
//Если час до сна, и ночной режим выкл
if (gg('NightMode.active')=='0' && timeBetween(date('H:i', strtotime("-1 hour", strtotime(gg('NightModeStart')))),gg('NightModeEnd'))){
say('Пора спать. Уже: '.timeNow(),2);
//say('2');
//детей нет, телек выключен и никто не работает за буком или компом
if (!gg('TV.status') && !gg("HOMEPC.inUse") && !gg("LAMABook.inUse") && $u<1){
say('1');
callMethod('Nightmode.activate');
//детей нет и кто-то работает за буком или компом или включен телек
}else if ((gg('TV.status') || gg("HOMEPC.inUse") || gg("LAMABook.inUse")) && $u<1){
say('2');
runScript('TurnOffk');
$objects=array('h2','h1','p1','l1','b1','t1','v1');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
//есть дети, телек выключен
}else if (!gg('TV.status') &&$u>0){
say('3');
callMethod('k3.turnon');
$objects=array('h2','h1','p1','k1','k2','k4','b1','t1','v1');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
//есть дети, телек выключен и комп и бук не используются
}else if (gg('TV.status') && !gg("HOMEPC.inUse") && !gg("LAMABook.inUse") &&$u>0){
say('4');
$objects=array('h2','h1','p1','k1','k2','k3','k4','b1','t1','v1','l1');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
//есть дети, телек выключен и комп или бук используются
}else if (gg('TV.status') && (gg("HOMEPC.inUse") || gg("LAMABook.inUse")) &&$u>0){
say('5');
$objects=array('h2','h1','p1','k1','k2','k4','b1','t1','v1','l1');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
}
}
}elseif ($params['NEW_VALUE'] =='1' && $params['OLD_VALUE']=='0'){
if (timeBetween(date('H:i', strtotime("-2 hour", strtotime(gg('NightModeStart')))),gg('NightModeEnd'))){
callMethod('b1.turnOff');
}
}Свойства класса:
Методы класса:
$latestActivity=$this->getProperty('LatestActivity');
$this->setProperty('LatestActivity',time());
$this->setProperty('LatestActivityTime',date('H:i'));
$this->setProperty('SomebodyHere',1);
$ot=$this->object_title;
if ($this->getProperty("IdleDelay")) {
$activity_timeout=(int)$this->getProperty("IdleDelay");
} else {
$activity_timeout=15*60;
}
if (isWeekDay()){
$NightModeStart = gg('NightModeStart');
$NightModeEnd = gg('NightModeEnd');
}elseif (isWeekEnd()){
$NightModeStart = '03:00';
$NightModeEnd = '10:00';
}
clearTimeOut($ot."_activity_timeout");
setTimeOut($ot."_activity_timeout","callMethod('".$ot.".onIdle');",$activity_timeout);
//clearTimeOut($ot."_activity_timeout2");
//setTimeOut($ot."_activity_timeout2","callMethod('".$ot.".onIdle');",$activity_timeout+30*60);
if (getGlobal('NobodyHomeMode.active')=='1' && getGlobal('NightMode.active')) {
callMethod('NightMode.deactivate');
callMethod('NobodyHomeMode.deactivate');
} else if (getGlobal('NobodyHomeMode.active')=='1' && !getGlobal('NightMode.active')) {
callMethod('NobodyHomeMode.deactivate');
}
if (getGlobal('NightMode.active') && timeBetween(date('h:i', strtotime("-30 min", strtotime($NightModeEnd))),$NightModeStart)){//time()-timeConvert($NightModeStart)>30 && (timeBetween(date('h:i', strtotime("-30 min", strtotime($NightModeEnd))),$NightModeStart) || time()-timeConvert($NightModeStart)<60*60)) {
callMethod('NightMode.deactivate');
// setGlobal('NobodyHomeMode.active',0);
if(getGlobal('DarknessMode.active')){
callMethod('k2.turnOn');
callMethod('h1.turnOn');
//say('k2.turnOn');
}
callMethod('v1.turnOn');
callMethod('t1.turnOn');
//setTimeOut('goodmorning',"runScript('goodmorning');",5);
runScript('goodmorning');
}
if (getGlobal('NightMode.active') && getGlobal('DarknessMode.active')){
//say('k3.turnOn');
callMethod('k3.turnOn');
ClearTimeOut("k3_timer");
SetTimeOut("k3_timer","callMethod('k3.turnOff');", 3*60);
}
$this->callMethod("updateActivityStatus");
/* begin injection of {SDevices} */
//require(DIR_MODULES.'devices/Rooms_onActivity.php');
/* end injection of {SDevices} */$this->setProperty('SomebodyHere',0);
//say('Rooms:onIdle');
$this->callMethod("updateActivityStatus");//продумать механизм$NightModeStart = gg('NightModeStart');
$NightModeEnd = gg('NightModeEnd');
$usrathome=getGlobal('usrAtHome');
$rooms=getObjectsByClass("Rooms");
$total=count($rooms);
for($i=0;$i<$total;$i++) {
$rooms[$i]['room']=getGlobal($rooms[$i]['TITLE'].'.Title');
//say($rooms[$i]['room']);
if (!$rooms[$i]['room']) {
$rooms[$i]['room']=$rooms[$i]['TITLE'];
}
$rooms[$i]['active']=getGlobal($rooms[$i]['TITLE'].'.SomebodyHere');
$rooms[$i]['time']=getGlobal($rooms[$i]['TITLE'].'.LatestActivity');
$rooms[$i]['diff']=time()-$rooms[$i]['time'];
}
function cmp($a, $b)
{
if ($a['diff'] == $b['diff']) {
return 0;
}
return ($a['diff'] < $b['diff']) ? -1 : 1;
}
usort($rooms,"cmp");
if (!$rooms[0]['active']) {
//say('нет');
$somebodyHomeText="Последняя активность в ".date('H:i',$rooms[0]['time'])." (".$rooms[0]['room'].")";
setGlobal('somebodyHome',0);
} else {
//say($usrathome.'да');
$res_rooms=array();
for($i=0;$i<$total;$i++) {
if ($rooms[$i]['active']) {
$res_rooms[]=$rooms[$i]['room'];
}
}
$somebodyHomeText="Активность: ".implode(", ",$res_rooms);
setGlobal('somebodyHome',1);
}
setGlobal('somebodyHomeText',$somebodyHomeText);
if ((timeBetween('11:00',$NightModeStart) && $usrathome=='1')) {
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", 3*60*60); // выполняем если целый час никого не было
} else if (timeBetween($NightModeStart,'11:00') && $usrathome=='1') {
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", timeConvert('11:00')-time()+3600);
} else {
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", 30*60);
}
//echo "Updated";
/* begin injection of {SDevices} */
//require(DIR_MODULES.'devices/Rooms_updateActivityStatus.php');
/* end injection of {SDevices} */Объекты класса:
if (gg('NightMode.active') && !gg('somebodyHome')){
say('Внимание! обнаружена активность в гараже!',2);
$filepath = 'C:/_majordomo/htdocs/cached/webcamG/Gallery/';
foreach(glob($filepath . '*.jpg') as $file) {
// далее получаем последний добавленный/измененный файл
$LastModified[] = filemtime($file); // массив файлов со временем изменения файла
$FileName[] = $file; // массив всех файлов
}
// Сортируем массив с файлами по дате изменения
$files = array_multisort($LastModified, SORT_NUMERIC, SORT_ASC, $FileName);
$lastIndex = count($LastModified) - 1;
// И вот он наш последний добавленный или измененный файл
$LastModifiedFile = $FileName[$lastIndex];
$LastModifiedFile2 = $FileName[$lastIndex-1];
//copy("http://192.168.10.10:8080/cam_1.jpg", "C:/_majordomo/htdocs/cached/img/out3.jpg");
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$telegram_module->sendStickerToAdmin("CAADAgADLQADyIsGAAGJcalkB0bXSQI");
$telegram_module->sendImageToAdmin($LastModifiedFile);
$telegram_module->sendImageToAdmin($LastModifiedFile2);
}if (time()>timeConvert(gg('SunRiseTime'))+60*60 && time()<timeConvert(gg('SunSetTime'))-60*60){
$objects=array('h2','h1','p1','l1','b1','SC2B');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
}else{
setTimeOut("TurnOffvth1h2p1","runScript('TurnOffvth1h2p1');",20*60);
if (gg('SC2B.status')=='1'){
callMethod('b1.turnoff');
}else{
setTimeOut("TurnOffb1","callMethod('b1.turnoff');",60*60);
}
}
clearTimeOut("TurnOffvth1h2p1");
clearTimeOut("TurnOffb1");if (time()>timeConvert(gg('SunRiseTime'))+60*60 && time()<timeConvert(gg('SunSetTime'))-60*60){
$objects=array('k1','k2','k3','k4');
foreach($objects as $o) {
callMethod($o.'.turnoff');
}
} else {
setTimeOut("TurnOffk","runScript('TurnOffk');",10*60);
}clearTimeOut("TurnOffk");Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SDevices_statusUpdated.php');
require(DIR_MODULES.'devices/SDevices_logicAction.php');
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SDevices_setUpdatedText.php');
/* end injection of {SDevices} */Методы класса:
require(DIR_MODULES.'devices/SButtons_pressed.php');
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_motionDetected.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_updatePreview.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_takeSnapshot.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SControllers_turnOn.php');
require(DIR_MODULES.'devices/SControllers_turnOff.php');
require(DIR_MODULES.'devices/SControllers_switch.php');
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SDimmers_levelUpdated.php');
require(DIR_MODULES.'devices/SDimmers_turnOn.php');
require(DIR_MODULES.'devices/SDimmers_turnOff.php');
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_colorUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_setColor.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_turnOn.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_turnOff.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_valueUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_statusUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_tempUp.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_tempDown.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCounters_valueUpdated.php');
/* end injection of {SDevices} */Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SLeak_statusUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SMotions_motionDetected.php');
Объекты класса:
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SOpenClose_statusUpdated.php');
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SSensors_valueUpdated.php');
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SSmoke_statusUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
Объекты класса:
$details=array();
$red_state=0;
$yellow_state=0;
if (!isOnline('Internet')) {
$yellow_state=1;
$details[]=LANG_GENERAL_NO_INTERNET_ACCESS;
}
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_COMMUNICATION_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details));
} else {
say(LANG_GENERAL_COMMUNICATION_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}$details=array();
$red_state=0;
$yellow_state=0;
$cycles=array('states'=>'states','main'=>'main','execs'=>'exec','scheduler'=>'scheduler');
foreach($cycles as $k=>$v) {
$tm=getGlobal('ThisComputer.cycle_'.$k.'Run');
if (time()-$tm>5*60) {
$red_state=1;
$details[]=$v." ".LANG_GENERAL_CYCLE." ".LANG_GENERAL_STOPPED.".";
}
}
$cycles=array('ping'=>'ping','webvars'=>'webvars','telegram'=>'telegram');
foreach($cycles as $k=>$v) {
$tm=getGlobal('ThisComputer.cycle_'.$k.'Run');
if (time()-$tm>10*60) {
$yellow_state=1;
$details[]=$v." ".LANG_GENERAL_CYCLE." ".LANG_GENERAL_STOPPED.".";
}
}
if (!isOnline('A1')) {
$yellow_state=1;
$details[]="Сенсор A1 недоступен.";
}
if (!isOnline('Rig')) {
$yellow_state=1;
$details[]="Ферма недоступна.";
}
if (!isOnline('RM-Pro')) {
$yellow_state=1;
$details[]="Модуль RM-Pro недоступен.";
}
/*
$objects=array('RMTemp'=>'RM-Pro','A1'=>'Датчик движения 2','TempSensor01'=>'Датчик температуры','HumSensor01'=>'Датчик влажности');
foreach($objects as $k=>$v) {
if (!gg($k.'.alive')) {
$yellow_state=1;
$details[]="Не обновляется ".$v.'.';
}
}
*/
if ((int)gg('ThisComputer.SpaceProblems')>0) {
$red_state=1;
$details[]="Недостаточно места на диске (".gg('ThisComputer.SpaceProblems_Details').').';
}
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details),2);
} else {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title,2);
}
$this->callMethod('stateChanged');
}
/* begin injection of {SDevices} */
//require(DIR_MODULES.'devices/system_checkstate.php');
/* end injection of {SDevices} */ $details=array();
$red_state=0;
$yellow_state=0;
if (!isOnline('AirCamDom')) {
$yellow_state=1;
$details[]="Камера на крыльце недоступна!";
}
if (!isOnline('AirCamUlica')) {
$yellow_state=1;
$details[]="Камера у гаража недоступна!";
}
if (!isOnline('S1')) {
$red_state=1;
$details[]="Модуль сигнализации недоступен!";
}
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_SECURITY_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details));
} else {
say(LANG_GENERAL_SECURITY_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}Свойства класса:
Методы класса:
//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather moduleОбъекты класса:
$h=(int)date('G',time());
$m=date('i',time());
if (isWeekDay()) {
}
if (timeBetween(getGlobal('NightModeEnd'),getGlobal('NightModeStart')) && getGlobal('clockChimeEnabled')) {
if ($m=="00") {
sayTo(timeNow(),1,Tab);
}
}
setGlobal('timeNow',date('H:i'));
$homeStatus=date('H:i');
if (getGlobal('NobodyHomeMode.active'=='1')) {
$homeStatus.=' Дома никого';
} else {
$homeStatus.=' Дома кто-то есть';
}
$homeStatus.=' '.getGlobal('Security.stateDetails');
$homeStatus.=' '.getGlobal('System.stateDetails');
$homeStatus.=' '.getGlobal('Communication.stateDetails');
setGlobal('HomeStatus',$homeStatus);
if (timeBetween(getGlobal('SunRiseTime'),getGlobal('SunSetTime')) && getGlobal('isDark')=="1") {
setGlobal("isDark",0);
callMethod('DarknessMode.deactivate');
} elseif (!timeBetween(getGlobal('SunRiseTime'),getGlobal('SunSetTime')) && getGlobal('isDark')!="1") {
setGlobal("isDark",1);
callMethod('DarknessMode.activate');
}
if (timeIs(getGlobal('SunRiseTime'))) {
say('Всходит солнце');
}
if (timeIs(getGlobal('SunSetTime'))) {
say('Солнце заходит',2);
}
if (timeIs("23:30") && (gg("EconomMode.active")!="1") && (gg("NobodyHomeMode.active")=="1")) {
say("Похоже никого нет сегодня, можно сэкономить немного.");
callMethod('EconomMode.activate');
}
if (isWeekDay()){
$NightModeStart = gg('NightModeStart');
$NightModeEnd = gg('NightModeEnd');
if (gg('lama.atHome') && !gg('admin.atHome') && !gg("somebodyHome")) {
if (timeIs('08:40')){
sayto('Олечка, вставай. Время:'.gg(timeNow),2,honor8);
} elseif (timeIs('08:45')){
sayto('Оля вставай быстро, время:'.gg(timeNow),2,honor8);
} elseif (timeIs('08:50')){
sayto('Оля быстро вставай, время:'.gg(timeNow).'. Подумай о стипендии и о должности общественного декана!',2,honor8);
} elseif (timeIs('08:55')){
sayto('Оля, еп твою мать! Вставай сейчас же! Время:'.gg(timeNow).'. Я больше не буду тебя будить! Напишу об этом Диме',2,honor8);
include_once(DIR_MODULES . 'telegram/telegram.class.php');
$telegram_module = new telegram();
$telegram_module->sendMessageToUser(304099464, "Оля не встает!");
}
}
}elseif (isWeekEnd()){
$NightModeStart = '02:00';
$NightModeEnd = '10:00';
}
if (gg("NightMode.active")=="0" && (gg("somebodyHome") || isOnline('TV') || gg("HOMEPC.inUse") || gg("LAMABook.inUse")) && timeIs($NightModeStart)){
say('Пора спать. Уже: '.$NightModeStart,2);
}
if (gg("NightMode.active")=="0" && gg("somebodyHome")=="0" && gg("HOMEPC.inUse")=="0" && gg("LAMABook.inUse")=="0" && !isOnline('TV') && timeBetween($NightModeStart,date('h:i', strtotime("-1 hour", strtotime($NightModeEnd))))){
//say('1');
callMethod('NightMode.activate');
} elseif (gg("NightMode.active")=="1" && timeBetween(date('h:i', strtotime("+1 hour", strtotime($NightModeEnd))),$NightModeStart)){
callMethod('NightMode.deactivate');
}
if (gg("NightMode.active") && gg('A1.light')>0 && gg('usrAtHome')=="0"){
runScript('lightOff');
//say('L off');
}
//getGlobal('isDark')!="1"
if (timeIs("03:00")) {
runScript("systemMaintenance");
}
if (timeIs("22:50")) {
setGlobal('minMsgLevel','2');
}
if (timeIs("00:00")) {
sg('CameraDom.dayCount',0);
sg('CameraUlica.dayCount',0);
}
if (gg('ThisComputer.AlarmStatus') && timeIs(gg('ThisComputer.AlarmTime'))) {
runScript('MorningAlarm');
}
if (isOnline('Home-PC')) {
SG("Home-PC.online",1);
}else{
SG("Home-PC.online",0);
}
if (gg('A1.humidity') <30 && getGlobal('NobodyHomeMode.active')=='0') {
sg('SC1K1.status',1);
ClearTimeOut("SC1");
SetTimeOut("SC1","sg('SC1K1.status',0);", 30*60);
} else if (gg('A1.humidity')>40 || getGlobal('NobodyHomeMode.active')=='1') {
sg('SC1K1.status',0);
}
runScript('UserState');
runScript('weatherReceived');$paths=array('/var/log/*.1','/var/log/*.2',
'/var/log/*.1.*',
'/var/log/*.2.*',
'/var/log/*.3.*',
'/var/log/*.4.*',
'/var/log/*.5.*',
'/var/log/*.6.*',
'/var/log/*.7.*'
);
foreach($paths as $p) {
safe_exec('rm '.$p);
}
runScript('Hourly');
runScript('filesClearOld');
if (gg('A1.humidity') <30 && time()-gg('SC1K1.updated')>10*60 && getGlobal('NobodyHomeMode.active')=="0" && gg('SC1K1.status')) {
say('Проверьте воду в увлажнителе');
}Свойства класса:
Методы класса:
if ($params['online']!='2'){
$this->setProperty('NetUpdatedTimestamp',time());
}
//say($ot.'.atHome');//$params["LOCATION_OBJECT"], $params["LOCATION"]
//$params["LOCATION_OBJECT"], $params["LOCATION"]
Объекты класса:
, Россия
© 2026 SJLab | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving