devicelist as $ieeeAddress) { $indexDevices[$ieeeAddress]->functions[] = array($this,"callback"); } } // callback fonction. Is called with these 4 parameters public function callBack($topic, $fn, $param, $value) { global $devices, $indexDevices; switch($param) { case "occupancy": if ($value == 1) $this->send(); break; 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; } private function send() { global $devices, $indexDevices; 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); } } } $hooks["rdc/panneau/salon"] = new rdc_panneau_salon(); ?>