Rooms And Widget API Endpoints
This commit is contained in:
17
app/api/WidgetApi.php
Normal file
17
app/api/WidgetApi.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
class WidgetApi extends ApiController{
|
||||
|
||||
public function default($subDeviceId){
|
||||
//$this->requireAuth();
|
||||
$response = null;
|
||||
|
||||
$subDeviceData = SubDeviceManager::getSubDevice($subDeviceId);
|
||||
if ($subDeviceData['type'] == 'on/off'){
|
||||
$lastValue = RecordManager::getLastRecord($subDeviceData['subdevice_id'])['value'];
|
||||
RecordManager::create($subDeviceData['device_id'], 'on/off', !$lastValue);
|
||||
$response = !$lastValue;
|
||||
}
|
||||
|
||||
$this->response($response);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user