1-wire
|
# массив адресов датчиков, переменная для сохранения - имя папки (адрес датчика)
$arr1 = array( array('Temp_Tepl_Air.temp', '28.4C996B070000'),
array('Temp_Tepl_Ground.temp', '28.8C1C01000080'));
$col = 2; # количество датчиков
$pathf = "/mnt/1-wire/"; # путь к папке
$namepar = "temperature"; # имя параметра для считывания
for ($i = 0; $i < $col; $i++)
{
$tempcur = file_get_contents ($pathf . $arr1[$i][1] . "/" . $namepar);
$tempcur = round ($tempcur,1);
sg($arr1[$i][0],$tempcur);
}
$sr = getGlobal('ow_fact.sunrise');
$sr1 = timeConvert($sr);
$ss = getGlobal('ow_fact.sunset');
$ss1 = timeConvert($ss);
$cur_time = time();
if(($cur_time > $sr1)&&($cur_time < $ss1)) // выключать свет с рассветом
{
$cur_stat = getGlobal('Light_main_outdoor.status');
if($cur_stat!=0)
{
say('Выключить свет на крыльце',2);
callMethod('Light_main_outdoor.turnOff');
callMethod('Light_kot_kr.turnOff');
}
}
$lo = getGlobal($light_outdoor_off,1);
if(($cur_time > $ss1)&&($lo!=1)) // включать свет с закатом
{
$cur_stat = getGlobal('Light_main_outdoor.status');
if($cur_stat!=1)
{
say('Включить свет на крыльце',2);
callMethod('Light_main_outdoor.turnOn');
callMethod('Light_kot_kr.turnOn');
}
}
$hwc = getGlobal('humWC.humidity');
$vs = getGlobal('Vent_WC.status');
if(($hwc > 70)&&($vs == 0))
{
callMethod('Vent_WC.turnOn');
SetTimeOut("TurnOffVent_WC","callMethod('Vent_WC.turnOff');",10*60); // выключить вентилятор через 10 минут
}
if(($hwc < 71)&&($vs == 1))
{
callMethod('Vent_WC.turnOff');
}
|
Check_domophone
|
$host = "192.168.1.14";
exec("ping -c 4 " . $host, $output, $result);
if ($result != 0)
{
say('Нет связи с домофоном. Перезагрузка!',2);
callMethod('Tapo-5.turnOff');
SetTimeOut("turnOnDomophone","callMethod('Tapo-5.turnOn');",60);
}
|
sensor_ok
|
//callMethod('Light_tambur.turnOff');
|
Включить свет на крыльце_2
|
$sr = getGlobal('ow_fact.sunrise');
$sr1 = timeConvert($sr);
$cur_time = time();
setGlobal($light_outdoor_off,0);
if($cur_time < $sr1) // включать свет только если рассвет позже 6:00
{
say('Включить свет на крыльце',2);
callMethod('Light_main_outdoor.turnOn');
callMethod('Light_kot_kr.turnOn');
}
|
Выключить свет на крыльце_2
|
say('Выключить свет на крыльце',2);
callMethod('Light_main_outdoor.turnOff');
callMethod('Light_kot_kr.turnOff');
setGlobal($light_outdoor_off,1);
|
Запустить музыку с Yandex.music
|
include_once (DIR_MODULES . 'app_player/app_player.class.php');
$player = new app_player();
$player->play_terminal = 'main'; // Имя терминала
$player->command = ($safe_play ? 'safe_play' : 'play'); // Команда
$player->param = 'http://192.168.1.35/modules/yamusic/m3u8/p1_1006_366994104.m3u'; // Параметр
$player->ajax = TRUE;
$player->intCall = TRUE;
$player->usual($out);
|
Полив газона
|
$temp_today = getGlobal('ow_forecast_2.temp_day');
$tont = 20;
if($temp_today > 20)
{
$tont = 30;
}
if($temp_today > 25)
{
$tont = 40;
}
if($temp_today > 30)
{
$tont = 50;
}
$cur_condition = getGlobal('ow_forecast_2.rain');
$for_condition = getGlobal('ow_forecast_2_1.rain');
if($cur_condition > 10 or $for_condition > 5) # был сегодня или будет завтра идти дождь
{
say('Дождь. Полива газона отменен',2);
}else
{
callMethod('Poliv_Gazon.turnOn');
ClearTimeOut("TurnOffGazon");
SetTimeOut("TurnOffGazon","callMethod('Poliv_Gazon.turnOff');",$tont*60);
# отложенный запуск полива второго газона
ClearTimeOut("TurnOnGazon2");
SetTimeOut("TurnOnGazon2","callMethod('Poliv_Left.turnOn');",$tont*60);
ClearTimeOut("TurnOffGazon2");
SetTimeOut("TurnOffGazon2","callMethod('Poliv_Left.turnOff');",$tont*60*2);
say('Запуск полива газона',2);
}
|
Полив газона у сада
|
$temp_today = getGlobal('ow_forecast_2.temp_day');
$tont = 20;
if($temp_today > 20)
{
$tont = 30;
}
if($temp_today > 25)
{
$tont = 40;
}
if($temp_today > 30)
{
$tont = 50;
}
$cur_condition = getGlobal('ow_forecast_2.rain');
$for_condition = getGlobal('ow_forecast_2_1.rain');
if($cur_condition > 10 or $for_condition > 5) # был сегодня или будет завтра идти дождь
{
say('Дождь. Полива газона у сада отменен',2);
}else
{
callMethod('Poliv_Barrel2.turnOn');
ClearTimeOut("TurnOffGazon");
SetTimeOut("TurnOffGazon","callMethod('Poliv_Barrel2.turnOff');",$tont*60);
say('Запуск полива газона у сада',2);
}
|
Полив грядок
|
$cur_condition = getGlobal('ow_forecast_2.rain');
$for_condition = getGlobal('ow_forecast_2_1.rain');
if($cur_condition > 10 or $for_condition > 5) # был сегодня или будет завтра идти дождь
{
say('Дождь. Полив грядок отменен',2);
}else
{
callMethod('Poliv_Barrel.turnOn');
callMethod('Poliv_Barrel2.turnOn');
ClearTimeOut("TurnOffBarrel");
ClearTimeOut("TurnOffBarrel2");
SetTimeOut("TurnOffBarrel2","callMethod('Poliv_Barrel2.turnOff');",900); # выключить клапан воды из скважины
SetTimeOut("TurnOffBarrel","callMethod('Poliv_Barrel.turnOff');",900); # выключить клапан полива
say('Запуск полива грядок',2);
}
|
Полив клубники
|
$cur_condition = getGlobal('ow_forecast_2.rain');
$for_condition = getGlobal('ow_forecast_2_1.rain');
if($cur_condition > 10 or $for_condition > 5) # был сегодня или будет завтра идти дождь
{
say('Дождь. Полив клубники отменен',2);
}else
{
callMethod('Poliv_Klub.turnOn');
ClearTimeOut("TurnOffKlub");
SetTimeOut("TurnOffKlub","callMethod('Poliv_Klub.turnOff');",7200); # выключить клапан через 2 часа
say('Запуск полива клубники',2);
}
|
Полив малины
|
$cur_condition = getGlobal('ow_forecast_2.rain');
$for_condition = getGlobal('ow_forecast_2_1.rain');
if($cur_condition > 10 or $for_condition > 5) # был сегодня или будет завтра идти дождь
{
say('Дождь. Полив малины отменен',2);
}else
{
callMethod('Vent_Tepl.turnOn');
ClearTimeOut("TurnOffMal");
SetTimeOut("TurnOffMal","callMethod('Vent_Tepl.turnOff');",3600); # выключить клапан через 1 час
say('Запуск полива малины',2);
}
|
Полив теплицы
|
callMethod('Poliv_Tepl.turnOn');
ClearTimeOut("TurnOffTepl");
SetTimeOut("TurnOffTepl","callMethod('Poliv_Tepl.turnOff');",2400); # полить 40 минут выключить клапан теплицы
say('Запуск полива теплицы',2);
|
Проверить асики
|
include_once(DIR_MODULES . 'sms_ru/sms_ru.class.php');
$host = "192.168.1.100";
exec("ping -c 4 " . $host, $output, $result);
if ($result == 0) // если есть связь с роутером на кухне значит сеть есть и асики должны быть на связи
{
$host = "192.168.1.34";
exec("ping -c 4 " . $host, $output, $result);
if ($result != 0) // асика нет на связи - что то случилось
{
$cur_stat = getGlobal('WhatsminerM30.Status');
if($cur_stat == 1)
{
say('Нет связи с асиком!',2);
setGlobal('WhatsminerM30.Status',0);
$notify = new sms_ru();
$notify->sendNotifyAll("Нет связи с асиком!");
}
}else
{
$cur_stat = getGlobal('WhatsminerM30.Status');
if($cur_stat == 0)
{
say('Связь с асиком восстановлена!',2);
setGlobal('WhatsminerM30.Status',1);
}
}
}
|
Проверить связь с MegaD
|
include_once(DIR_MODULES . 'sms_ru/sms_ru.class.php');
$host = "192.168.1.70";
exec("ping -c 4 " . $host, $output, $result);
if ($result != 0) // если есть связь с роутером на кухне значит сеть есть и асики должны быть на связи
{
$cur_stat = getGlobal('MegaD.Status');
if($cur_stat == 1)
{
say('Нет связи с MegaD! (проверить питание в котельной)',2);
setGlobal('MegaD.Status',0);
$notify = new sms_ru();
$notify->sendNotifyAll("Нет связи с MegaD! (проверить питание в котельной)");
}
}else
{
$cur_stat = getGlobal('MegaD.Status');
if($cur_stat == 0)
{
say('Связь с MegaD восстановлена! (проверить питание в котельной)',2);
setGlobal('MegaD.Status',1);
}
}
|
KODI_Pause
|
$title = "Majordomo";
$host = '192.168.1.8:8080';
$timeout = 3000;
$login = "kodi";
$password = "1";
$url = 'http://'.$host;
$out=array();
$out["jsonrpc"] = "2.0";
$out["method"] = "Player.PlayPause";
$out["params"] = array();
$out["params"]["playerid"] = 0;
// $out["params"]["message"] = $message;
// $out["params"]["displaytime"] = (int)$timeout;
$out["id"] = 1;
$json = json_encode($out);
$req = $url."/jsonrpc";
//registerError('kodi_notify', $req);
$curl = curl_init($req);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
if ($login!="" && $password!="")
{
curl_setopt($curl, CURLOPT_USERPWD, "$login:$password");
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
$contents = curl_exec($curl);
/* curl_close($curl);
if ($contents!="")
{
$obj = json_decode($contents);
if ($obj->{'result'} != "OK")
registerError('kodi_notify',$contents. 'URL='. $req);
} */
|
KODI_Pause_copy
|
$title = "Majordomo";
$host = '192.168.1.8:8080';
$timeout = 3000;
$login = "kodi";
$password = "1";
$url = 'http://'.$host;
$out = array("jsonrpc" => "2.0",
"id" => 1,
"method" => "Player.PlayPause",
"params" => array("playerid" => 0)
);
$json = json_encode($out);
$req = $url."/jsonrpc";
$curl = curl_init($req);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
if ($login!="" && $password!="")
{
curl_setopt($curl, CURLOPT_USERPWD, "$login:$password");
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
$contents = curl_exec($curl);
|
KODI_Play
|
$title = "Majordomo";
$host = '192.168.1.8:8080';
$timeout = 3000;
$login = "kodi";
$password = "1";
$url = 'http://'.$host;
$out = array("jsonrpc" => "2.0",
"id" => 1,
"method" => "Player.Open",
// "params" => array("item" => array("file" => "smb://192.168.1.35/Music/tadu.mp3")
"params" => array("item" => array("playlistid" => 0),
"options" => array("repeat" => "All",
"shuffled" => true)
)
);
$out["id"] = 1;
$json = json_encode($out);
$req = $url."/jsonrpc";
$curl = curl_init($req);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3);
curl_setopt($curl, CURLOPT_POSTFIELDS, $json);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Content-Length: ' . strlen($json))
);
if ($login!="" && $password!="")
{
curl_setopt($curl, CURLOPT_USERPWD, "$login:$password");
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
}
$contents = curl_exec($curl);
echo $contents;
/* curl_close($curl);
if ($contents!="")
{
$obj = json_decode($contents);
if ($obj->{'result'} != "OK")
registerError('kodi_notify',$contents. 'URL='. $req);
} */
|
test
|
$uid = rand(1, 9999999);
$uid = 0;
$method = 'Player.PlayPause';
$username = 'kodi';
$password = '1';
$json = array(
'jsonrpc' => '2.0',
'method' => $method,
'username' => $username,
'password' => $password,
'id' => $uid
);
$url='http://192.168.1.8:8080';
$request = json_encode($json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, $url."/jsonrpc");
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$responseRaw = curl_exec($ch);
echo $responseRaw;
// return json_decode($responseRaw);
|
timeNow
|
|