debugged notification of availability of devices
This commit is contained in:
@ -1,31 +1,40 @@
|
||||
<?php
|
||||
|
||||
class availability
|
||||
class availability extends hook
|
||||
{
|
||||
public $hookname = "availability";
|
||||
public $initialized = true;
|
||||
public $active = true;
|
||||
// by default all devices are listening for availability
|
||||
protected $devicelist = array();
|
||||
|
||||
function __construct()
|
||||
function init()
|
||||
{
|
||||
global $devices;
|
||||
global $indexDevices;
|
||||
$this->iterate();
|
||||
}
|
||||
|
||||
private function iterate()
|
||||
protected function iterate()
|
||||
{
|
||||
global $indexDevices;
|
||||
foreach ($indexDevices as &$value)
|
||||
foreach ($indexDevices as $ieeeAddress => $value)
|
||||
{
|
||||
$value->properties["availability"]["functions"][] = array($this,"callback");
|
||||
$deviceList[] = array( $ieeeAdress => "availability");
|
||||
}
|
||||
$this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return true;
|
||||
static $indexDevicesSize;
|
||||
$tmp = count($indexDevices);
|
||||
if ($tmp != $indexDevicesSize)
|
||||
{
|
||||
$this->iterate();
|
||||
$indexDevicesSize = $tmp;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
// $property -> parameter passed by mqtt
|
||||
@ -35,18 +44,19 @@ class availability
|
||||
switch($property)
|
||||
{
|
||||
case "availability": // theorically can't be other, but ....
|
||||
if ($device->availability != $value)
|
||||
if ($device->properties["availability"]["value]"] != $value)
|
||||
{
|
||||
//echo "==========>>>>>> Availability $value" . EOL;
|
||||
//if (!empty($device->availability))
|
||||
//{
|
||||
//{[ Torrent911.com]
|
||||
$log = ALERT;
|
||||
//}else
|
||||
//{
|
||||
// $log = INFO;
|
||||
//}
|
||||
//$device->availability = $value;
|
||||
logger($log, sprintf(_("Device: %s/%s is %s"), $device->topic, $device->friendlyName, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||
|
||||
logger($log, sprintf(_("Device: %s/%s is %s"), $device->topic, $device->friendlyName, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -49,6 +49,11 @@ class radiateurs extends hook
|
||||
// ETAGE_CHAMBRE_RADIATEUR => 0
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
|
@ -16,6 +16,11 @@ class rdc_chambre_eclairage extends hook
|
||||
RDC_CHAMBRE_AMBIANCE_INTER => "action"
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
|
@ -14,6 +14,11 @@ class alerte_intrusion extends hook
|
||||
GARAGE_PORTAIL => "contact"
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack($device, $property, $value)
|
||||
{
|
||||
|
@ -20,6 +20,11 @@ class rdc_salon_eclairage extends hook
|
||||
public $luminance_min = 50;
|
||||
public $luminance_max = 100;
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack($device, $param, $value)
|
||||
{
|
||||
|
@ -27,6 +27,12 @@ class rdc_sdb_eclairage extends hook
|
||||
array(RDC_SDB_PLAFOND_MVMT, "occupancy", 1),
|
||||
array(RDC_SDB_MVMT, "occupancy", 1)
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
|
@ -21,6 +21,11 @@ class rdc_store extends hook
|
||||
METEO => "windgustkmh"
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
|
@ -21,6 +21,11 @@ class rdc_store extends hook
|
||||
METEO => "windgustkmh"
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
$this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 3 parameters
|
||||
// $device -> calling device
|
||||
// $property -> property of the device (given by mqtt)
|
||||
@ -153,7 +158,7 @@ class rdc_store extends hook
|
||||
}
|
||||
}elseif ($exterieurLuxMoyen < 6000 and $salon_lux < 200 and $soleil < 100)
|
||||
{
|
||||
logger(DEBUG, "exterieurLuxMoyen < 11000 and salon_lux < 1000", __FILE__ . ":" . __LINE__);
|
||||
logger(DEBUG, "exterieurLuxMoyen < 6000 and salon_lux < 200 and soleil < 100", __FILE__ . ":" . __LINE__);
|
||||
$this->close("Luminosité faible");
|
||||
}
|
||||
|
||||
@ -237,7 +242,7 @@ class rdc_store extends hook
|
||||
}
|
||||
}
|
||||
|
||||
private function send($level)
|
||||
private function send($level, $method)
|
||||
{
|
||||
global $indexDevices;
|
||||
$deviceObject = $indexDevices[RDC_STORE];
|
||||
|
@ -4,26 +4,33 @@ class rdc_temperature_int_ext extends hook
|
||||
{
|
||||
public $hookName = "rdc_wc_eclairage";
|
||||
public $active = true; //enable/disable hook (true => enabled)
|
||||
public $wantedTemp = 24;
|
||||
|
||||
protected $devicelist = array(
|
||||
METEO=> "tempc",
|
||||
);
|
||||
|
||||
function installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
global $indexDevices;
|
||||
static $status = 0;
|
||||
if ($device->properties["indoortempc"]["value"] > $value and $status === 1)
|
||||
static $status = -1;
|
||||
$indoorTemp = $device->properties["indoortempc"]["value"];
|
||||
if ( (($value > $this->wantedTemp and $indoorTemp < $this->wantedTemp) or ( $value < $this->wantedTemp and $indoorTemp >= $this->wantedTemp)) and $status === 1)
|
||||
{
|
||||
$status = 0;
|
||||
logger(ALERT, _("Indoor temperature is superior to outdoor one"));
|
||||
}elseif ($device->properties["indoortempc"]["value"] < $value and $status === 0)
|
||||
logger(ALERT, _("Open doors to climate"), null ,$device);
|
||||
}elseif ( (($value > $this->wantedTemp and $indoorTemp >= $this->wantedTemp) or ( $value < $this->wantedTemp and $indoorTemp <= $this->wantedTemp)) and $status === 0 )
|
||||
{
|
||||
$status = 1;
|
||||
logger(ALERT, _("Indoor temperature is inferior to outdoor one"));
|
||||
logger(ALERT, _("Close doors to climate"), null, $device);
|
||||
}
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__);
|
||||
logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, bool2string($value)), __FILE__ . ":" . __LINE__, $device);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,11 @@ class rdc_wc_eclairage extends hook
|
||||
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 installHooks(&$indexDevices)
|
||||
{
|
||||
return $this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
|
@ -14,6 +14,11 @@ class rdc_wc_eclairage extends hook
|
||||
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 installHooks(&$indexDevices)
|
||||
{
|
||||
$this->installHooksFunction($indexDevices);
|
||||
}
|
||||
|
||||
// callback fonction. Is called with these 4 parameters
|
||||
public function callBack(&$device, $property, $value)
|
||||
{
|
||||
|
Reference in New Issue
Block a user