Свойства класса:
Методы класса:
Объекты класса:
if (isWeekDay()){ // сегодня рабочий день
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!');
// ieslegsim gaismu
setTimeOut('MI1','callMethod("MiLedRGBW1.turnOn");',1);
setTimeOut('MI2','callMethod("MiLedRGBW2.turnOn");',10);
setTimeOut('MI3','callMethod("MiLedRGBW3.turnOn");',20);
}
if (isWeekEnd()){ // сегодня выходной день
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!');
// ieslegsim gaismu
setTimeOut('MI2','callMethod("MiLedRGBW2.turnOn");',1);
setTimeOut('MI3','callMethod("MiLedRGBW3.turnOn");',10);
}
// это однократный будильник, выключем его
sg("AlarmOne.AlarmOn",0);
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!');
// ieslegsim gaismu
setTimeOut('MI1','callMethod("MiLedRGBW1.turnOn");',1);
setTimeOut('MI2','callMethod("MiLedRGBW2.turnOn");',10);
setTimeOut('MI3','callMethod("MiLedRGBW3.turnOn");',20);Свойства класса:
Методы класса:
$volume=round(65535*$params['VALUE']/100);
$this->setProperty('volumeLevel',$params['VALUE']);
safe_exec('..\\apps\\nircmd\\nircmdc setsysvolume '.$volume);
say("Изменилась громкость до ".$params['VALUE']." процентов");Объекты класса:
$command=$params['command'];
$short_command='';
$dt=recognizeTime($command,$short_command);
if (preg_match('/скажи сколько врем/is',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say('Сейчас '.timeNow(),2);
} elseif (preg_match('/сколько время/is',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята');
echo $short_command;
return;
}
say('Сейчас '.timeNow());
} elseif (preg_match('/повтори (.+)/is',$command,$m) || preg_match('/скажи (.+)/is',$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['t']
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date("H:i",time()));
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=30*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);
if (!isset($params['h'])) {
return;
}
$old_temp=$this->getProperty('humidity');
$t=round($params['h'],1);
if ($t>100) return;
$this->setProperty('humidity',$t);
if ($params['uptime']) {
$this->setProperty('uptime',$params['uptime']);
}
if ($t>$old_temp) {
$d=1;
} elseif ($t<$old_temp) {
$d=-1;
} else {
$d=0;
}
$this->setProperty('direction',$d);
$linked_room=$this->getProperty("LinkedRoom");
if ($linked_room) {
setGlobal($linked_room.'.Humidity',$t);
}Объекты класса:
Свойства класса:
Методы класса:
if ($params['status']) {
$this->setProperty('status',$params['status']);
}
$this->setProperty('updatedTimestamp',time());
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=12*60*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);Свойства класса:
Методы класса:
$this->setProperty('status',$params['status']); // выставляем статус сенсора
$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['status']) {
$this->setProperty('motionDetected',1);
clearTimeOut($this->object_title.'_detected');
setTimeOut($this->object_title.'_detected',"setGlobal('".$this->object_title.".motionDetected',0);",30);
$linked_room=$this->getProperty('LinkedRoom');
if ($linked_room!='') {
callMethod($linked_room.'.onActivity');
}
if ($this->object_title=='sensorMovement3' || $this->object_title=='sensorMovementRemote1' || $this->object_title=='sensorMovementRemote2') {
//|| $this->object_title=='sensorMovement5'
return; // не реагируем на движение в спальне, по ip-сенсорам и по сенсору на втром этаже
}
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", 1*60*60); // выполняем если целый час никого не было
if (getGlobal('NobodyHomeMode.active')) {
callMethod('NobodyHomeMode.deactivate');
}
$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("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');setGlobal('minMsgLevel','1');Свойства класса:
Методы класса:
$status=$this->getProperty("status");
if ($status) {
$this->callMethod('turnOn');
} else {
$this->callMethod('turnOff');
}
$this->callMethod("onChange");$status=$this->getProperty("status");
if ($status) {
$this->callMethod('turnOff');
} else {
$this->callMethod('turnOn');
}$this->setProperty("status",0);$this->setProperty("status",1);$this->setProperty("updated",time());
$this->setProperty("updatedTime",date('H:i'));Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty('updated',time());
$this->setProperty('updatedTime',date('H:i'));
include_once(ROOT.'lib/hardware/milight.php');
if (is_array($params)) {
$command=$params['command'];
$value=$params['value'];
} else {
$command=$params;
}
$host=$this->getProperty('Host');
$type=(int)$this->getProperty('LampType');
$zone=(int)$this->getProperty('Zone');
$milight = new Milight($host);
$commands='';
if ($type==0) {
$milight->setWhiteActiveGroup($zone);
if ($command=='leveldown') {
$milight->command('whiteBrightnessDown');
}
if ($command=='levelup') {
$milight->command('whiteBrightnessUp');
}
if ($command=='level' && $value>=90) {
$command='levelmax';
}
if ($command=='level' && $value<=90) {
$command='levelmin';
}
if ($command=='levelmax') {
$milight->command('whiteGroup'.$zone.'BrightnessMax');
}
if ($command=='levelmin') {
$milight->command('whiteGroup'.$zone.'BrightnessMin');
}
if ($command=='nightmode') {
$milight->command('whiteGroup'.$zone.'NightMode');
}
if ($zone==1) {
if ($command=='on') {
$milight->whiteGroup1On();
}
if ($command=='off') {
$milight->whiteGroup1Off();
}
}
if ($zone==2) {
if ($command=='on') {
$milight->whiteGroup2On();
}
if ($command=='off') {
$milight->whiteGroup2Off();
}
}
if ($zone==3) {
if ($command=='on') {
$milight->whiteGroup3On();
}
if ($command=='off') {
$milight->whiteGroup3Off();
}
}
if ($zone==4) {
if ($command=='on') {
$milight->whiteGroup4On();
}
if ($command=='off') {
$milight->whiteGroup4Off();
}
}
}
if ($type==1) {
if ($command=='disco') {
$milight->setRgbwActiveGroup($zone);
$milight->rgbwSendOnToActiveGroup();
$milight->command('rgbwDiscoMode');
}
if ($command=='discofaster') {
$milight->setRgbwActiveGroup($zone);
$milight->rgbwSendOnToActiveGroup();
$milight->command('rgbwDiscoFaster');
}
if ($command=='discoslower') {
$milight->setRgbwActiveGroup($zone);
$milight->rgbwSendOnToActiveGroup();
$milight->command('rgbwDiscoSlower');
}
if ($command=='level') {
$milight->setRgbwActiveGroup($zone);
$milight->rgbwBrightnessPercent($value);
}
if ($command=='color') {
$milight->setRgbwActiveGroup($zone);
$milight->rgbwSetColorHexString($value);
}
if ($zone==1) {
if ($command=='on') {
$milight->rgbwGroup1On();
}
if ($command=='off') {
$milight->rgbwGroup1Off();
}
if ($command=='white') {
$milight->rgbwGroup1SetToWhite();
}
}
if ($zone==2) {
if ($command=='on') {
$milight->rgbwGroup2On();
}
if ($command=='off') {
$milight->rgbwGroup2Off();
}
if ($command=='white') {
$milight->rgbwGroup2SetToWhite();
}
}
if ($zone==3) {
if ($command=='on') {
$milight->rgbwGroup3On();
}
if ($command=='off') {
$milight->rgbwGroup3Off();
}
if ($command=='white') {
$milight->rgbwGroup3SetToWhite();
}
}
if ($zone==4) {
if ($command=='on') {
$milight->rgbwGroup4On();
}
if ($command=='off') {
$milight->rgbwGroup4Off();
}
if ($command=='white') {
$milight->rgbwGroup4SetToWhite();
}
}
}
sleep(1);$this->setProperty('status',1);
$this->callMethod('sendCommand',array('command'=>'disco'));$this->setProperty('status',1);
$this->callMethod('sendCommand',array('command'=>'discofaster'));$this->setProperty('status',1);
$this->callMethod('sendCommand',array('command'=>'discoslower'));$this->setProperty('status',0);
$this->callMethod('sendCommand',array('command'=>'off'));$this->setProperty('status',1);
$this->callMethod('sendCommand',array('command'=>'on'));$status=$this->getProperty("status");
if ($status) {
if ($this->getProperty('LampType')==1) {
$this->callMethod('setColor');
}else {
$this->callMethod('turnOn');
}
} else {
$this->callMethod('turnOff');
}$level=$this->getProperty("Level");
if ($level>0) {
$this->callMethod('setLevel',array('level'=>$level));
} else {
$this->callMethod('turnOff');
}/*
$colors=array(
'#ff0000',
'#00ff00',
'#0000ff');
$color=$colors[rand(0,count($colors)-1)];
*/
$rand = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
$color = '#'.$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)].$rand[rand(0,15)];
$this->callMethod('setColor',array('color'=>$color));$this->setProperty('status',1);
$this->setProperty('Mode','C');
if ($params['color']) {
$this->setProperty('Color',$params['color']);
} else {
$params['color']=$this->getProperty('Color');
}
$this->callMethod('sendCommand',array('command'=>'color','value'=>$params['color']));if ($params['level']>0) {
$this->setProperty('status',1);
} else {
$this->setProperty('status',0);
}
$this->setProperty('Level',$params['level']);
$this->callMethod('sendCommand',array('command'=>'level','value'=>$params['level']));$this->setProperty('status',1);
$this->setProperty('Mode','W');
$this->callMethod('sendCommand',array('command'=>'white'));Объекты класса:
Свойства класса:
Методы класса:
$cmdline='"c:\Program Files\nooLite\nooLite.exe" -api '.$params['command'];
$last_called=gg('NoolightCommandSend');
$min_delay=3;
$now=time();
if (($now-$last_called)>$min_delay) {
//safe_exec($cmdline);
$last_callled=$now;
sg('NoolightCommandSend',$last_called);
DebMes("Noolite instant exec: ".$cmdline);
system($cmdline);
//exec($cmdline);
} else {
if ($last_callled<$now) {
$last_callled=$now;
}
$last_called+=$min_delay;
sg('NoolightCommandSend',$last_called);
DebMes("Noolite scheduled job for ".date('H:i:s',$last_called));
AddScheduledJob("noolight".md5($cmdline),"safe_exec('".$cmdline."');",$last_called);
}
$this->setProperty("status",0);
//safe_exec('"c:\Program Files\nooLite\noolite.exe" -api -off_ch'.$this->getProperty("channel"));
$this->callMethod("sendCommand",array('command'=>'-off_ch'.$this->getProperty("channel")));$this->setProperty("status",1);
$this->callMethod("sendCommand",array('command'=>'-on_ch'.$this->getProperty("channel")));Свойства класса:
Методы класса:
$code1=$this->getProperty('Code1');
$code2=$this->getProperty('Code2');
safe_exec("c:\_majordomo\apps\arduino_gw\arduino_gw.exe rcon$code1:$code2;");
$this->setProperty("status",1);$code1=$this->getProperty('Code1');
$code2=$this->getProperty('Code2');
safe_exec("c:\_majordomo\apps\arduino_gw\arduino_gw.exe rcoff$code1:$code2;");
$this->setProperty("status",0);Свойства класса:
Методы класса:
$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");
if ($this->object_title=='Bedroom' && timeBetween('23:00', '09:00')) {
return; // не реагируем на движение в спальне
}
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", 1*60*60); // выполняем если целый час никого не было
if (getGlobal('NobodyHomeMode.active')) {
callMethod('NobodyHomeMode.deactivate');
}
$last_register=registeredEventTime('inhouseMovement'); // проверяем когда в последний раз срабатывало событие "движение внутри дома"
registerEvent('inhouseMovement',$this->name,2); // регистрируем событие "движение внутри дома"
if (!$last_register || ((time()-$last_register)>2*60*60)) { // срабатывало более 2х часов назад
if (timeBetween('06:00', '12:00')) { // движение замечено утром
runScript('morningGreeting'); // запускаем скрипт "доброе утро"
}
if (timeBetween('16:00', '01:00')) { // движение замечено вечером
runScript('eveningGreeting'); // запускаем скрипт приветствия
}
}$this->setProperty('SomebodyHere',0);
$this->callMethod("updateActivityStatus");$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";Объекты класса:
// Если кто-то зашёл в спальню первый раз за вечер, то включаем ночник
if (getGlobal('DarknessMode.active') && (!getGlobal('MiLedRGBW3.status')) && ((time()-$this->getProperty('LastAutoLight'))>16*60*60)) {
$this->setProperty('LastAutoLight',time());
callMethod('MiLedRGBW3.turnOn');
callMethod('MiLedRGBW3.sendCommand',array('command'=>'levelmax'));
}Методы класса:
Объекты класса:
echo "status received: ".$params['status'];
global $voicemode; $voicemode='off'; processCommand($params['message']);
Свойства класса:
Методы класса:
Объекты класса:
$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.".";
}
}
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));
} else {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}$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');
}Свойства класса:
Методы класса:
//$params['t']
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date("H:i",time()));
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=30*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);
if (!isset($params['t'])) {
return;
}
$old_temp=$this->getProperty('temp');
$t=round($params['t'],1);
if ($t>110) return;
$this->setProperty('temp',$t);
if ($params['uptime']) {
$this->setProperty('uptime',$params['uptime']);
}
if ($t>$old_temp) {
$d=1;
} elseif ($t<$old_temp) {
$d=-1;
} else {
$d=0;
}
$this->setProperty('direction',$d);
$linked_room=$this->getProperty("LinkedRoom");
if ($linked_room) {
setGlobal($linked_room.'.Temperature',$t);
}Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
$h=(int)date('G',time());
$m=date('i',time());
if (($h>=8)) {
if ($m=="00") {
say(timeNow());
}
}
//Записываем текущее время
sg("ThisComputer.timeNow",date( "H:i", time()));
//будильник
$objects=getObjectsByClass("AlarmClock");
foreach($objects as $obj) { // переберем все будильники в системе
if (getGlobal($obj['TITLE'].".AlarmOn") && timeIs(getGlobal($obj['TITLE'].".AlarmTime"))){ //если будильник включен и время совпало
callMethod($obj['TITLE'].".AlarmRun"); // выполним метод будильника
}
}
//В обед расскажем анекдот
//if (timeIs('12:30')) {
// callMethod("Chat_request.action",array("command"=>"Расскажи анекдот"));
// say("Анекдот:");
//}
//Читаем состояние сенсоров сервера
RunScript('sensorsUbuntu');
// Включение/выключение реле левой части RGB подсветки коридора
if (timeBetween(gg("YandexSamara.SunSet"),gg("YandexSamara.SunRise"))){ // темно
if (gg('Relay_RGB_Left.status')==0){
sg('Relay_RGB_Left.status',1);
}
}else{
if (gg('Relay_RGB_Left.status')==1){
sg('Relay_RGB_Left.status',0);
}
}
//Подписываем на события таймера методы проверок
//всех заитересованных объектов
//при этом код проверки инкапсулирован в самом объекте
// Режим Охрана
callMethod("SecurityArmedMode.check");
// Режим Никого нет дома
callMethod("NobodyHomeMode.check");
// Режим У нас гости
callMethod("GuestsMode.check");
// Режим Все спят
callMethod("SleepAllMode.check");
// напоминалка
callMethod("TaskExistMode.check");
// Блок Экономайзер
// Коридорная люстра
if (gg('Relay_Hallway_Light.status')){ // если горит свет в корридоре
if (gg('sensorDoorHeck.status') or gg('sensorDoorLockDown.status')){ // закрыт один или оба замка
if (gg('sensorHallwayPIR.status') // датчик движения не активирован
and (time()-gg('sensorHallwayPIR.updatedTimestamp'))>60*2){ // больше 2 минут
sg('Relay_Hallway_Light.status',0); // выключить
}
}
}
// Свет в спальне
if (gg('MiLedRGBW1.status')==1){ // если горит свет в туалете
if (time()-gg('MiLedRGBW1.updated')>60*30){ // больше 30 минут
callMethod("MiLedRGBW1.turnOff"); // выключить
}
}
// Свет в спальне
if (gg('MiLedRGBW3.status')==1){ // если горит свет в туалете
if (time()-gg('MiLedRGBW3.updated')>60*30){ // больше 30 минут
callMethod("MiLedRGBW3.turnOff"); // выключить
}
}
// Свет в кухне
if (gg('MiLedRGBW2.status')==1){ // если горит свет в кухне
if (time()-gg('MiLedRGBW2.updated')>60*60){ // больше 60 минут
callMethod("MiLedRGBW2.turnOff"); // выключить
}
}
// Входная дверь закрыта но не заперта
if ( gg('sensorDoorEnter.status')==1 // дверь закрыта
and gg('sensorDoorHeck.status')==0 // задвижка открыта
and gg('sensorDoorLockDown.status')==0 // нижний замок открыт
and gg('sensorDoorLockUp.status')==0 // верхний замок открыт
and ($m=="00" or $m=="15" or $m=="30" or $m=="45") ) // минута кратна 15
{
say("Внимание! Открыта входная дверь!",5);
}Методы класса:
Объекты класса:
if ($params['serial']=='' && $params['devname']!='') {
$params['serial']=$params['devname'];
}
$device=SQLSelectOne("SELECT * FROM usbdevices WHERE SERIAL LIKE '".$params['serial']."'");
if (!$device['ID']) {
// new device connected
//say("Подключено новое устройство",1);
$device=array();
$device['SERIAL']=$params['serial'];
$device['TITLE']='устройство '.$params['devname'];
$device['FIRST_FOUND']=date('Y-m-d H:i:s');
$device['LAST_FOUND']=date('Y-m-d H:i:s');
$device['LOG'].=$device['FIRST_FOUND'].' подключено (впервые)'."\n";
$device['ID']=SQLInsert('usbdevices',$device);
} else {
// device already in our database
//say("Подключено ".$device['TITLE'],1);
if ($device['USER_ID']) {
$user=SQLSelectOne("SELECT * FROM users WHERE ID='".$device['USER_ID']."'");
if ($user['ID']) {
//$user['NAME']; // теперь мы знаем имя пользователя, связанного с этим устройством
}
}
$device['LAST_FOUND']=date('Y-m-d H:i:s');
$device['LOG']=$device['LAST_FOUND'].' подключено'."\n".$device['LOG'];
SQLUpdate('usbdevices',$device);
if ($device['SCRIPT_ID']!='') {
runScript($device['SCRIPT_ID'],$params);
} elseif ($device['SCRIPT']!='') {
eval($device['SCRIPT']);
}
}Свойства класса:
Объекты класса:
, Latvija
Веб-сайт:
http://starpcitu.blogspot.com
© 2026 SJLab | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving