properties))
{
$propertyObject = $device->properties[$property];
$value = $propertyObject["value"];
logger(DEBUG, $device->friendlyName . " => " . bool2string(_($value)));
$response .= $device->friendlyName . aliases($device->friendlyName, $property) . ' => ';
if (array_key_exists("access", $propertyObject))
{
logger(DEBUG, _("Access = ") . $propertyObject["access"], __FILE__ . ":" . __LINE__);
if(($propertyObject["access"] & 2))
{
logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__);
$response .= " " . displayChoice($device, $property, $value);
}
if(($propertyObject["access"] & 4))
{
logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__);
$response .= 'friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">";
}
$response .= EOLH;
}else
{
$response .= bool2string(_($value));
if(array_key_exists("unit", $propertyObject))
{
$response .= $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__);
}
$response .= EOLH;
}
}else
{
logger(ERROR, _("Property does not exists"), __FILE__ . ":" . __LINE__);
}
}else
{
logger(ERROR, _("Device does not exists"), __FILE__ . ":" . __LINE__);
}
}
}else
{
logger(ERROR, _("Dashboard does not exists"), __FILE__ . ":" . __LINE__);
$response = _("dashboard not found");
}
htmlSend($socket, $response, '');
}
function displayChoice($device, $propertyName, $value)
{
logger(INFO, _("function displayChoice"), __FILE__ . ":" . __LINE__);
$propertyObject = $device->properties[$propertyName];
$unit = '';
if(array_key_exists("unit", $propertyObject))
{
$unit = $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__);
}
if (!array_key_exists("type", $propertyObject)) return "";
switch ($propertyObject["type"])
{
case "binary":
logger(DEBUG, _("type is binary"), __FILE__ . ":" . __LINE__);
$formHTML = bool2string($value);
$choice["on"] = $propertyObject["value_on"];
$choice["off"] = $propertyObject["value_off"];
if (array_key_exists("toggle", $propertyObject))
{
$choice["toggle"] = $propertyObject["toggle"];
}
$formHTML .= mkHTML($device, $propertyName, $choice);
break;
case "numeric":
logger(DEBUG, _("type is numeric") . "#" . $value . "#", __FILE__ . ":" . __LINE__);
$step = '';
if (array_key_exists("value_step", $propertyObject))
{
$step = ' step="' . $propertyObject["value_step"] . '"';
}
//$formHTML .= $device->friendlyName . aliases($device->friendlyName, $property) . ' => ';
$formHTML = 'friendlyName . "/"
. $propertyObject["name"] ."/value" . '"'
. ' min="' . $propertyObject["value_min"] . '"'
. ' max="' . $propertyObject["value_max"] . '"'
. $step
. ' value="' . $value . '">' . $unit . EOL;
$formHTML .= 'friendlyName . "/" . $propertyObject["name"] . '"';
$formHTML .= ' name="' . $propertyObject["name"] . '"';
$formHTML .= ' min="' . $propertyObject["value_min"] . '"';
$formHTML .= ' max="' . $propertyObject["value_max"] . '"';
$formHTML .= ' value="' . $propertyObject["value"] . '"';
$formHTML .= $step;
$formHTML .= " oninput=\"setPropertyValue('" . $device->topic . "', '" . $device->friendlyName . "', this.value, '" . $propertyObject["name"] . "')\">";
break;
case "enum":
logger(DEBUG, _("type is enum"), __FILE__ . ":" . __LINE__);
$formHTML = bool2string($value);
$choice = $propertyObject["values"];
$formHTML .= mkHTML($device, $propertyName, $choice);
break;
default:
logger(DEBUG, "type of property not recognized:" . $propertyObject["type"] , __FILE__ . ":" . __LINE__);
}
return $formHTML;
}
function mkHTML($device, $propertyName, $choice)
{
$html = "";
logger(DEBUG, "function mkHTML", __FILE__ . ":" . __LINE__);
foreach ($choice as $key => $value)
{
$html .= 'friendlyName . "/" . $propertyName . "/" . $key . '" value="' . $value . "\" onmouseup=\"setPropertyValue('" . $device->topic . "', '" . $device->friendlyName . "', '" . $value . "', '" . $propertyName . "')\">";
}
return $html;
}
function webBrowse($socket, $argList, $page="/browse")
{
global $topics, $devices, $listenPort,$indexDevices;
logger(DEBUG, _("Generic response to choose device and property"), __FILE__ . ":" . __LINE__);
//$response = "
" . nl2br(print_r($var, true)) . ""; }elseif($command === "dump") { $response = "Dump" . EOL; $response .= "" . nl2br(var_export($var, true)) . ""; } }else { $response = _("Object do not exists"); } return $response; } function webNotify($argList) { 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 5 parameters: topic, fn, property, condition, value"); }else { $response = _("notify command have been set"); $monitored[] = new watch($argList["topic"], $argList["fn"], $argList["property"], $argList["condition"], $argList["value"]); } return $response; } /* function webDisplayByType($argList) { global $indexTypes, $config; require_once $config . "porpertiesbytype.php"; require_once "webserver/javascript.php"; $response .= insertJavascript(); foreach($indexTypes[$argList["type"]] as $device) { foreach($) displayProperty($device, $device->, $value, $response) } } */ ?>