Свойства класса:
Методы класса:
$ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования $volCode = $params['Code']; // получаем аргумент передаваемый с запуском этого метода if($volCode == 105) sg($otp.'onWork', 0); // если команда периодического опроса, то ... if(gg($otp.'onLine') == 1) { // если пинг с хостом есть sg($otp.'sendCode', $volCode); // записываем код отправляемой команды sg($otp.'sendEvent', 1); // декларируем отправку команды say('Отправлена команда',2); $command = "cm('".$otp."alertHost');"; SetTimeOut('checkbyHost', $command , 5); } else { say('Отмена команды. Проверьте связь',2); }
$ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования if(gg($otp.'sendEvent') == 1) { // если ещё нет правильного ответа на команду sg($otp.'sendEvent', 0); // сбрасываем флаг отправки команды say('Отмена команды. Проверьте хост', 2); if($ot == 'Cluster_1') say('Кластер 1', 2); }
$propTitle = $params['PROPERTY']; // получаем название изменившегося свойства, вызвавшего этот метод $ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования $_cmd = 0; if ($propTitle == 'rxStatus') jsonHandler($otp, 'Status', 102); elseif($propTitle == "rxConfig") jsonHandler($otp, 'Config', 103); elseif($propTitle == "rxInform") jsonHandler($otp, 'Inform', 104); // функция обработки принимаемой json-строки function jsonHandler($_ot, $input, $code) { if(gg($_ot.'_firstPacket') <> 1) { // если пакетов ещё не было sg($_ot.'_firstPacket', 1); // декларируем получение первого пакета sg($_ot.'_jsonCheck', 0); sg($_ot.'_jsonBuffer', ''); // !!! здесь можно коментить для отладки sg($_ot.'ready'.$input, ''); } $tmpStr = gg($_ot.'_jsonBuffer').gg($_ot.'rx'.$input); sg($_ot.'_jsonBuffer', $tmpStr); $jsonArr = json_decode($tmpStr); if($jsonArr == true) { // если полученная json-строка исправна // отключаем тамер запуска метода повторной отправки команды с параметром $code (команды) ClearTimeOut('repeatCmd'); // !!! здесь можно коментить для отладки sg($_ot.'sendEvent ', 0); // декларируем отработку события(команды) //say('декодер есть', 2); sg($_ot.'_jsonCheck', 1); // декларируем исправность json-строки sg($_ot.'ready'.$input, $tmpStr); // запоминаем полученную json-строку sg($_ot.'_jsonBuffer', ''); // очиска буфера sg($_ot.'_firstPacket', 0); sg($_ot.'qwtRepeatCmd', 3); // установка счётчика повтора команд } elseif ($jsonArr == false) { // если полученная json-строка не исправна //say('декодера нет', 2); // включаем тамер запуска метода повторной отправки команды с параметром $code (команды) $command = "cm('".$_ot."repeatSend', ['Code'=>".$code."]);"; // образец: $command = 'cm("Cluster_1.repeatSend",["Code"=>102]);'; SetTimeOut('repeatCmd', $command , 5); // образец: SetTimeOut('repeatCmd', 'cm("Cluster_1.repeatSend",["Code"=>102]);', 10); } }
say('Повтор команды',2); $propTitle = $params['PROPERTY']; // получаем название изменившегося свойства, вызвавшего этот метод $ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования sg($otp.'_jsonBuffer', ''); sg($_ot.'_firstPacket', 0); $volCode = $params['Code']; $_qwt = gg($otp.'qwtRepeatCmd'); if($_qwt == 0) sg($otp.'qwtRepeatCmd', 3); else { sg($otp.'cmdСode', $volCode); $_qwt--; sg($otp.'qwtRepeatCmd', $_qwt); } //say($volCode, 2);
$ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования if($ot == 'Cluster_1') $_otp = 'infoClst_1.'; sg($otp.'onWork', 0); sg($otp.'sendEvent', 0); if(gg($otp.'host_ID') == gg($_otp.'cluster_ID')) { sg($otp.'onWork', 1); say('окей', 2); } else { say('Проверьте хост', 2); if($ot == 'Cluster_1') say('Кластер 1', 2); cm($otp.'cmdSend', ['Code'=>104]); }
Объекты класса:
$propTitle = $params['PROPERTY']; // получаем название изменившегося свойства $ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования if ($propTitle == 'rxStatus') $propTitle = 'Status'; elseif($propTitle == 'rxConfig') $propTitle = 'Config'; elseif($propTitle == 'rxInform') $propTitle = 'Inform'; if(gg($otp.'_jsonCheck') == 1) { say('готово', 2); // парсим json-строку $_readyjson = gg($otp.'ready'.$propTitle); $jsonArr = json_decode($_readyjson, true); if($propTitle == 'Status') { if($ot == 'Cluster_1') { // парсим выключатели $_clst = 'Clst1'; $nmbr = count($jsonArr['StatSW']); //узнаём сколько выключателей for ($i = 0; $i < $nmbr; $i++) { $tmpStatSW = $jsonArr['StatSW'][$i]; $tmplockSW = $jsonArr['LockSW'][$i]; $tmpSens_U = $jsonArr['Sens_U'][$i]; $tmpSens_I = $jsonArr['Sens_I'][$i]; $_swch = 'Swch'.($i+1).'.'; sg($_clst.$_swch.'Status', $tmpStatSW); sg($_clst.$_swch.'Lock', $tmplockSW); sg($_clst.$_swch.'Sensor_U', $tmpSens_U); sg($_clst.$_swch.'Sensor_I', $tmpSens_I); } // end парсим выключатели }// end if($ot == 'Cluster_1') } // end if($propTitle == 'Status') elseif($propTitle == 'Config') { // парсим IP $tmpip_0 = $jsonArr['IP_Station'][0]; $tmpip_1 = $jsonArr['IP_Station'][1]; $tmpip_2 = $jsonArr['IP_Station'][2]; $tmpip_3 = $jsonArr['IP_Station'][3]; $tmpIP = $tmpip_0.'.'.$tmpip_1.'.'.$tmpip_2.'.'.$tmpip_3; sg($otp.'addressIP',$tmpIP); // end арсим IP if($ot == 'Cluster_1') { }// end if($ot == 'Cluster_1') } // end if($propTitle == 'Config') elseif($propTitle == 'Inform') { sg($otp.'cluster_ID', $jsonArr['Host_ID']); if($ot == 'Cluster_1') { $otp = 'infoClst_1.'; sg($otp.'cluster_ID', $jsonArr['Host_ID']); sg($otp.'model_master', $jsonArr['ESP_Model']); sg($otp.'hard_master', $jsonArr['Hard_ESP']); sg($otp.'hard_slave', $jsonArr['Hard_Arduino']); } } // end if($propTitle == 'Inform') } // end if(gg($otp.'_jsonCheck') == 1)
$propTitle = $params['PROPERTY']; // получаем название изменившегося свойства $ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования if ($propTitle == 'rxStatus') $propTitle = 'Status'; elseif($propTitle == 'rxConfig') $propTitle = 'Config'; elseif($propTitle == 'rxInform') $propTitle = 'Inform'; if(gg($otp.'_jsonCheck') == 1) { say('готово', 2); // парсим json-строку $_readyjson = gg($otp.'ready'.$propTitle); $jsonArr = json_decode($_readyjson, true); if($propTitle == 'Status') { if($ot == 'Cluster_2') { // парсим выключатели $_clst = 'Clst2'; $nmbr = count($jsonArr['StatSW']); //узнаём сколько выключателей for ($i = 0; $i < $nmbr; $i++) { $tmpStatSW = $jsonArr['StatSW'][$i]; $tmplockSW = $jsonArr['LockSW'][$i]; $tmpSens_U = $jsonArr['Sens_U'][$i]; $tmpSens_I = $jsonArr['Sens_I'][$i]; if($i == 0) { sg($_clst.'Swch1.Status',$tmpStatSW); sg($_clst.'Swch1.Lock',$tmplockSW); sg($_clst.'Swch1.Sensor_U',$tmpSens_U); sg($_clst.'Swch1.Sensor_I',$tmpSens_I); } if($i == 1) { sg($_clst.'Swch2.Status',$tmpStatSW); sg($_clst.'Swch2.Lock',$tmplockSW); sg($_clst.'Swch2.Sensor_U',$tmpSens_U); sg($_clst.'Swch2.Sensor_I',$tmpSens_I); } } // end парсим выключатели }// end if($ot == 'Cluster_1') } // end if($propTitle == 'Status') elseif($propTitle == 'Config') { // парсим IP $tmpip_0 = $jsonArr['IP_Station'][0]; $tmpip_1 = $jsonArr['IP_Station'][1]; $tmpip_2 = $jsonArr['IP_Station'][2]; $tmpip_3 = $jsonArr['IP_Station'][3]; $tmpIP = $tmpip_0.'.'.$tmpip_1.'.'.$tmpip_2.'.'.$tmpip_3; sg($otp.'addressIP',$tmpIP); // end арсим IP if($ot == 'Cluster_2') { }// end if($ot == 'Cluster_1') } // end if($propTitle == 'Config') elseif($propTitle == 'Inform') { if($ot == 'Cluster_2') { }// end if($ot == 'Cluster_1') } // end if($propTitle == 'Inform') } // end if(gg($otp.'_jsonCheck') == 1)
Свойства класса:
Объекты класса:
Свойства класса:
Методы класса:
$propTitle = $params['PROPERTY']; // получаем название изменившегося свойства $ot = $this->object_title; // получаем название обэкта у которого это свойство $otp = $ot.'.'; // добаляем "." -модифицируем для дальнейшего использования if($propTitle == 'Sensor_U') { if($params['OLD_VALUE'] != $params['NEW_VALUE']) { sg($otp.'_lswChanged', 1); } } if($propTitle == 'Sensor_I') { $txt_11 = 'Включен первый локальный выключатель'; $txt_10 = 'Выключен первый локальный выключатель'; $txt_21 = 'Включен второй локальный выключатель'; $txt_20 = 'Выключен второй локальный выключатель'; $txt_31 = 'Проверте первую лампу'; $txt_32 = 'Проверте вторую лампу'; $_tmpS = gg($otp.'Status'); $_tmpL = gg($otp.'Lock'); $_tmpU = gg($otp.'Sensor_U'); $_tmpI = gg($otp.'Sensor_I'); if(gg($otp.'_lswChanged') == 1) { sg($otp.'_lswChanged', 0); if($ot == Clst1Swch1) { if($_tmpS == 1 && $_tmpU == 1 && $_tmpI == 1) say($txt_11, 2); elseif($_tmpS == 0 && $_tmpU == 0 && $_tmpI == 0) say($txt_10, 2); elseif($_tmpS == 1 && $_tmpU == 1 && $_tmpI == 0) say($txt_31, 2); elseif($_tmpS == 0 && $_tmpU == 1 && $_tmpI == 0 && $_tmpL == 0) say($txt_31, 2); } if($ot == Clst1Swch2) { if($_tmpS == 1 && $_tmpU == 1 && $_tmpI == 1) say($txt_21, 2); elseif($_tmpS == 0 && $_tmpU == 0 && $_tmpI == 0) say($txt_20, 2); elseif($_tmpS == 1 && $_tmpU == 1 && $_tmpI == 0) say($txt_32, 2); elseif($_tmpS == 0 && $_tmpU == 1 && $_tmpI == 0 && $_tmpL == 0) say($txt_32, 2); } } else { if($ot == Clst1Swch1) { if($_tmpS == 1 && $_tmpI == 0) say($txt_31, 2); } if($ot == Clst1Swch2) { if($_tmpS == 1 && $_tmpI == 0) say($txt_32, 2); } } } //say($_tmpS, 2); //say($ot); //say(gg($otp.'Sensor_U'), 2); //if($ot == Clst1Swch1) { // if($propTitle == 'Sensor_U') { // if($params['OLD_VALUE'] != $params['NEW_VALUE']) { // say('Изменился выключатель', 2); // say($_tmpS, 2); // say($_tmpU, 2); // say($_tmpI, 2); // if($_tmpS == 1 && $_tmpU == 1 && $_tmpI == 1) {say($txt_11, 2);} // elseif($_tmpS == 0 && $_tmpU == 0 && $_tmpI == 0) {say($txt_10, 2);} // } // else{ // } // } //} //if($ot == Clst1Swch2) { //} //if($propTitle == 'Sensor_U') { // if(gg($otp.'Sensor_U') == 1 ) say($txt_1, 2); // elseif(gg($otp.'Sensor_U') == 0 ) say($txt_2, 2); //}
Свойства класса:
Методы класса:
$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']." процентов");
Объекты класса:
say("Отключено питание");
//$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); //}
Свойства класса:
Методы класса:
$name='Cron_'.$this->object_title; SQLExec("DELETE FROM jobs WHERE title='".$name."'");
$this->setProperty('LastRun',date('Y-m-d H:i:s'));
Объекты класса:
say('цикл', 2); cm('Cluster_1.cmdSend', ['Code'=>105]);
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/processHomebridgeMQTT.inc.php');
Объекты класса:
Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty("updated",time()); $this->setProperty("updatedTime",date('H:i')); if ($this->getProperty('active')) { say("Режим ".$this->getProperty('title')." активирован."); } else { say("Режим ".$this->getProperty('title')." выключен."); }
$this->setProperty('active',1);
$this->setProperty('active',0);
Объекты класса:
setGlobal('minMsgLevel','2'); /* begin injection of {SDevices} */ require(DIR_MODULES.'devices/nightmode_activate.php'); /* end injection of {SDevices} */
setGlobal('minMsgLevel','1'); /* begin injection of {SDevices} */ require(DIR_MODULES.'devices/nightmode_deactivate.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/darknessmode_activate.php'); /* end injection of {SDevices} */
$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} */
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} */
$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} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/nobodyhomemode_activate.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/nobodyhomemode_deactivate.php'); /* end injection of {SDevices} */
Свойства класса:
Методы класса:
$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=10*60; } clearTimeOut($ot."_activity_timeout"); setTimeOut($ot."_activity_timeout","callMethod('".$ot.".onIdle');",$activity_timeout); $this->callMethod("updateActivityStatus"); /* begin injection of {SDevices} */ require(DIR_MODULES.'devices/Rooms_onActivity.php'); /* end injection of {SDevices} */
$this->setProperty('SomebodyHere',0); /* begin injection of {SDevices} */ require(DIR_MODULES.'devices/Rooms_onIdle.php'); /* end injection of {SDevices} */
$rooms=getObjectsByClass("Rooms"); $total=count($rooms); for($i=0;$i<$total;$i++) { $rooms[$i]['room']=getGlobal($rooms[$i]['TITLE'].'.Title'); 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']) { $somebodyHomeText="Никого нет дома. Были в ".date('H:i',$rooms[0]['time'])." (".$rooms[0]['room'].")"; } else { $res_rooms=array(); for($i=0;$i<$total;$i++) { if ($rooms[$i]['active']) { $res_rooms[]=$rooms[$i]['room']; } } $somebodyHomeText="Кто-то дома: ".implode(", ",$res_rooms); } setGlobal('somebodyHomeText',$somebodyHomeText); //echo "Updated"; /* begin injection of {SDevices} */ require(DIR_MODULES.'devices/Rooms_updateActivityStatus.php'); /* end injection of {SDevices} */
Объекты класса:
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SDevices_setUpdatedText.php'); /* end injection of {SDevices} */
require(DIR_MODULES.'devices/SDevices_statusUpdated.php');
require(DIR_MODULES.'devices/SDevices_logicAction.php');
Свойства класса:
Методы класса:
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} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SCameras_takeSeries.php'); /* end injection of {SDevices} */
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SControllers_turnOff.php');
require(DIR_MODULES.'devices/SControllers_switch.php');
require(DIR_MODULES.'devices/SControllers_turnOn.php');
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SDimmers_levelWorkUpdated.php'); /* end injection of {SDevices} */
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_turnOff.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_setColor.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SRGB_colorUpdated.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/SThermostats_switchEnable.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SThermostats_enable.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SThermostats_disable.php'); /* end injection of {SDevices} */
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SCounters_refreshStats.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SCounters_valueWorkUpdated.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/SPowerSensors_valueUpdated.php'); /* end injection of {SDevices} */
/* begin injection of {SDevices} */ require(DIR_MODULES.'devices/SPowerSensors_loadStatusChanged.php'); /* end injection of {SDevices} */
Методы класса:
/* 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'); 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."."; } } /* $objects=array('MotionSensor1'=>'Датчик движения 1','MotionSensor2'=>'Датчик движения 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 ($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
Объекты класса:
$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');
$h=(int)date('G',time()); $m=date('i',time()); if (isWeekDay()) { } if (timeBetween(getGlobal('NightModeEnd'),getGlobal('NightModeStart')) && getGlobal('clockChimeEnabled')) { if ($m=="00") { say(timeNow(),1); } } setGlobal('timeNow',date('H:i')); $homeStatus=date('H:i'); if (getGlobal('NobodyHomeMode.active')) { $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 (timeIs(gg('NightModeStart'))) { callMethod('NightMode.activate'); } elseif (timeIs(gg('NightModeEnd'))) { callMethod('NightMode.deactivate'); } if (timeIs("03:00")) { runScript("systemMaintenance"); } if (gg('ThisComputer.AlarmStatus') && timeIs(gg('ThisComputer.AlarmTime'))) { runScript('MorningAlarm'); }
, Украина
© 2024 - Site Built By SergeJey | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving