1
0

debugged notification of availability of devices

This commit is contained in:
2022-08-12 10:41:55 +02:00
parent 247d1fd17d
commit df94a6becf
18 changed files with 176 additions and 70 deletions

View File

@ -153,11 +153,14 @@ function apiServer($read)
apiDashboard($spawn, $argList[0]);
}else
{
logger(DEBUG, $command . _(" so default action"), __FILE__ . ":" . __LINE__);
logger(DEBUG, $command . _(" does not exists ... so default action"), __FILE__ . ":" . __LINE__);
if (file_exists("php://temp/". $command))
{
logger(DEBUG, $command . _(" is a file"), __FILE__ . ":" . __LINE__);
htmlSend($spawn, file_get_contents("php://temp/". $command), 'Content-Type: image/png');
}else
{
htmlSend($spawn, "command does not exists");
}
}
}

View File

@ -342,7 +342,7 @@ function apiSet($argList)
$device = $indexFriendlyNames[$argList["fn"]];
$device->payload = array($argList["property"] => $argList["value"]);
$device->set($argList["property"], IDLE);
publish($argList["topic"] . "/" . $argList["fn"], $payload, "set");
publish($argList["topic"] . "/" . $argList["fn"], $device->payload, "set");
//removeEvent($indexFriendlyNames($argList["fn"]), $argList["property"], "OFF");
}
return $response;
@ -482,41 +482,48 @@ function PropertiesDashboard($argList)
logger(INFO, _("propertiesDashboard function"), __FILE__ . ":" . __LINE__);
$response = insertJavascript();
$property = $argList["property"];
foreach ($indexProperties[$property] as $device)
print_r($indexProperties[$property]);
foreach($indexProperties as $propertyName => $index)
{
$propertyObject = $device->properties[$property];
$value = $propertyObject["value"];
logger(DEBUG, $device->friendlyName . " => " . bool2string(_($value)), __FILE__ . ":" . __LINE__);
$response .= $device->friendlyName . aliases($device->friendlyName, $property) . ' => ';
if (array_key_exists("access", $propertyObject))
if (str_contains($propertyName, $property ))
{
logger(DEBUG, _("Access = ") . $propertyObject["access"], __FILE__ . ":" . __LINE__);
if(($propertyObject["access"] & 2))
foreach($index as $device)
{
logger(DEBUG, _("Write Access OK ") . ($propertyObject["access"] & 2), __FILE__ . ":" . __LINE__);
$response .= "     " . displayChoice($device, $property, $value);
$propertyObject = $device->properties[$propertyName];
$value = $propertyObject["value"];
logger(DEBUG, $device->friendlyName . " => " . bool2string(_($value)), __FILE__ . ":" . __LINE__);
$response .= $device->friendlyName . aliases($device->friendlyName, $propertyName) . ' => ';
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, $propertyName, $value);
}
if(($propertyObject["access"] & 4))
{
logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__);
$response .= '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">";
}else
{
$response .= $value;
}
$response .= EOLH;
}else
{
$response .= bool2string(_($value));
if(array_key_exists("unit", $propertyObject))
{
$response .= $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__);
}
$response .= EOLH;
}
}
if(($propertyObject["access"] & 4))
{
logger(DEBUG, _("can get value") . ($propertyObject["access"] & 4), __FILE__ . ":" . __LINE__);
$response .= '<input type="button" id="' . $device->topic ."/" . $device->friendlyName . "/" . $propertyObject["name"] . '" value="' . _("Update") . "\" onmouseup=\"getPropertyValue('" . $device->topic . "','" . $device->friendlyName . "','" . $propertyObject["name"] . "')\">";
}else
{
$response .= $value;
}
$response .= EOLH;
}else
{
$response .= bool2string(_($value));
if(array_key_exists("unit", $propertyObject))
{
$response .= $propertyObject["unit"];
logger(DEBUG, _("unit = ") . $unit, __FILE__ . ":" . __LINE__);
}
$response .= EOLH;
}
}
return "json=" . $response;
return $response;
}
function apiHookActive($argList, $status)