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) ); // callback fonction. Is called with these 4 parameters public function callBack(&$device, $property, $value) { global $devices, $indexDevices; switch($property) { case "occupancy": if ($value == ON) { $this->send("ON"); setDelay($device, $this->delay, $this->timeUnit, "state_l1", "OFF", true); $device->method = AUTO; } break; case "state_l1": if ($value == ON) { setDelay($device, $this->delayManual, $this->timeUnit, "state_l1", "OFF", true); $device->method = MANUAL; }elseif ($value = OFF) { deleteEvent(searchEvent($device, "state_l1", "OFF")); } break; } logger (INFO, _("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, $value); } private function send($state) { global $devices, $indexDevices; $msg = array("state_l1" => $state); $device = & $indexDevices["0x00158d0005c1a998"]; logger(INFO, sprintf(_("publishing message: %s to %s"), $msg, $device->friendlyName)); $device->payload = $msg; $device->set(null); } } $hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage(); ?>