1
0

debugging

This commit is contained in:
2022-01-17 00:18:50 +01:00
parent cd20e973cd
commit 4fb5504cdc
18 changed files with 379 additions and 269 deletions

View File

@ -2,28 +2,25 @@
class availability
{
public $hookname = "availability";
public $initialized = true;
// by default all devices are listening for availability
function __construct()
{
global $devices;
$this->iterate($devices);
$this->iterate();
}
private function iterate(& $device)
private function iterate()
{
foreach ($device as $key => $value)
global $indexDevices;
foreach ($indexDevices as $value)
{
if (gettype($value) == "array")
{
$this->iterate($value);
}elseif (is_a($value, "device"))
{
$value->availability["functions"][] = array($this,"callback");
}
$value->availability["functions"][] = array($this,"callback");
}
}
// callback fonction. Is called with these 3 parameters
// $device -> calling device
// $property -> parameter passed by mqtt

View File

@ -1,28 +1,19 @@
<?php
class alerte_intrusion
class alerte_intrusion extends hook
{
public $hookName = "alerte_intrusion";
public $active = true;
private $devicelist = array(ENTREE_PORTE => "contact", GARAGE_PORTE => "contact", RDC_CHAMBRE_BAIE => "contact", RDC_SALON_BAIE => "contact");
protected $devicelist = array(
ENTREE_PORTE => array("contact", false),
GARAGE_PORTE => array("contact", false),
RDC_CHAMBRE_BAIE => array("contact", false),
RDC_SALON_BAIE => array("contact", false));
public $delay = 3; // amount of time in $timeunit
public $delayManual = 10; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
function __construct()
{
global $indexDevices;
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress => $param)
{
$indexDevices[$ieeeAddress]->$param["functions"][] = array($this,"callback");
}
}
}
// callback fonction. Is called with these 4 parameters
public function callBack(&$device, $param, $value)
{

View File

@ -1,15 +1,14 @@
<?php
class rdc_salon_eclairage
class rdc_salon_eclairage extends hook
{
public $hookName = "rdc_salon_eclairage";
public $active = true;
// list of devices we are listening to
private $devicelist = array(
RDC_SALON_MVMT => "occupancy",
RDC_SALON_MVMT2 => "occupancy",
RDC_ENTREE_PORTE => "contact",
RDC_SALON_LUMINOSITE => "illuminance_lux"
protected $devicelist = array(
RDC_SALON_MVMT => array("occupancy", false),
RDC_SALON_MVMT2 => array("occupancy", false),
RDC_ENTREE_PORTE => array("contact", false),
RDC_SALON_LUMINOSITE => array("illuminance_lux", false)
);
public $delay = 3; // amount of time in $timeunit
@ -18,20 +17,6 @@ class rdc_salon_eclairage
public $luminance_max = 3000;
function __construct()
{
global $indexDevices;
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress => $param)
{
$indexDevices[$ieeeAddress]->$param["functions"][] = array($this,"callback");
}
}
}
// callback fonction. Is called with these 4 parameters
public function callBack(&$device, $param, $value)
{
@ -61,7 +46,7 @@ class rdc_salon_eclairage
{
global $devices, $indexDevices;
$device = & $indexDevices[RDC_SALON_ECLAIRAGE_PANNEAU];
if ($device->state_l1["value"] != $state)
if ($device->state["value"] != $state)
{
$msg = array("state" => $state);
logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName));

View File

@ -1,40 +1,31 @@
<?php
class rdc_sdb_eclairage
class rdc_sdb_eclairage extends hook
{
public $hookName = "rdc_sdb_eclairage";
public $active = true;
/* already defined in hook class */
// public $active = true;
//public $initlialized = false;
public $delay = 3; // amount of time in $timeunit
public $delayManual = 10; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
// list of devices we are listening to
// 0x00158d0003f0f3b4 douche mvmnt
// 0x842e14fffe1c0cd1 plafond mvmnt
// 0x00124b0022ec05dc mvmnt
// 0x00158d0005c1a998 module commutateur => state_l1
private $devicelist = array(
"0x00158d0003f0f3b4" => "occupancy",
"0x842e14fffe1c0cd1" => "occupancy",
"0x00124b0022ec05dc" => "occupancy",
RDC_SDB_WC_ECLAIRAGE => "state_l1"
// devicelist[$ieeAddress][0] => property to watch
// devicelist[$ieeAddress][1] => initialized = true
protected $devicelist = array(
"0x00158d0003f0f3b4" => array("occupancy", false),
"0x842e14fffe1c0cd1" => array("occupancy", false),
"0x00124b0022ec05dc" => array("occupancy", false),
RDC_SDB_WC_ECLAIRAGE => array("state_l1", false)
);
public $delay = 3; // amount of time in $timeunit
public $delayManual = 10; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
function __construct()
{
global $indexDevices;
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress => $property)
{
$indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback");
}
}
}
// callback fonction. Is called with these 4 parameters
public function callBack(&$device, $property, $value)
{
@ -73,6 +64,6 @@ class rdc_sdb_eclairage
$device->set(null);
}
}
$hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage();
?>

View File

@ -1,30 +1,15 @@
<?php
class rdc_wc_eclairage
class rdc_wc_eclairage extends hook
{
public $hookName = "rdc_wc_eclairage";
public $active = true;
private $devicelist = array(RDC_SDB_WC_ECLAIRAGE => "state_l2");
protected $devicelist = array(RDC_SDB_WC_ECLAIRAGE => array("state_l2", false));
public $delay = 3; // amount of time in $timeunit
public $delayManual = 10; // amount of time in $timeunit for manual mode
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
function __construct()
{
global $indexDevices;
// assigne the function to the sensors devices
if ($this->active === true)
{
foreach ($this->devicelist as $ieeeAddress => $property)
{
$indexDevices[$ieeeAddress]->$property["functions"][] = array($this,"callback");
}
}
}
// callback fonction. Is called with these 4 parameters
public function callBack(&$device, $property, $value)
{