" . $argList[1]); //print_r($array); //if (isset($array[1])) $argList[$array[0]] = $array[1]; } logger(DEBUG, print_r($argList, true)); if(array_key_exists("cmd", $argList)) { $command = strtolower($argList["cmd"]); logger(DEBUG, _("command is ") . $command); switch($command) { case "get": logger(DEBUG, _("GET reached"), __FILE__ . ":" . __LINE__); if(!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList)) { $response = "
GET: " . _("no parameters passed, need topic, fn and property") . ""; }else { $device = getDevice($argList["topic"], $argList["fn"]); $property = $argList["property"]; $response = "
GET: " . bool2string($device->$property["value"]) . ""; } fwrite($spawn, $response); break; case "set": logger(DEBUG, _("SET reached"), __FILE__ . ":" . __LINE__); if(!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList) or !array_key_exists("value", $argList)) { $response = "
SET: " . _("no parameters passed, need topic, fn, property and value") . "passed"; fwrite($spawn, $response); }else { $response = "
setting property " . $argList["property"] . " of " . $argList["fn"] . " to value: " . $argList["value"] . ""; fwrite($spawn, $response); $payload = array($argList["property"] => $argList["value"]); publish(Z2M . "/" . $argList["fn"], $payload); } break; case "dump": case "print": logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); $var = $GLOBALS[$argList["object"]]; if (isset($argList["topic"])) { $topic = $argList["topic"]; } if (isset($argList["address"])) { $var = $var[$argList["address"]]; }elseif (isset($argList["fn"])) { if(!empty($topic)) { $var = getDevice($topic, $argList["fn"]); }else { $str = _("topic is not defining: add &topic=\nThese topics are availables: "); foreach($topics as $key => $value) { $str .= $key . EOL; } logger(ERROR, $str, __FILE__ . ":" . __LINE__); } } $error = error_get_last(); if($error !== null) { $response = "
" . $error["message"] . " file: " . $error["file"] . " line: " . $error["line"] . ""; } if ($command === "print") { $response = print_r($var, true); }elseif($command === "dump") { $response = "Dump" . EOL; $response .= var_export($var, true); } fwrite($spawn, $response); break; case "notify": logger(DEBUG, $command . _(" reached"), __FILE__ . ":" . __LINE__); if (!array_key_exists("topic", $argList) or !array_key_exists("fn", $argList) or !array_key_exists("property", $argList) or !array_key_exists("condition", $argList) or !array_key_exists("value", $argList)) { $response = "
" . _("Error: With 'notify' command, you need 4 parameters: topic, fn, property, condition, value") . ""; fwrite($spawn, $response); }else { $response = "
" . _("notify command have been set") . ""; $monitored[] = new watch($argList["topic"], $argList["fn"], $argList["property"], $argList["condition"], $argList["value"]); fwrite($spawn, $response); } logger(DEBUG, print_r($monitored, true)); break; default: logger(DEBUG, _("unknown command"), __FILE__ . ":" . __LINE__); $response = "
" . _("unknown command") . ""; fwrite($spawn, $response); } } } } } } ?>