property to watch // devicelist[$ieeAddress][1] => initialized = true protected $devicelist = array( //RDC_SDB_DOUCHE_MVMT => array("occupancy", false), RDC_SDB_PLAFOND_MVMT => array("occupancy", false), RDC_SDB_MVMT => array("occupancy", false), RDC_SDB_WC_ECLAIRAGE => array("state_l1", false) ); // callback fonction. Is called with these 3 parameters public function callBack(&$device, $property, $value) { global $devices, $indexDevices; //var_dump($value); switch($property) { case "occupancy": if ($value == ON) { if (getValue(RDC_SDB_WC_ECLAIRAGE, "state_l1") != "ON") { $this->send("ON"); } //setDelay($indexDevices[RDC_SDB_WC_ECLAIRAGE], $this->delay, $this->timeUnit, "state_l1", "OFF", true); $device->method = AUTO; } break; case "state_l1": if ($value == ON) { setDelay($indexDevices[RDC_SDB_WC_ECLAIRAGE], $this->delayManual, $this->timeUnit, "state_l1", "OFF", true); $device->method = MANUAL; }elseif ($value = OFF) { removeEvent($indexDevices[RDC_SDB_WC_ECLAIRAGE], "state_l1", "OFF"); } break; } logger (INFO, sprintf(_("%s: notification received from MQTT from %s => parameter: %s value: %s"), $this->hookName, $device->friendlyName, $property, ($value == 0 ? "OFF" : "ON")), __FILE__ . ":" . __LINE__); } private function send($state) { global $devices, $indexDevices; $msg = array("state_l1" => $state); $device = & $indexDevices[RDC_SDB_WC_ECLAIRAGE]; logger(INFO, sprintf(_("publishing message: %s to %s"), $state, $device->friendlyName), __FILE__ . ":" . __LINE__); $device->payload = $msg; $device->set(null); } } $hooks["rdc_sdb_eclairage"] = new rdc_sdb_eclairage(); ?>