enabled) public $delay = 5; // amount of time in $timeunit public $timeUnit = "minute"; // unit of time for delay, second, minute, hour, day, week, month, year public $luminance_min = 60; public $luminance_max = 3000; protected $devicelist = array( "RDC_CHAMBRE_AMBIANCE" => array("state", false), "RDC_CHAMBRE_ECLAIRAGE" => array("state_l1", false), "RDC_CHAMBRE_MVMT" => array("occupancy", false), "RDC_CHAMBRE_ARMOIRE_GAUCHE" => array("contact", false) ); // callback fonction. Is called with these 3 parameters // $device -> calling device // $property -> property of the device (given by mqtt) // $value -> value of the property public function callBack(&$device, $property, $value) { global $devices, $indexDevices; $lux = $indexDevices[RDC_CHAMBRE_LUMINOSITE]->illuminance_lux; if ($property == "occupancy" and $value == "ON") { $this->send(RDC_CHAMBRE_LUMINOSITE, "ON", "OFF", AUTO); } logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value), __FILE__ . ":" . __LINE__); } private function send($device, $state, $delayState = false, $method = MANUAL) { global $devices, $indexDevices; $device = &$indexDevices[$device]; $msg = array("state" => $state); if ($device->state["value"] != $state) { logger(INFO, sprintf(_("publishing message: %s to %s"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__); $device->payload = $msg; $device->set(); $device->method = $method; }else { logger(INFO, sprintf(_("not publishing message: %s to %s, already set"), json_encode($msg), $device->friendlyName), __FILE__ . ":" . __LINE__); } //echo 'delaystate = ' . var_dump($delayState); if ($delayState !== false) setDelay($device, $this->delay, $this->timeUnit, "state", $delayState, true); } } $hooks["rdc_chambre_eclairage"] = new rdc_chambre_eclairage(); ?>