Свойства класса:
Методы класса:
$balance = floatval($this->getProperty("balance")); if ($balance < 10) { registerEvent(sprintf('Low balance of %s', $this->object_title), sprintf('%s.balance = %s', $this->object_title, $balance), 60); }
Объекты класса:
Свойства класса:
Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
say("Отключено питание");
$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('Задача принята'); return; } global $voicemode; $voicemode='on'; say('Сейчас '.timeNow()); } 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('Задача принята'); return; } global $voicemode; $voicemode='on'; say($m[1]); } else { say('Неизвестная команда...'); }
Свойства класса:
Объекты класса:
Свойства класса:
Методы класса:
$rawValue = $params['NEW_VALUE']; //DebMes('Statuses inside splitStringToBool rawSensorStatus = '.$rawValue); $statuses = explode(',', str_replace('"', "", $rawValue)); //DebMes('Statuses inside splitStringToBool '.$statuses[0].$statuses[1].$statuses[2].$statuses[3]); $this->setProperty('sensor1', intval($statuses[0])); $this->setProperty('sensor2', intval($statuses[1])); $this->setProperty('sensor3', intval($statuses[2])); $this->setProperty('sensor4', intval($statuses[3]));
$rawValue = $params['NEW_VALUE']; $temp = str_replace(array("+", '"'), "", $rawValue); // DebMes('convertTempStringToFloat $temp'); $this->setProperty('temp', floatval($temp));
Объекты класса:
// Invert 0 -> 1 and 1 -> 0 setGlobal('CorridorPlace.isOccupied', -1 * ($params['NEW_VALUE'] - 1));
setGlobal('BedroomPlace.isOccupied', $params['NEW_VALUE']);
Свойства класса:
Методы класса:
// !!! If you change it, then update AutoSwitchOffLight !!! $params['output'] = $this->getProperty('outputPort'); $params['value'] = 0; $log = getLogger($this); $log->trace(sprintf('switchOff method: set output = %d to %d', $params['output'], $params['value'])); // Call megadevice class callMethod($this->getProperty('outputDevice').'.setOutput', $params); $this->setProperty('enabled', 0);
$this->callMethod('toggleSwitch');
// Read current state of output $params['output'] = $this->getProperty('outputPort'); $params['propertyName'] = $this->object_title.'.enabled'; $log = getLogger($this); $log->trace(sprintf('getOutputPortState method: get state of output = %d', $params['output'])); callMethod($this->getProperty('outputDevice').'.getOutput', $params);
// !!! If you change it, then update AutoSwitchOffLight !!! $params['output'] = $this->getProperty('outputPort'); $params['value'] = 1; $log = getLogger($this); $log->trace(sprintf('switchOn method: set output = %d to %d', $params['output'], $params['value'])); // Call megadevice class callMethod($this->getProperty('outputDevice').'.setOutput', $params); $this->setProperty('enabled', 1);
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) $this->callMethod('switchOff'); else $this->callMethod('switchOn');
Объекты класса:
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) setGlobal('LivingroomPlace.isOccupied', 1);
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) setGlobal('CorridorPlace.isOccupied', 1);
callMethod('Livingroom3Light.switchOn'); callMethod('Livingroom4Light.switchOn'); callMethod('Livingroom5Light.switchOn');
callMethod('Livingroom3Light.switchOn'); callMethod('Livingroom4Light.switchOn'); callMethod('Livingroom5Light.switchOn');
callMethod('Kitchen2Light.switchOn');
// Looks like i found bug. I cannot use $params inside this method $params1['output'] = 13; $params1['value'] = 1; $log = getLogger($this); $log->trace(sprintf('switchOn method: set output = 12 and 13 to %d', $params1['value'])); // Call megadevice class callMethod('MegaD3.setOutput', $params1); $params1['output'] = 12; $params1['value'] = 1; callMethod('MegaD3.setOutput', $params1); $this->setProperty('enabled', 1); if (timeBetween('08:00', '23:30')) { SetTimeOut('Switch on bathroom fan', 'callMethod("BathroomFan.switchOn");', 20 * 60); } clearTimeOut('Switch off heated towel rails'); // Enable only in the evening //if (!timeBetween('08:00', '18:30')) { callMethod('HeatedTowelRailsLight.switchOn'); //}
// Looks like i found bug. I cannot use $params inside this method $params1['output'] = 13; $params1['value'] = 0; $log = getLogger($this); $log->trace(sprintf('switchOff method: set output = 12 and 13 to %d', $params1['value'])); // Call megadevice class callMethod('MegaD3.setOutput', $params1); $params1['output'] = 12; $params1['value'] = 0; callMethod('MegaD3.setOutput', $params1); $this->setProperty('enabled', 0); clearTimeOut('Switch on bathroom fan'); SetTimeOut('Switch off bathroom fan', 'callMethod("BathroomFan.switchOff");', 1 * 60); SetTimeOut('Switch off heated towel rails', 'callMethod("HeatedTowelRailsLight.switchOff");', 5 * 60);
// TODO : Refactor this obsolete code if ($this->getProperty('stopped') == 1) { // DebMes } else { $params1['output'] = $this->getProperty('outputPort'); $params1['value'] = 1; callMethod($this->getProperty('outputDevice').'.setOutput', $params1); $this->callMethod('getOutputPortState'); }
callMethod('Bedroom2Light.switchOn');
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) setGlobal('KitchenPlace.isOccupied', 1);
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) setGlobal('BathroomPlace.isOccupied', 1);
setGlobal('WaterMeter.value', intval(getGlobal('WaterMeter.value') + 1));
registerEvent('Water leakage is detected', 'Обнаружена протечка воды!', 14); //setGlobal('KitchenPlace.isOccupied', 1); //cannot use it because it doesn't work after 23:00 callMethod('KitchenLight.switchOn'); setGlobal('BathroomPlace.isOccupied', 1); say('Обнаружена протечка воды!'); sendMail('noreply@majordomo.com', 'dimitrystd@gmail.com', '[Majordomo][Alert] Water leakage is detected', 'Обнаружена протечка воды!');
setGlobal('StoreroomPlace.isOccupied', 1);
setGlobal('BedroomPlace.isOccupied', 1);
$this->callMethod('getOutputPortState'); if ($this->getProperty('enabled') == 1) setGlobal('CorridorPlace.isOccupied', 1);
setGlobal('BedroomPlace.isOccupied', 1);
setGlobal('BathroomPlace.isOccupied', 1);
Свойства класса:
Методы класса:
if ($this->getProperty('autoSwitchOffEnabled') == 1) { $timeout = intval($this->getProperty('autoSwitchOffTimeOut')); if ($timeout == 0) $timeout = 180; SetTimeOut("Auto switch off {$this->object_title} after $timeout", "callMethod('{$this->object_title}.switchOff');", $timeout); }
$params['output'] = $this->getProperty('outputPort'); $params['value'] = 1; $log = getLogger($this); $log->trace(sprintf('switchOn method: set output = %d to %d', $params['output'], $params['value'])); // Call megadevice class callMethod($this->getProperty('outputDevice').'.setOutput', $params); $this->setProperty('enabled', 1); $this->callMethod('resetAutoSwitchOffTimer');
Объекты класса:
callMethod('Corridor2Light.switchOn');
Свойства класса:
Методы класса:
// Expects 'output' and 'value' in $params $log = getLogger($this); $cmdUrl = sprintf ("http://%s/%s/?pt=%d&cmd=get", $this->getProperty('IpAddress'), $this->getProperty('Password'), intval($params['output'])); $state = trim(file_get_contents($cmdUrl)); $log->trace(sprintf('getOutput method: %s returned %s', $cmdUrl, $state)); $value = stripos($state, 'ON') === 0 ? 1 : 0; setGlobal($params['propertyName'], $value); $log->trace(sprintf('getOutput method: set %s = %d', $params['propertyName'], $value));
// Expects 'output' and 'value' in $params $cmdUrl = sprintf('http://%s/%s/?cmd=%d:%d', $this->getProperty('IpAddress'), $this->getProperty('Password'), intval($params['output']), intval($params['value'])); $log = getLogger($this); $log->trace('setOutput method: '.$cmdUrl); getURL($cmdUrl, 0);
// Try to resolve MegaD object by IP $ip = $_SERVER['REMOTE_ADDR']; $objects=getObjectsByClass("Megadevice"); foreach($objects as $obj) { if (getGlobal($obj['TITLE'].".ipAddress") == $ip) $megaD = $obj; } if(!$megaD) { DebMes('Cannot find Megadevice with ip = '.$ip); exit; } // Try to find Light objects (by device and input port) $inputDevice = $megaD['TITLE']; $inputPort = $params['pt']; $objects=getObjectsByClass("Light"); foreach($objects as $obj) { if (getGlobal($obj['TITLE'].".inputDevice") == $inputDevice && getGlobal($obj['TITLE'].".inputPort") == $inputPort) $light = $obj; } if(!$light) { DebMes(sprintf('Cannot find Light with inputDevice = %s and inputPort = %d', $inputDevice, $inputPort)); exit; } callMethod($light['TITLE'].'.switchPressed');
Объекты класса:
Свойства класса:
Методы класса:
$isOccupied = intval($params['NEW_VALUE']); if ($isOccupied == 1) { $interval = time() - $this->getProperty('occupiedTime'); $freezeTimeout = intval($this->getProperty('freezeTimeout')); if ($freezeTimeout == 0) $freezeTimeout = 30; if ($interval > $freezeTimeout) { $this->callMethod('onOccupie'); $releaseTimeout= intval($this->getProperty('releaseTimeout')); if ($releaseTimeout== 0) $releaseTimeout = 60; SetTimeOut(sprintf('Place %s is occupied', $this->object_title), 'callMethod("'.$this->object_title.'.onRelease");', $releaseTimeout); $log = getLogger($this); $log->trace(sprintf('Place %s is occupied, and will be automatically released in %d seconds', $this->object_title, $releaseTimeout)); $this->setProperty('occupiedTime', time()); } }
Объекты класса:
callMethod('Bedroom1Light.switchOff'); callMethod('Bedroom2Light.switchOff');
if (timeBetween('17:00', '23:00')) { callMethod('Corridor1Light.switchOn'); } if (!timeBetween('00:00', '08:00')) { callMethod('Corridor2Light.switchOn'); } // Reset timer if light was switch on by hardware button callMethod('Corridor1Light.resetAutoSwitchOffTimer');
callMethod('Kitchen2Light.switchOff'); callMethod('Kitchen1Light.switchOff');
if (timeBetween('8:00', '23:00')) { callMethod('Kitchen2Light.switchOn'); callMethod('Kitchen1Light.switchOn'); }
if (timeBetween('08:00', '23:00')) { callMethod('Livingroom3Light.switchOn'); callMethod('Livingroom4Light.switchOn'); callMethod('Livingroom5Light.switchOn'); }
callMethod('Livingroom3Light.switchOff'); callMethod('Livingroom4Light.switchOff'); callMethod('Livingroom5Light.switchOff');
callMethod('BathroomLight.switchOff');
callMethod('BathroomLight.switchOn');
callMethod('StoreroomLight.switchOn');
Свойства класса:
Методы класса:
$params['key'] = 'POWEROFF'; $this->callMethod('sendCommand', $params);
$log = getLogger($this); $key = $params['key']; $log->debug(sprintf('Sending key = %s to %s', $key, $this->object_title)); $tvip = $this->getProperty('ipAddress'); //IP Address of TV $myip = "192.168.0.30"; //Doesn't seem to be really used $mymac = "00-0c-29-3e-b1-4f"; //Used for the access control/validation, but not after that AFAIK $appstring = "iphone..iapp.samsung"; //What the iPhone app reports $tvappstring = "iphone.LE46C650.iapp.samsung"; //Might need changing to match your TV type $remotename = "Perl Samsung Remote"; //What gets reported when it asks for permission/also shows in General->Wireless Remote Control menu //echo "Content-type: text/html\n\n"; $log->debug('Opening socket'); $sock = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp')); $result = socket_connect($sock, $tvip, '55000'); if ($result === false) $log->error('Could not open socket for: '.$tvip); //Normal remote keys //KEY_0 //KEY_1 //KEY_2 //KEY_3 //KEY_4 //KEY_5 //KEY_6 //KEY_7 //KEY_8 //KEY_9 //KEY_UP //KEY_DOWN //KEY_LEFT //KEY_RIGHT //KEY_MENU //KEY_PRECH //KEY_GUIDE //KEY_INFO //KEY_RETURN //KEY_CH_LIST //KEY_EXIT //KEY_ENTER //KEY_SOURCE //KEY_AD //KEY_PLAY //KEY_PAUSE //KEY_MUTE //KEY_PICTURE_SIZE //KEY_VOLUP //KEY_VOLDOWN //KEY_TOOLS //KEY_POWEROFF //KEY_CHUP //KEY_CHDOWN //KEY_CONTENTS //KEY_W_LINK //Media P //KEY_RSS //Internet //KEY_MTS //Dual //KEY_CAPTION //Subt //KEY_REWIND //KEY_FF //KEY_REC //KEY_STOP //Bonus buttons not on the normal remote: //KEY_TV //Don't work/wrong codes: //KEY_CONTENT //KEY_INTERNET //KEY_PC //KEY_HDMI1 //KEY_OFF //KEY_POWER //KEY_STANDBY //KEY_DUAL //KEY_SUBT //KEY_CHANUP //KEY_CHAN_UP //KEY_PROGUP //KEY_PROG_UP $ipencoded = base64_encode($myip); $macencoded = base64_encode($mymac); $messagepart1 = chr(0x64) . chr(0x00) . chr(strlen($ipencoded)) . chr(0x00) . $ipencoded . chr(strlen($macencoded)) . chr(0x00) . $macencoded . chr(strlen(base64_encode($remotename))) . chr(0x00) . base64_encode($remotename); $part1 = chr(0x00) . chr(strlen($appstring)) . chr(0x00) . $appstring . chr(strlen($messagepart1)) . chr(0x00) . $messagepart1; socket_write($sock, $part1, strlen($part1)); echo $part1; echo "\n"; $messagepart2 = chr(0xc8) . chr(0x00); $part2 = chr(0x00) . chr(strlen($appstring)) . chr(0x00) . $appstring . chr(strlen($messagepart2)) . chr(0x00) . $messagepart2; socket_write($sock, $part2, strlen($part2)); echo $part2; echo "\n"; //Preceding sections all first time only if (isset($key)) { //Send remote key $key = "KEY_" . $key; $messagepart3 = chr(0x00) . chr(0x00) . chr(0x00) . chr(strlen(base64_encode($key))) . chr(0x00) . base64_encode($key); $part3 = chr(0x00) . chr(strlen($tvappstring)) . chr(0x00) . $tvappstring . chr(strlen($messagepart3)) . chr(0x00) . $messagepart3; $log->debug('Writing command to socket'); socket_write($sock, $part3, strlen($part3)); echo $part3; echo "\n"; } $log->debug('Close socket'); socket_close($sock);
$params['key'] = 'CHUP'; $this->callMethod('sendCommand', $params);
$params['key'] = 'CHDOWN'; $this->callMethod('sendCommand', $params);
$this->callMethod('channelUp'); SetTimeOut("Switch channel for {$this->object_title}", "callMethod('{$this->object_title}.startChannelScan');", $this->getProperty('channelScanDelay'));
ClearTimeOut("Switch channel for {$this->object_title}");
Объекты класса:
if ($params['NEW_VALUE'] == 1) setGlobal('LivingroomPlace.isOccupied', 1);
Методы класса:
Объекты класса:
global $voicemode; $voicemode='off'; processCommand($params['message']);
echo "status received: ".$params['status'];
Свойства класса:
Методы класса:
Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
$hour = (int)date('G',time()); if (($hour % 11) === 0) { runScript('Check Fregat balance'); }
$h=(int)date('G',time()); $m=(int)date('i',time()); if (isWeekDay()) { } if (($h >= 10 && $h < 23)) { if ($m % 20 == 0) { // say(timeNow()); // runScript('Switch on air fan in storeroom'); } } // run now and every 20sec // runScript("Get data from electric meter"); // SetTimeOut('Get data from electric meter','runScript("Get data from electric meter");', 20); // SetTimeOut('Get data from electric meter','runScript("Get data from electric meter");', 40);
Свойства класса:
Методы класса:
setGlobal('Unittest2.Property3', 'Value from method Unittest2.UpdateProperty4');
$rawValue = $params['NEW_VALUE']; $this->setProperty('Property2', 'value from UpdateProperty2 - 1'); // try to update property one more time $this->setProperty('Property2', 'value from UpdateProperty2 - 2');
setGlobal('Unittest2.Property4', 'Value from method Unittest2.UpdateProperty3');
$rawValue = $params['NEW_VALUE']; $this->setProperty('Property1', 'value from UpdateProperty1');
Объекты класса:
Методы класса:
Объекты класса:
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']); } }
Свойства класса:
Объекты класса:
Свойства класса:
Объекты класса:
, Украина
© 2025 - Site Built By SergeJey | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving