API Device Log Fix
This commit is contained in:
parent
e65b046d47
commit
ac43bdaf64
@ -70,11 +70,6 @@ class EndpointsApi extends ApiController{
|
|||||||
$data['firmware_hash'] = $obj['settings']["firmware_hash"];
|
$data['firmware_hash'] = $obj['settings']["firmware_hash"];
|
||||||
}
|
}
|
||||||
DeviceManager::editByToken($obj['token'], $data);
|
DeviceManager::editByToken($obj['token'], $data);
|
||||||
$this->response([
|
|
||||||
'state' => 'succes',
|
|
||||||
'command' => $command,
|
|
||||||
], 200);
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Log Data Save
|
//Log Data Save
|
||||||
@ -115,6 +110,7 @@ class EndpointsApi extends ApiController{
|
|||||||
if (!SubDeviceManager::getSubDeviceByMaster($device['device_id'], $key)) {
|
if (!SubDeviceManager::getSubDeviceByMaster($device['device_id'], $key)) {
|
||||||
SubDeviceManager::create($device['device_id'], $key, UNITS[$key]);
|
SubDeviceManager::create($device['device_id'], $key, UNITS[$key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subDeviceLastReordValue[$key] = $value['value'];
|
$subDeviceLastReordValue[$key] = $value['value'];
|
||||||
RecordManager::create($device['device_id'], $key, round($value['value'],3));
|
RecordManager::create($device['device_id'], $key, round($value['value'],3));
|
||||||
$logManager->write("[API] Device_ID " . $device['device_id'] . " writed value " . $key . ' ' . $value['value'], LogRecordTypes::INFO);
|
$logManager->write("[API] Device_ID " . $device['device_id'] . " writed value " . $key . ' ' . $value['value'], LogRecordTypes::INFO);
|
||||||
@ -170,14 +166,15 @@ class EndpointsApi extends ApiController{
|
|||||||
foreach ($subDevicesData as $key => $subDeviceData) {
|
foreach ($subDevicesData as $key => $subDeviceData) {
|
||||||
$subDeviceId = $subDeviceData['subdevice_id'];
|
$subDeviceId = $subDeviceData['subdevice_id'];
|
||||||
$subDeviceLastReord = RecordManager::getLastRecord($subDeviceId);
|
$subDeviceLastReord = RecordManager::getLastRecord($subDeviceId);
|
||||||
|
if (!empty ($subDeviceLastReord)) {
|
||||||
$subDeviceLastReordValue[$subDeviceData['type']] = $subDeviceLastReord['value'];
|
$subDeviceLastReordValue[$subDeviceData['type']] = $subDeviceLastReord['value'];
|
||||||
|
|
||||||
if ($subDeviceLastReord['execuded'] == 0){
|
if ($subDeviceLastReord['execuded'] == 0){
|
||||||
$logManager->write("[API] subDevice_ID " . $subDeviceId . " executed comand with value " . json_encode($subDeviceLastReordValue) . " executed " . $subDeviceLastReord['execuded'], LogRecordTypes::INFO);
|
$logManager->write("[API] subDevice_ID " . $subDeviceId . " executed comand with value " . json_encode($subDeviceLastReordValue) . " executed " . $subDeviceLastReord['execuded'], LogRecordTypes::INFO);
|
||||||
RecordManager::setExecuted($subDeviceLastReord['record_id']);
|
RecordManager::setExecuted($subDeviceLastReord['record_id']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$hostname = "";
|
$hostname = "";
|
||||||
$hostname = strtolower($device['name']);
|
$hostname = strtolower($device['name']);
|
||||||
|
Loading…
Reference in New Issue
Block a user