Keep record of record origin

This commit is contained in:
2021-02-02 12:47:41 +01:00
parent 1f49391b36
commit 2410441b88
4 changed files with 21 additions and 12 deletions

View File

@@ -113,7 +113,7 @@ class EndpointsApi extends ApiController{
}
$subDeviceLastReordValue[$key] = $value['value'];
RecordManager::create($device['device_id'], $key, round($value['value'],3));
RecordManager::create($device['device_id'], $key, round($value['value'],3), 'device');
$logManager->write("[API] Device_ID " . $device['device_id'] . " writed value " . $key . ' ' . $value['value'], LogRecordTypes::INFO);
//notification

View File

@@ -14,7 +14,7 @@ class WidgetApi extends ApiController
$subDeviceData = SubDeviceManager::getSubDevice($subDeviceId);
if ($subDeviceData['type'] == 'on/off') {
$lastValue = RecordManager::getLastRecord($subDeviceData['subdevice_id'])['value'];
RecordManager::create($subDeviceData['device_id'], 'on/off', (int) !$lastValue);
RecordManager::create($subDeviceData['device_id'], 'on/off', (int) !$lastValue, "vue-app");
$response = !$lastValue;
} else {
throw new Exception("Bad Request", 403);
@@ -46,7 +46,7 @@ class WidgetApi extends ApiController
$response = null;
$subDeviceData = SubDeviceManager::getSubdeviceDetailById($subDeviceId);
//TODO: zeptat se @Patrik Je Graf Dobře Seřazený na DESC ?
$events = RecordManager::getAllRecordForGraph($subDeviceId, $period, $groupBy[$period]);
if ( count($events) == 0){
@@ -114,7 +114,7 @@ class WidgetApi extends ApiController
];
//TODO: Make Cleaner
//TODO: Make Cleaner
if (isset(RANGES[$subDeviceData['type']])){
$response['graph']['options']['scales']['yAxes'] = [[
'ticks' => [
@@ -124,7 +124,7 @@ class WidgetApi extends ApiController
]
]];
}
$this->response($response);
}