Skip to content

Commit

Permalink
new scenario method api
Browse files Browse the repository at this point in the history
  • Loading branch information
Sekiro-kost committed Jun 7, 2024
1 parent ca971f4 commit 3f2ca98
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions core/api/mobile.api.php
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,46 @@ function saveMenuFromAppV2($menu, $mobile)
}


if($jsonrpc->getMethod() == 'handleScenario'){
$scenarioId = $params['scenario_id'];
$action = $params['action'];

switch($action){
case 'start': if(is_object($scenario = scenario::byId($scenarioId))){
$scenario->launch();
$jsonrpc->makeSuccess('ok');
}else{
$jsonrpc->makeSuccess('ko');
}
break;
case 'stop': if(is_object($scenario = scenario::byId($scenarioId))){
$scenario->stop();
$jsonrpc->makeSuccess('ok');
}else{
$jsonrpc->makeSuccess('ko');
}
break;
case 'activate': if(is_object($scenario = scenario::byId($scenarioId))){
$scenario->setIsActive(1);
$scenario->save();
$jsonrpc->makeSuccess('ok');
}else{
$jsonrpc->makeSuccess('ko');
}
break;
case 'desactivate': if(is_object($scenario = scenario::byId($scenarioId))){
$scenario->setIsActive(0);
$scenario->save();
$jsonrpc->makeSuccess('ok');
}else{
$jsonrpc->makeSuccess('ko');
}
break;
}

}


// if($jsonrpc->getMethod() == 'modifyNotifInJsonFile'){
// log::add('mobile', 'debug', 'modifyNotifInJsonFile');
// $Iq = $params['Iq'];
Expand Down

0 comments on commit 3f2ca98

Please sign in to comment.