correction de bugs
This commit is contained in:
parent
2b4fc54071
commit
6a333acc9f
@ -50,7 +50,7 @@ class db extends mysqli
|
|||||||
{
|
{
|
||||||
if (!array_key_exists("lastValueLogged", $device->properties[$property]))
|
if (!array_key_exists("lastValueLogged", $device->properties[$property]))
|
||||||
{
|
{
|
||||||
$oldvalue = -1;
|
$oldValue = -1;
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$oldValue = $device->properties[$property]["lastValueLogged"];
|
$oldValue = $device->properties[$property]["lastValueLogged"];
|
||||||
|
@ -63,6 +63,8 @@ class ranges
|
|||||||
|
|
||||||
class event
|
class event
|
||||||
{
|
{
|
||||||
|
public $id;
|
||||||
|
public $key;
|
||||||
public $ieeeAddress;
|
public $ieeeAddress;
|
||||||
public $topic;
|
public $topic;
|
||||||
public $param;
|
public $param;
|
||||||
|
84
events.php
84
events.php
@ -12,16 +12,20 @@ function checkEvents()
|
|||||||
$oldLevel = $logLevel;
|
$oldLevel = $logLevel;
|
||||||
//$logLevel = DEBUG;
|
//$logLevel = DEBUG;
|
||||||
$exception = false;
|
$exception = false;
|
||||||
/*if ($events === null)
|
if ($events === null)
|
||||||
{
|
{
|
||||||
$events = array();
|
$events = array();
|
||||||
}*/
|
}
|
||||||
|
//var_dump($events);
|
||||||
$now = now();
|
$now = now();
|
||||||
|
if (!empty($events))
|
||||||
|
{
|
||||||
foreach ($events as $key => &$event)
|
foreach ($events as $key => &$event)
|
||||||
{
|
{
|
||||||
|
|
||||||
if($event->dateTimeEvent < $now)
|
if($event->dateTimeEvent < $now)
|
||||||
{
|
{
|
||||||
|
logger(DEBUG, _("Executing event") . $key, __FILE__ . ":" . __LINE__);
|
||||||
if (is_callable($event->function))
|
if (is_callable($event->function))
|
||||||
{
|
{
|
||||||
logger(DEBUG, _("executing function") . $event->function[1], __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("executing function") . $event->function[1], __FILE__ . ":" . __LINE__);
|
||||||
@ -37,15 +41,17 @@ function checkEvents()
|
|||||||
}
|
}
|
||||||
|
|
||||||
$event->published = $now;
|
$event->published = $now;
|
||||||
}
|
|
||||||
if (!empty($event->recurrence))
|
if (!empty($event->recurrence))
|
||||||
{
|
{
|
||||||
nextOccurence($event, $key, $now);
|
nextOccurence($event, $key);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
|
logger(DEBUG, _("Unsetting event") . $key, __FILE__ . ":" . __LINE__);
|
||||||
unset($events[$key]);
|
unset($events[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextIntervalDate(&$event)
|
function nextIntervalDate(&$event)
|
||||||
@ -125,7 +131,7 @@ function nextDate(&$event)
|
|||||||
$event->dateTimeEvent->setTime(intval($hour), intval($minutes), intval($seconds));
|
$event->dateTimeEvent->setTime(intval($hour), intval($minutes), intval($seconds));
|
||||||
}
|
}
|
||||||
|
|
||||||
function exceptionsTest(&$event, $now)
|
function exceptionsTest(&$event, $date)
|
||||||
{
|
{
|
||||||
$exception = false;
|
$exception = false;
|
||||||
|
|
||||||
@ -146,10 +152,10 @@ function exceptionsTest(&$event, $now)
|
|||||||
return $exception;
|
return $exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextOccurence(&$event, $eventKey, $now)
|
function nextOccurence(&$event, $eventKey)
|
||||||
{
|
{
|
||||||
$n = 0;
|
$n = 0;
|
||||||
logger(DEBUG, _("Calculating next occurence"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Calculating next occurence of event #") . $event->key, __FILE__ . ":" . __LINE__);
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if ($event->isInterval === true)
|
if ($event->isInterval === true)
|
||||||
@ -164,7 +170,7 @@ function nextOccurence(&$event, $eventKey, $now)
|
|||||||
logger(ERROR, _("infinite loop"), __FILE__ . ":" . __LINE__);
|
logger(ERROR, _("infinite loop"), __FILE__ . ":" . __LINE__);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}while (exceptionsTest($event, $now) === true); // loop until the date is not comprise in exceptions dates
|
}while (exceptionsTest($event, $event->dateTimeEvent) === true); // loop until the date is not comprise in exceptions dates
|
||||||
}
|
}
|
||||||
|
|
||||||
// datetime format : "yyyy-mm-dd hh:mm:ss"
|
// datetime format : "yyyy-mm-dd hh:mm:ss"
|
||||||
@ -173,7 +179,8 @@ function setOneshotEvent(device &$deviceObject, string $datetime, $property, $va
|
|||||||
{
|
{
|
||||||
global $events;
|
global $events;
|
||||||
$events[] = new event;
|
$events[] = new event;
|
||||||
$key = key($events);
|
$key = array_key_last($events);
|
||||||
|
$events[$key]->key = $key;
|
||||||
$events[$key]->dateTimeEvent = new dateTime($datetime);
|
$events[$key]->dateTimeEvent = new dateTime($datetime);
|
||||||
$events[$key]->ieeeAddress = $deviceObject->ieeeAddress;
|
$events[$key]->ieeeAddress = $deviceObject->ieeeAddress;
|
||||||
$events[$key]->topic = $deviceObject->topic;
|
$events[$key]->topic = $deviceObject->topic;
|
||||||
@ -186,30 +193,41 @@ function setOneshotEvent(device &$deviceObject, string $datetime, $property, $va
|
|||||||
|
|
||||||
// startDatetime and stopDatetime format : "yyyy-mm-dd hh:mm:ss"
|
// startDatetime and stopDatetime format : "yyyy-mm-dd hh:mm:ss"
|
||||||
|
|
||||||
function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bool $isInterval, string $startDatetime, string $stopDatetime, int $hours, int $minutes, int $seconds, int $days, int $weeks, int $months, int $years, int $method = null)
|
function setRecurrentEvent(string $id, $function, string $ieeeAddress, string $property, $value, int $method=0 , string $startDatetime, string $stopDatetime, bool $isInterval, int $hours=0, int $minutes=0, int $seconds=0, int $days=0, int $weeks=0, int $months=0, int $years=0)
|
||||||
{
|
{
|
||||||
global $events, $indexDevices;
|
global $events, $indexDevices;
|
||||||
|
$string ="";
|
||||||
|
$stringTemp = "";
|
||||||
|
|
||||||
logger(INFO, _("Setting recurrent event"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("Setting recurrent event"), __FILE__ . ":" . __LINE__);
|
||||||
|
|
||||||
$string = "P";
|
if (!empty($years)) $stringTemp .= $years . "Y";
|
||||||
if (!empty($years)) $string .= $years . "Y";
|
if (!empty($months)) $stringTemp .= $months . "M";
|
||||||
if (!empty($months)) $string .= $months . "M";
|
if (!empty($week)) $stringTemp .= $week . "W";
|
||||||
if (!empty($week)) $string .= $week . "W";
|
if (!empty($days)) $stringTemp .= $days . "D";
|
||||||
if (!empty($days)) $string .= $days . "D";
|
if (!empty($stringTemp)) $string = "P" . $stringTemp;
|
||||||
$string .= "T";
|
$stringTemp = "";
|
||||||
if (!empty($hours)) $string .= $hours . "H";
|
if (!empty($hours)) $stringTemp .= $hours . "H";
|
||||||
if (!empty($minutes)) $string .= $minutes . "M";
|
if (!empty($minutes)) $stringTemp .= $minutes . "M";
|
||||||
if (!empty($seconds)) $string .= $seconds . "S";
|
if (!empty($seconds)) $stringTemp .= $seconds . "S";
|
||||||
|
if (!empty($stringTemp)) $string .= "T" . $stringTemp;
|
||||||
|
|
||||||
logger(DEBUG, _("reccurrent event string : ") . $string, __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("reccurrent event string : ") . $string, __FILE__ . ":" . __LINE__);
|
||||||
|
|
||||||
|
$key = searchEventByID($id);
|
||||||
|
if($key !== false)
|
||||||
|
{
|
||||||
|
deleteEvent($key);
|
||||||
|
}
|
||||||
$event = new event;
|
$event = new event;
|
||||||
|
|
||||||
|
$event->id = $id;
|
||||||
// pb in recurrent event in case of date and not interval
|
// pb in recurrent event in case of date and not interval
|
||||||
if ($isInterval === true)
|
if ($isInterval === true)
|
||||||
{
|
{
|
||||||
if (($event->dateTimeEvent->add($event->recurrence)) === false)
|
if (($event->dateTimeEvent->add($event->recurrence)) === false)
|
||||||
{
|
{
|
||||||
logger(ERROR, _("Error in event recurrence. event: ") . $key, __FILE__ . ":" . __LINE__);
|
logger(ERROR, _("Error in event recurrence. event: ") . $id , __FILE__ . ":" . __LINE__);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
$event->recurrence = new DateInterval($string);
|
$event->recurrence = new DateInterval($string);
|
||||||
@ -226,6 +244,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
$event->startDatetime = now();
|
$event->startDatetime = now();
|
||||||
|
logger(DEBUG, _("Datetime is ") . $event->startDatetime->format("Y-m-d H:i:s"), __FILE__ . ":" . __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($stopDatetime))
|
if (!empty($stopDatetime))
|
||||||
@ -234,6 +253,7 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo
|
|||||||
}
|
}
|
||||||
|
|
||||||
$event->dateTimeEvent = $event->startDatetime;
|
$event->dateTimeEvent = $event->startDatetime;
|
||||||
|
|
||||||
if (!empty($ieeeAddress))
|
if (!empty($ieeeAddress))
|
||||||
{
|
{
|
||||||
$event->ieee_address = $ieeeAddress;
|
$event->ieee_address = $ieeeAddress;
|
||||||
@ -245,10 +265,14 @@ function setRecurrentEvent($function, $ieeeAddress, string $property, $value, bo
|
|||||||
|
|
||||||
if ($method !== null) $event->method = $method;
|
if ($method !== null) $event->method = $method;
|
||||||
$events[] = $event;
|
$events[] = $event;
|
||||||
return false;
|
$r = key($events);
|
||||||
|
$events[$r]->key = $r;
|
||||||
|
$events[$r]->dateTimeEvent = nextOccurence($events[$r], $r);
|
||||||
|
|
||||||
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setDelay(device &$deviceObject, float $delay, string $unit, string $property, $value, $function, bool $replace=false, int $method = null)
|
function setDelay(device &$deviceObject, float $delay, string $unit, string $property, $value, $function, bool $replace=false, int $method=null)
|
||||||
{
|
{
|
||||||
global $events, $logLevel;
|
global $events, $logLevel;
|
||||||
$oldLevel = $logLevel;
|
$oldLevel = $logLevel;
|
||||||
@ -336,6 +360,20 @@ function searchEvent(device $deviceObject, string $property, $value, $function=n
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function searchEventByID($id)
|
||||||
|
{
|
||||||
|
global $events;
|
||||||
|
logger(DEBUG, sprintf(_("searching event by ID %s"), $id), __FILE__ . ":" . __LINE__);
|
||||||
|
foreach($events as $key => $event)
|
||||||
|
{
|
||||||
|
if ($event->id == $id)
|
||||||
|
{
|
||||||
|
return $key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// warning delete event does not manage method of the device (IDLE, )
|
// warning delete event does not manage method of the device (IDLE, )
|
||||||
function deleteEvent(int $eventKey)
|
function deleteEvent(int $eventKey)
|
||||||
{
|
{
|
||||||
|
@ -29,16 +29,16 @@ class alerte_intrusion extends hook
|
|||||||
switch($property)
|
switch($property)
|
||||||
{
|
{
|
||||||
case "contact":
|
case "contact":
|
||||||
if ($value == false)
|
if (isPresent() === false)
|
||||||
|
{
|
||||||
|
if ($value == false and isPresent() === false)
|
||||||
{
|
{
|
||||||
logger(ALERT, sprintf(_("%s vient de s'ouvrir alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
logger(ALERT, sprintf(_("%s vient de s'ouvrir alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
logger(ALERT, sprintf(_("%s vient de se fermer alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
logger(ALERT, sprintf(_("%s vient de se fermer alors que personne n'est présent"), $device->friendlyName), __FILE__ . ":" . __LINE__);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,6 +87,6 @@ class alerte_intrusion extends hook
|
|||||||
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
$hooks["alerte_intrusion"] = new alerte_intrusion();
|
||||||
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Initializing event"), __FILE__ . ":" . __LINE__);
|
||||||
$function = array($hooks["alerte_intrusion"], "testPortes");
|
$function = array($hooks["alerte_intrusion"], "testPortes");
|
||||||
setRecurrentEvent($function, 0, 0, 0, false, 0, 0, 21, 0, 0, 0, 0, 0, 0);
|
//setRecurrentEvent("alerte_intrusion", $function, "", "", 0, -1, "", "", false, 21);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@ -10,11 +10,13 @@ class rdc_salon_eclairage extends hook
|
|||||||
RDC_SALON_MVMT2 => "occupancy",
|
RDC_SALON_MVMT2 => "occupancy",
|
||||||
RDC_ENTREE_PORTE => "contact",
|
RDC_ENTREE_PORTE => "contact",
|
||||||
RDC_SALON_LUMINOSITE => "illuminance_lux",
|
RDC_SALON_LUMINOSITE => "illuminance_lux",
|
||||||
RDC_SALON_ECLAIRAGE_PANNEAU => "state"
|
RDC_SALON_ECLAIRAGE_PANNEAU => "state",
|
||||||
|
RDC_SALON_PRESENCE => "presence"
|
||||||
);
|
);
|
||||||
protected $actionneurs = array(
|
protected $actionneurs = array(
|
||||||
array(RDC_SALON_MVMT, "occupancy", 1),
|
array(RDC_SALON_MVMT, "occupancy", 1),
|
||||||
array(RDC_SALON_MVMT2, "occupancy", 1)
|
array(RDC_SALON_MVMT2, "occupancy", 1),
|
||||||
|
array(RDC_SALON_PRESENCE => "presence", 1)
|
||||||
);
|
);
|
||||||
public $delay = 3; // amount of time in $timeunit
|
public $delay = 3; // amount of time in $timeunit
|
||||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year
|
||||||
@ -41,6 +43,8 @@ class rdc_salon_eclairage extends hook
|
|||||||
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
|
logger (INFO, _("property => ") . $param . _("value =>") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||||
switch($param)
|
switch($param)
|
||||||
{
|
{
|
||||||
|
case "presence":
|
||||||
|
logger(INFO, _("CASE: Présence => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||||
case "occupancy":
|
case "occupancy":
|
||||||
$method = $deviceTarget->properties["state"]["method"];
|
$method = $deviceTarget->properties["state"]["method"];
|
||||||
logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("CASE: Occupancy => ") . bool2string($value), __FILE__ . ":" . __LINE__);
|
||||||
@ -57,7 +61,8 @@ class rdc_salon_eclairage extends hook
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("Value is OFF"), __FILE__ . ":" . __LINE__);
|
||||||
if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
if (testActionneurs($this->actionneurs) and $method = AUTO)
|
||||||
|
//if ((getValue(RDC_SALON_MVMT, "occupancy") == OFF) and (getValue(RDC_SALON_MVMT2, "occupancy") == OFF) and $method == AUTO)
|
||||||
{
|
{
|
||||||
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("Setting to OFF"), __FILE__ . ":" . __LINE__);
|
||||||
$this->send($deviceTarget, "OFF", false, IDLE);
|
$this->send($deviceTarget, "OFF", false, IDLE);
|
||||||
@ -65,6 +70,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "contact":
|
case "contact":
|
||||||
$method = $deviceTarget->properties["state"]["method"];
|
$method = $deviceTarget->properties["state"]["method"];
|
||||||
logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("CASE: Contact Door"), __FILE__ . ":" . __LINE__);
|
||||||
@ -78,6 +84,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "illuminance_lux":
|
case "illuminance_lux":
|
||||||
logger(INFO, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("CASE : Illuminance"), __FILE__ . ":" . __LINE__);
|
||||||
if ($value >= $this->luminance_max and $deviceTarget->properties["state"]["value"] == "ON")
|
if ($value >= $this->luminance_max and $deviceTarget->properties["state"]["value"] == "ON")
|
||||||
@ -87,6 +94,7 @@ class rdc_salon_eclairage extends hook
|
|||||||
removeEvent($deviceTarget, "state", "OFF");
|
removeEvent($deviceTarget, "state", "OFF");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "state":
|
case "state":
|
||||||
logger(INFO, _("CASE : State"), __FILE__ . ":" . __LINE__);
|
logger(INFO, _("CASE : State"), __FILE__ . ":" . __LINE__);
|
||||||
$method = $deviceTarget->properties["state"]["method"];
|
$method = $deviceTarget->properties["state"]["method"];
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// script to prevent when exterior temperature become inferior or superior to interior one
|
// script to prevent when exterior temperature become inferior or superior to interior one
|
||||||
class rdc_temperature_int_ext extends hook
|
class rdc_temperature_int_ext extends hook
|
||||||
{
|
{
|
||||||
public $hookName = "rdc_wc_eclairage";
|
public $hookName = "rdc_temperature_int_ext";
|
||||||
public $active = true; //enable/disable hook (true => enabled)
|
public $active = true; //enable/disable hook (true => enabled)
|
||||||
public $tempSup = 25;
|
public $tempSup = 25;
|
||||||
public $tempInf = 20;
|
public $tempInf = 20;
|
||||||
@ -12,6 +12,13 @@ class rdc_temperature_int_ext extends hook
|
|||||||
METEO=> "tempc",
|
METEO=> "tempc",
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $portesList = array(
|
||||||
|
ENTREE_PORTE => "contact",
|
||||||
|
//GARAGE_PORTE => "contact",
|
||||||
|
RDC_CHAMBRE_BAIE => "contact",
|
||||||
|
RDC_SALON_BAIE => "contact"
|
||||||
|
);
|
||||||
|
|
||||||
function installHooks(&$indexDevices)
|
function installHooks(&$indexDevices)
|
||||||
{
|
{
|
||||||
return $this->installHooksFunction($indexDevices);
|
return $this->installHooksFunction($indexDevices);
|
||||||
@ -26,7 +33,14 @@ class rdc_temperature_int_ext extends hook
|
|||||||
$status = -1;
|
$status = -1;
|
||||||
$msg = "";
|
$msg = "";
|
||||||
|
|
||||||
|
logger(DEBUG, _("rdc_temperature_int_ext hook"), null ,$device);
|
||||||
|
|
||||||
if (empty($time)) $time = now();
|
if (empty($time)) $time = now();
|
||||||
|
//echo "Time is " . var_dump($time) . EOL;
|
||||||
|
//echo "minutes since time :" . now()->format("U") - $time->format("U");
|
||||||
|
if ((now()->format("U") - $time->format("U")) > 300)
|
||||||
|
{
|
||||||
|
|
||||||
$indoorTemp = $device->properties["indoortempc"]["value"];
|
$indoorTemp = $device->properties["indoortempc"]["value"];
|
||||||
|
|
||||||
|
|
||||||
@ -54,10 +68,11 @@ class rdc_temperature_int_ext extends hook
|
|||||||
}
|
}
|
||||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||||
}
|
}
|
||||||
$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
$portes = $hooks["alerte_intrusion"]->testPortes($this->portesList, false, true);
|
||||||
|
print_r($portes);
|
||||||
if ($status == 1)
|
if ($status == 1)
|
||||||
{
|
{
|
||||||
if (empty($portes) and ($time->diff(now())->format("i")) > 5)
|
if (empty($portes))
|
||||||
{
|
{
|
||||||
logger(ALERT, _("Open doors to climate"), null, $device);
|
logger(ALERT, _("Open doors to climate"), null, $device);
|
||||||
$time = now();
|
$time = now();
|
||||||
@ -65,12 +80,13 @@ class rdc_temperature_int_ext extends hook
|
|||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
//$portes = $hooks["alerte_intrusion"]->testPortes(false, true);
|
||||||
if (!empty($portes) and ($time.diff(now()).format("i") > 5))
|
if (!empty($portes))
|
||||||
{
|
{
|
||||||
$time = now();
|
$time = now();
|
||||||
foreach($portes as $porte)
|
foreach($portes as $porte)
|
||||||
{
|
{
|
||||||
$msg .= $porte . "\n";
|
$msg .= $porte . "\n";
|
||||||
|
}
|
||||||
logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
|
logger(ALERT, _("Close doors to climate\n") . $msg, null, $device);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
moha.php
8
moha.php
@ -38,7 +38,8 @@ $curlErr = 0; // Number of errors returned by curl
|
|||||||
$configDir = "./config"; // default config dir (production value is /etc/moha/)
|
$configDir = "./config"; // default config dir (production value is /etc/moha/)
|
||||||
$hooksInitialized = 0; // are all hooks initialized ? false/true
|
$hooksInitialized = 0; // are all hooks initialized ? false/true
|
||||||
$flagHooks = false;
|
$flagHooks = false;
|
||||||
$devicesRequest = false; //say to true when publishing device request to zigbee2mqtt
|
$devicesRequest = false; // set to true when publishing device request to zigbee2mqtt
|
||||||
|
$presence = array(); // name and status of presence
|
||||||
|
|
||||||
if ($testMode)
|
if ($testMode)
|
||||||
{
|
{
|
||||||
@ -60,6 +61,7 @@ if ($testMode)
|
|||||||
|
|
||||||
if (!init()) exit(1);
|
if (!init()) exit(1);
|
||||||
|
|
||||||
|
|
||||||
// gettext
|
// gettext
|
||||||
bindtextdomain("moha", "./locale");
|
bindtextdomain("moha", "./locale");
|
||||||
textdomain("moha");
|
textdomain("moha");
|
||||||
@ -207,8 +209,11 @@ require $configDir . "/properties2log.php";
|
|||||||
require "mqtt_functions.php";
|
require "mqtt_functions.php";
|
||||||
require "events.php";
|
require "events.php";
|
||||||
require "db_functions.php";
|
require "db_functions.php";
|
||||||
|
require "config/liste_telephones.php";
|
||||||
|
require "presence.php";
|
||||||
require "apiserver/apiserver.php";
|
require "apiserver/apiserver.php";
|
||||||
|
|
||||||
|
|
||||||
logger(DEBUG, _("Loading stored events datas from ") . $dataPath . "events.db", __FILE__ . ":" . __LINE__);
|
logger(DEBUG, _("Loading stored events datas from ") . $dataPath . "events.db", __FILE__ . ":" . __LINE__);
|
||||||
if (file_exists($dataPath . "events.db"))
|
if (file_exists($dataPath . "events.db"))
|
||||||
{
|
{
|
||||||
@ -362,6 +367,7 @@ while (true)
|
|||||||
checkEvents();
|
checkEvents();
|
||||||
checkTopicsAvailability();
|
checkTopicsAvailability();
|
||||||
if ($apiServerIsActive) apiServer($read);
|
if ($apiServerIsActive) apiServer($read);
|
||||||
|
//presence();
|
||||||
}
|
}
|
||||||
|
|
||||||
endMoha();
|
endMoha();
|
||||||
|
@ -5,3 +5,6 @@ chown domotique:domotique -R /etc/moha
|
|||||||
rsync -aP --exclude "*~" --exclude *kate-swp $1/webserver/ /var/www/html/moha/
|
rsync -aP --exclude "*~" --exclude *kate-swp $1/webserver/ /var/www/html/moha/
|
||||||
chmod u+rX -R /var/www/html/moha/
|
chmod u+rX -R /var/www/html/moha/
|
||||||
chown apache:apache -R /var/www/html/moha
|
chown apache:apache -R /var/www/html/moha
|
||||||
|
rsync -aP --exclude "*~" --exclude *kate-swp $1/daemons/ /usr/bin/
|
||||||
|
rsync -aP --exclude "*~" --exclude *kate-swp $1/systemd/ /etc/systemd/system/
|
||||||
|
#must enable service
|
||||||
|
Loading…
Reference in New Issue
Block a user