Command interface API

This commit is contained in:
JonatanRek 2020-03-13 16:20:14 +01:00
parent 0d0ba4ae50
commit 62449d2528
1 changed files with 18 additions and 2 deletions

20
api.php
View File

@ -92,6 +92,7 @@ try {
$token = $obj['token'];
$values = null;
$settings = null;
$command = "null";
if (isset($obj['values'])) {
$values = $obj['values'];
@ -169,6 +170,21 @@ if ($settings != null || $settings != ""){
DeviceManager::editByToken($token, $data);
}
// Issuing command
if ($command == "null"){
$deviceCommand = DeviceManager::getDeviceByToken($token)["command"];
if ($deviceCommand != '' || $deviceCommand != null)
{
$command = $deviceCommand;
}
$data = [
'command'=>'null'
];
DeviceManager::editByToken($token, $data);
$logManager->write("[API] Device_ID " . $deviceId . " executing command " . $command, LogRecordType::INFO);
}
// Subdevices first data!
if ($values != null || $values != "") {
@ -226,7 +242,7 @@ if ($values != null || $values != "") {
'gateway' => $device['gateway'],
],
'state' => 'succes',
'command' => "null",
'command' => $command,
];
$subDevicesTypeList = SubDeviceManager::getSubDeviceSTypeForMater($deviceId);
@ -263,7 +279,7 @@ if ($values != null || $values != "") {
],
'state' => 'succes',
'value' => $subDeviceLastReordValue,
'command' => "null",
'command' => $command,
));
header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
}