availibility is now property of device object
This commit is contained in:
@ -5,14 +5,18 @@ class rdc_panneau_salon
|
||||
private $devicelist = array("0x00124b0022ebac5c", "0x588e81fffe2cf695", "0x00124b001f900753", "0x04cf8cdf3c78aff0");
|
||||
public $delay = 3; // amount of time in $timeunit
|
||||
public $timeUnit = "minute"; // unit of time for delay, second, minute, day, week, month, year
|
||||
public $luminance_min = 80;
|
||||
public $luminance_max = 3000;
|
||||
|
||||
|
||||
function __construct()
|
||||
{
|
||||
global $indexDevices;
|
||||
|
||||
// assigne the function to the sensors devices
|
||||
foreach ($this->devicelist as $ieeeAddress)
|
||||
{
|
||||
$indexDevices[$ieeeAddress]->functions[] = array($this,"callback");
|
||||
//print_r($indexDevices[$ieeeAddress]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,6 +32,8 @@ class rdc_panneau_salon
|
||||
case "contact":
|
||||
if ($value == false) $this->send();
|
||||
break;
|
||||
case "illuminance_lux":
|
||||
if ($value >= $this->luminance_max) $this->send();
|
||||
}
|
||||
echo _("notification received from MQTT") . EOL;
|
||||
//echo $param . "=> " . $value . EOL;
|
||||
@ -36,10 +42,11 @@ class rdc_panneau_salon
|
||||
private function send()
|
||||
{
|
||||
global $devices, $indexDevices;
|
||||
if ($indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= 76)
|
||||
if ($indexDevices["0x04cf8cdf3c78aff0"]->illuminance_lux <= $this->luminance_min)
|
||||
{
|
||||
$msg = array("state" => "ON");
|
||||
$device = & $indexDevices["0x588e81fffe343e8f"];
|
||||
logger(LOG_INFO, __("publishing ") . $msg . __(" message: ") . $device->friendlyName);
|
||||
$device->payload = $msg;
|
||||
$device->set(null);
|
||||
setDelay($device, $this->delay, $this->timeUnit, "state", "OFF", true);
|
||||
@ -48,9 +55,4 @@ class rdc_panneau_salon
|
||||
}
|
||||
|
||||
$hooks["rdc/panneau/salon"] = new rdc_panneau_salon();
|
||||
//assignation of the function to the sensors devices
|
||||
//$indexDevices["0x00124b0022ebac5c"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-mvmt2
|
||||
//$indexDevices["0x588e81fffe2cf695"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-mvmt
|
||||
//$indexDevices["0x00124b001f900753"]->functions[] = array($panneau_salon,"getCallback"); // rdc-porte-entree
|
||||
//$indexDevices["0x04cf8cdf3c78aff0"]->functions[] = array($panneau_salon,"getCallback"); // rdc-salon-luminosite
|
||||
?>
|
||||
|
Reference in New Issue
Block a user