From 3f2ca98e667e8babb7cb82aebef3bfefb176e19b Mon Sep 17 00:00:00 2001 From: "Julien C." Date: Fri, 7 Jun 2024 14:55:46 +0200 Subject: [PATCH] new scenario method api --- core/api/mobile.api.php | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/core/api/mobile.api.php b/core/api/mobile.api.php index 722b9ad6..47bc7926 100755 --- a/core/api/mobile.api.php +++ b/core/api/mobile.api.php @@ -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'];