Свойства класса:
Методы класса:
Объекты класса:
if (isWeekEnd()){ // сегодня выходной день // все проснулись setGlobal("SleepAllMode.active",0); say('Пора вставать!'); // включим радио // callMethod("Radio.RadioPlay"); // запланируем выключить радио через 25 минут // SetTimeOut("AlarmWeekEnd_RadioStop",'callMethod("Radio.RadioStop");', 60*25); // запланируем напоминание о точном времени и доклад погоды // SetTimeOut("AlarmWeekEnd_timeNow1",'callMethod("сколько время.action");', 60*30); // SetTimeOut("AlarmWeekEnd_Pogoda", 'callMethod("погода на улице.action");', 60*35); // SetTimeOut("AlarmWeekEnd_timeNow2",'callMethod("сколько время.action");', 60*40); // SetTimeOut("AlarmWeekEnd_timeNow3",'callMethod("сколько время.action");', 60*50); // если на улице темно // if(timeBetween(gg("Yandex.SunSet"),gg("Yandex.SunRise"))){ // плавное включение Бра в спальне // runScript("nl_lowOn_SpalnyaBra"); // Запланируем выключить его через полчаса // SetTimeOut("AlarmWeekEnd_BraOff",'callMethod("NooLiteD_SpalnyBra.turnOff");', 30*60); // } }
if (isWeekDay()) { // сегодня рабочий день // все проснулись setGlobal("SleepAllMode.active",0); $add_word=getGlobal('AlarmWeekDay.AlarmText'); say(timeNow()); say($add_word); sleep(2); runScript("sayTodayAgenda"); }
// это однократный будильник, выключем его sg("AlarmOne.AlarmOn",0); // все проснулись setGlobal("SleepAllMode.active",0); $add_word=getGlobal('AlarmOne.AlarmText'); if ($add_word<>"") {say($add_word,5); } if (gg("AlarmOne.AlarmSound")) { playSound('alarm_num7'); //playSound('alarm_num7'); }
Свойства класса:
Методы класса:
$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("Отключено питание");
say('Привет',2);
Свойства класса:
Методы класса:
$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=60*60; // 60 минут } clearTimeOut($ot."_alive"); setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);
Объекты класса:
Свойства класса:
Методы класса:
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');
Свойства класса:
Методы класса:
Объекты класса:
include_once(DIR_MODULES.'app_radio/app_radio.class.php'); $app_radio=new app_radio(); if(is_array($params)) { if(isset($params['sta'])) $app_radio->change_station($params['sta'],$app_radio); if(isset($params['cmd'])) $app_radio->control($params['cmd']); if(isset($params['vol'])) $app_radio->set_volume($params['vol'],$app_radio); } else { if($params=='play' || $params=='stop') $app_radio->control($params); else if(strpos($params, "vol")===0) $app_radio->set_volume((int)substr($params,3),$app_radio); else if(strpos($params, "sta:")===0) $app_radio->change_station(substr($params,4),$app_radio); }
Методы класса:
$this->setProperty("RadioIsPlay",0); $this->callMethod("RadioSwitch");
if(!getGlobal("NobodyHomeMode.active")){ $this->setProperty("RadioIsPlay",1); $this->callMethod("RadioSwitch"); }else{ say('Никого нет дома, радио не включаю'); }
// if (getGlobal("Radio.RadioIsPlay")){ say("Включаю радио"); // safe_exec("mpc play 1"); getURL('http://127.0.0.1:8080/requests/status.xml?command=pl_empty',0); getURL('http://127.0.0.1:8080/requests/status.xml?command=in_play&input=http://air.verdure.net:8881/listen.pls',0); // getURL('http://127.0.0.1:8080/requests/status.xml?command=in_play&input=http://streaming.radionomy.com/The-Smooth-Lounge',0); // getURL('http://127.0.0.1:8080/requests/status.xml?command=in_play&input=http://stream-sd.radioparadise.com:8056',0); setGlobal("Radio.RadioPlayBeginTime",time()); }else{ // safe_exec("mpc stop"); getURL('http://127.0.0.1:8080/requests/status.xml?command=pl_stop',0); say("Радио выключено"); }
say("Установим уровень громкости радио ".getGlobal("Radio.RadioVolume")." %."); exec("mpc volume ".getGlobal("Radio.RadioVolume"));
Свойства класса:
Методы класса:
$status=$this->getProperty("status"); if ($status) { $this->callMethod('turnOn'); } else { $this->callMethod('turnOff'); }
$status=$this->getProperty("status"); if ($status) { $this->callMethod('turnOff'); } else { $this->callMethod('turnOn'); }
$this->setProperty("status",0);
$this->setProperty("status",1);
Объекты класса:
getURL('192.168.200.105/gpio?st=1&pin=4');
getURL('192.168.200.105/gpio?st=0&pin=4');
Свойства класса:
Методы класса:
$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");
$this->setProperty('SomebodyHere',0);
$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";
Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
$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'); }
$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 (!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'); }
Свойства класса:
Методы класса:
$h=(int)date('G',time()); $m=date('i',time()); /*if (isWeekDay()) { if (timeIs('10:22')) { say("Доброе утро"); }/* if (($h>=9)) { if ($m=="57") {*/ say(timeNow()); //say ('Доброе утро');}
//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//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//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//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//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//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//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//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 yaWeather module*/ $updateTime = gg('yw_setting.updateTime'); if($updateTime > 0){ $count = gg('yw_setting.countTime'); if($count >= $updateTime){ include_once(DIR_MODULES.'app_yaweather/app_yaweather.class.php'); $app_yaweather=new app_yaweather(); $app_yaweather->get_weather(gg('yw_setting.city_id')); sg('yw_setting.countTime',1); } else { $count++; sg('yw_setting.countTime',$count); } }/* END yaWeather*/
Объекты класса:
$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('NooLiteD_TualetTop.status')==1){ // если горит свет в туалете if (time()-gg('NooLiteD_TualetTop.updatedTimestamp')>60*30){ // больше 30 минут callMethod("NooLiteD_TualetTop.turnOff"); // выключить } } // Свет в спальне if (gg('NooLiteD_SpalnyTop.status')==1){ // если горит свет в спальне if (time()-gg('NooLiteD_SpalnyTop.updatedTimestamp')>60*30){ // больше 30 минут callMethod("NooLiteD_SpalnyTop.turnOff"); // выключить } } // Свет в кухне if (gg('NooLiteD_KuhnyaTop.status')==1){ // если горит свет в кухне if (time()-gg('NooLiteD_KuhnyaTop.updatedTimestamp')>60*60){ // больше 60 минут callMethod("NooLiteD_KuhnyaTop.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); }
$h=(int)date('G',time()); // раскидываем дату и время если сейчас 00:00 час if (($h=="00")) { $day[0]="воскресенье"; $day[1]="понедельник"; $day[2]="вторник"; $day[3]="среда"; $day[4]="четверг"; $day[5]="пятница"; $day[6]="суббота"; $month[1]="января"; $monthAlt[1]="ЯНВАРЬ"; $month[2]="февраля"; $monthAlt[2]="ФЕВРАЛЬ"; $month[3]="марта"; $monthAlt[3]="МАРТ"; $month[4]="апреля"; $monthAlt[4]="АПРЕЛЬ"; $month[5]="мая"; $monthAlt[5]="МАЙ"; $month[6]="июня"; $monthAlt[6]="ИЮНЬ"; $month[7]="июля"; $monthAlt[7]="ИЮЛЬ"; $month[8]="августа"; $monthAlt[8]="АВГУСТ"; $month[9]="сентября"; $monthAlt[9]="СЕНТЯБРЬ"; $month[10]="октября"; $monthAlt[10]="ОКТЯБРЬ"; $month[11]="ноября"; $monthAlt[11]="НОЯБРЬ"; $month[12]="декабря"; $monthAlt[12]="ДЕКАБРЬ"; sg("ThisComputer.DateD",date( "d", time())); sg("ThisComputer.DateM",date( "m", time())); sg("ThisComputer.DateY",date( "Y", time())); sg("ThisComputer.Date",date( "d.m.Y", time())); sg("ThisComputer.Day",$day[date("w")]); sg("ThisComputer.Month",$month[date("n")]); sg("ThisComputer.MonthAlt",$monthAlt[date("n")]); } if (isOnline("Интернет")) { // обновим прогноз погоды callMethod("Izhevsk.sensors"); // обновим курс валюты каждые 4 часа if (!($h%4)) {callMethod("cbr.update");} } else { say ("Проверить погоду и курсы валют пока не могу, так как нет доступа в интеренет. Попробую сделать это через один час. ",-1); } //дни рождения, проверять при условии разрешения в установках и в 9-00 if ((gg("Sets.checkBirthday"))&&($h=="09")) { runScript("birthday"); }
Свойства класса:
Методы класса:
Объекты класса:
$city_id=gg("37145"); //ID города узнаем тут: https://pogoda.yandex.ru/static/cities.xml $data_file="http://export.yandex.ru/weather-ng/forecasts/$city_id.xml?".rand(); // адрес xml файла - 28411 //say($data_file); $xml = simplexml_load_file($data_file); // раскладываем xml на массив // Запишем прогноз погоды на 10 дней $nDay=0; foreach($xml->day as $day) { // записываем дату с днем недели на каждый день sg("Mozdok.mcD".$nDay."_Day",getDayDate($day['date'])); // нам нужны только 4 части дня по 6+1 параметров в каждом for($i = 0;$i < 4;$i++) { $prop_Temp = 'mcD'.$nDay.'_Temp_'.$i; //addClassProperty('Weather',$prop_Temp); $prop_Image = 'mcD'.$nDay.'_Image_'.$i; //addClassProperty('Weather',$prop_Image); $prop_WindDir = 'mcD'.$nDay.'_WindDir_'.$i; //addClassProperty('Weather',$prop_WindDir); $prop_WindDirText = 'mcD'.$nDay.'_WindDirText_'.$i; //addClassProperty('Weather',$prop_WindDirText); $prop_WindSpeed = 'mcD'.$nDay.'_WindSpeed_'.$i; //addClassProperty('Weather',$prop_WindSpeed); $prop_Humidity = 'mcD'.$nDay.'_Humidity_'.$i; //addClassProperty('Weather',$prop_Humidity); $prop_Pressure = 'mcD'.$nDay.'_Pressure_'.$i; //addClassProperty('Weather',$prop_Pressure); // 1 температура sg("Mozdok.".$prop_Temp, getTempSign($day->day_part[$i]->{'temperature-data'}->avg)); // 2 Картинка sg("Mozdok.".$prop_Image,$day->day_part[$i]->{'image-v3'}); // 3 Направление ветра $dir = $day->day_part[$i]->wind_direction; // Функция возвращает массив, поэтому записываем в переменные значения, полученные в функции list ($dir, $dirtext) = getWindDirection($dir); sg("Mozdok.".$prop_WindDir, $dir); sg("Mozdok.".$prop_WindDirText, $dirtext); // 4 Скорость ветра sg("Izhevsk.".$prop_WindSpeed,$day->day_part[$i]->wind_speed); // 5 Влажность sg("Mozdok.".$prop_Humidity,$day->day_part[$i]->humidity); // 6 Атмосферное давление sg("Mozdok.".$prop_Pressure,$day->day_part[$i]->pressure); } $nDay++; } // Проговариваем, при необходимости $sayMetUSD = gg ("Sets.sayMetUSD"); if ($sayMetUSD) { say("Читаю прогноз погоды на 10 дней с Yandex",($sayMetUSD-2)); } // ******************************************************** // КОНЕЦ ОСНОВНОГО БЛОКА // Функция - добавления "+" к положительной температуре function getTempSign($temp) { $temp = (int)$temp; return $temp > 0 ? '+'.$temp : $temp; } // Функция - получить направления ветра в МАССИВ function getWindDirection($wind) { $wind = (string)$wind; $wind_direction = array('s'=>'↑ ю', 'n'=>'↓ с', 'w'=>'→ з', 'e'=>'← в', 'sw'=>'↗ юз', 'se'=>'↖ юв', 'nw'=>'↘ сз', 'ne'=>'↙ св'); $wind_dirtxt = array('s'=>'южный', 'n'=>'северный', 'w'=>'западный', 'e'=>'восточный', 'sw'=>'юго-западный', 'se'=>'юго-восточный', 'nw'=>'северо-западный', 'ne'=>'северо-восточный'); return array ($wind_direction[$wind], $wind_dirtxt[$wind]); } // Функция - получить локализованный день недели function getDayDate($date) { $date = strtotime($date); // $months = array('','января','февраля','марта','апреля','мая','июня','июля','августа','сентября','октября','ноября','декабря'); $days = array('ВС','ПН', 'ВТ', 'СР', 'ЧТ', 'ПТ', 'СБ'); // return $days[date('w', $date)].', '.(int)date('d',$date).' '.$months[date('n', $date)].' '.date('y',$date).' г.'; return $days[date('w', $date)]; }
$city_id=gg("37145"); //ID города узнаем тут: https://pogoda.yandex.ru/static/cities.xml $data_file="http://export.yandex.ru/weather-ng/forecasts/$city_id.xml?".rand(); // адрес xml файла - 28411 //say($data_file); $xml = simplexml_load_file($data_file); // раскладываем xml на массив // температура вчера в это же время $temp_yesterday=$xml->yesterday->temperature; // Если значение температуры положительно, для наглядности добавляем "+" $temp_yesterday = getTempSign($temp_yesterday); sg("Mozdok.TempYesterday",$temp_yesterday); // температура сейчас $temp=$xml->fact->temperature; if (date('G')==13) {sg("Mozdok.Temp13h",$temp);} if (date('G')==21) {sg("Mozdok.Temp21h",$temp);} $temp = getTempSign($temp); // Если значение температуры положительно, для наглядности добавляем "+" // достаем из XML-файла время его чтения $XMLuptime = $xml->fact->uptime; $XMLuptime = explode("T", $XMLuptime); $XMLuptimeTo = ($XMLuptime[0].' '.$XMLuptime[1]); // addClassProperty('Weather','XMLuptime'); sg("Izhevsk.XMLuptime",$XMLuptimeTo); // сохраняем основные параметры текущей погоды sg("Mozdok.Temp",$temp); sg("ThisComputer.TempOutside",$temp); sg("Mozdok.Type",$xml->fact->weather_type); sg("Mozdok.Pressure",$xml->fact->pressure); sg("Mozdok.Humidity",$xml->fact->humidity); sg("Mozdok.WindSpeed",$xml->fact->wind_speed); sg("Mozdok.Image",$xml->fact->{'image-v3'}); // определение вероятности дождя 0 или 1 $rain1=gg("Izhevsk.Type"); $rain2=$xml->day[0]->day_part[0]->weather_type; $rain3=$xml->day[0]->day_part[1]->weather_type; $rain4=$xml->day[0]->day_part[2]->weather_type; $rain5=$xml->day[0]->day_part[3]->weather_type; $rain=($rain1. $rain2. $rain3. $rain4. $rain5); $pos = strpos($rain, "дожд"); if ($pos === false) { sg("Izhevsk.Rain",0); } else { sg("Izhevsk.Rain",1); // say("Возможен дождь",2); } // Направление ветра $dir = $xml->fact->wind_direction; // Функция возвращает массив, поэтому записываем в переменные значения, полученные в функции list ($dir, $dirtext) = getWindDirection($dir); sg("Mozdok.WindDir",$dir); sg("Mozdok.WindDirText",$dirtext); // Солнце: восход/закат sg("Mozdok.SunRise",$xml->day[0]->sunrise); sg("Mozdok.SunSet",$xml->day[0]->sunset); // Луна sg("Mozdok.Moon_phase",$xml->day[0]->moon_phase); sg("Mozdok.MoonRise",$xml->day[0]->moonrise); sg("Mozdok.MoonSet",$xml->day[0]->moonset); // длинный текстовый прогноз погоды // $metcast=""; $metcast="На улице ".gg("Izhevsk.Type")."."; // ветер $WindSpeed=(float)gg("Izhevsk.WindSpeed"); if ($WindSpeed<1) { $metcast.=' Ветра, скорее всего, нет.'; } elseif ($WindSpeed<3) { $metcast.=' Возможен слабый ветер.'; } elseif ($WindSpeed<6) { $metcast.=' Возможен сильный ветер.'; } elseif ($WindSpeed<9) { $metcast.=' Возможен довольно сильный ветер.'; } else { $metcast.=' Возможен очень сильный ветер.'; } $w=round(strip_tags(gg("Izhevsk.Temp"))); $tempw=$w; if($w < "0"){ $tempw=abs($w); } if($w > "0"){ $templus=" плюс "; } if($tempw >= 11 and $tempw <= 14){ $tempcels=" градусов";} else{ while ($tempw > 9){ $tempw=$tempw-10; } if($tempw == 0 or $tempw >= 5 and $tempw <= 9){ $tempcels=" градусов"; } if($tempw == 1){ $tempcels=" градус"; } if($tempw >= 2 and $tempw <= 4){ $tempcels=" градуса"; } } $metcast.=' Температура '.gg("Izhevsk.Temp").' '.$tempcels.'.'; $tm=(float)gg("Izhevsk.Temp"); if ($tm<-40) { $metcast.=' Мы морозов не боимся!'; } elseif ($tm<-30) { $metcast.=' Очень холодно, оденьтесь теплее.'; } elseif ($tm<-20) { $metcast.=' Самое время есть мороженое.'; } elseif ($tm<-10) { $metcast.=' Холодновато.'; } elseif ($tm<-3) { $metcast.=' Не особо холодно.'; } elseif ($tm<3) { $metcast.=' Значит, возможно, гололёд.'; } elseif ($tm<10) { $metcast.=' Тепловато.'; } elseif ($tm<25) { $metcast.=' Тепло.'; } elseif ($tm<30) { $metcast.=' Жарко.'; } elseif ($tm>30) { $metcast.=' Ташкент.'; } // $metcast.=' Восход солнца сегодня в '.gg("Izhevsk.SunRise").','; // $metcast.=' закат в '.gg("Izhevsk.SunSet").'.'; sg("Izhevsk.metcast",$metcast); // прогноз на 3 дня $w3days="Сегодня ночью будет "; $temp=$xml->day[0]->day_part[3]->temperature_from; if ($temp>0) {$temp='+'.$temp;} $w3days.=$temp; $w3days.="°, "; $w3days.=$xml->day[0]->day_part[3]->weather_type; $w3days.=".\r\nЗавтра днём будет "; $temp=$xml->day[1]->day_part[1]->temperature_from; if ($temp>0) {$temp='+'.$temp;} $w3days.=$temp; $w3days.="°, "; $w3days.=$xml->day[1]->day_part[1]->weather_type; $w3days.=". Послезавтра ночью "; $temp=$xml->day[1]->day_part[3]->temperature_from; if ($temp>0) {$temp='+'.$temp;} $w3days.=$temp; $w3days.="°, "; $w3days.=$xml->day[1]->day_part[3]->weather_type; $w3days.="."; sg("Izhevsk.forecast",$w3days); // Определяем время года $season = $xml->fact->season; switch ($season){ case 'winter': $season="зима"; break; case 'summer': $season="лето"; break; case 'autumn': $season="осень"; break; case 'spring': $season="весна"; break; } sg("Mozdok.season",$season); //время года // Обновляем показатели жизни объекта sg("Mozdok.updatedTimestamp", time()); sg("Mozdok.updatedTime", date( "H:i - d.m.Y", time())); // Проговариваем, при необходимости $sayMetUSD = gg ("Sets.sayMetUSD"); if ($sayMetUSD) { say("Читаю прогноз погоды на 3 дня с Yandex",($sayMetUSD-2)); } // ******************************************************** // КОНЕЦ ОСНОВНОГО БЛОКА // Функция - добавления "+" к положительной температуре function getTempSign($temp) { $temp = (int)$temp; return $temp > 0 ? '+'.$temp : $temp; } // Функция - получить направления ветра в МАССИВ function getWindDirection($wind) { $wind = (string)$wind; $wind_direction = array('s'=>'↑ ю', 'n'=>'↓ с', 'w'=>'→ з', 'e'=>'← в', 'sw'=>'↗ юз', 'se'=>'↖ юв', 'nw'=>'↘ сз', 'ne'=>'↙ св'); $wind_dirtxt = array('s'=>'южный', 'n'=>'северный', 'w'=>'западный', 'e'=>'восточный', 'sw'=>'юго-западный', 'se'=>'юго-восточный', 'nw'=>'северо-западный', 'ne'=>'северо-восточный'); return array ($wind_direction[$wind], $wind_dirtxt[$wind]); }
Методы класса:
$updateTime = gg("yt_settings.updateTime"); if($updateTime > 0){ $count = gg("yt_settings.countTime"); if($count >= $updateTime){ include_once(DIR_MODULES."app_yatraffic/app_yatraffic.class.php"); $app_yatraffic=new app_yatraffic(); $app_yatraffic->get_traffic(gg("yt_settings.reg_id")); sg("yt_settings.countTime",1); } else { $count++; sg("yt_settings.countTime",$count); } }
include_once(DIR_MODULES."app_yatraffic/app_yatraffic.class.php"); $app_yatraffic=new app_yatraffic(); $app_yatraffic->get_traffic(gg("yt_settings.reg_id"));
Объекты класса:
Объекты класса:
, Россия
© 2024 - Site Built By SergeJey | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving