// Objekte zuweisen var OneClick_Start = 'vr200.0.Robbi.commands.OneClick_Start' var OneClick_GoToBase = 'vr200.0.Robbi.commands.OneClick_GoToBase' // Startwerte holen var doLog = getState('vr200.0.Robbi.commands.OneClick_Log').val; // Robbi commands var cRobbiStart ='vr200.0.Robbi.commands.clean' var cRobbiStop ='vr200.0.Robbi.commands.stop' var cRobbiNachHause = 'vr200.0.Robbi.commands.OneClick_GoToBase' // Zum Start zur sicherheit zurücksetzten setState(OneClick_Start, false); setState(OneClick_GoToBase, false); // Auf Events reagieren on({id: OneClick_Start}, function (obj) {if(getState(OneClick_Start).val == true){DoStateChanges('Start');}}); on({id: OneClick_Start}, function (obj) {if(getState(OneClick_Start).val == false){DoStateChanges('Stop');}}); on({id: OneClick_GoToBase}, function (obj) {if(getState(OneClick_GoToBase).val != false){DoStateChanges('GoToBase');}}); // Objektstatus zuweisen function DoStateChanges(Action) { doLog = getState('vr200.0.Robbi.commands.OneClick_Log').val; switch (true) { case (Action =='Start'): MyLog('RobbiStart: ' + " " + String(getState(OneClick_Start).val)); RobbiStart(); break; case (Action =='Stop'): MyLog('RobbiStop: ' + " " + String(getState(OneClick_Start).val)); RobbiStop(); break; case (Action =='GoToBase'): MyLog('RobbiToHome: ' + " " + String(getState(OneClick_GoToBase).val)); RobbiNachHause(); break; default: MyLog('Gibbet nicht'); } } // Robbi ansteuern function RobbiStart() { if(getState('vr200.0.Robbi.status.canStart').val == true) { setState(cRobbiStop ,false); setState(cRobbiNachHause ,false); setState(cRobbiStart ,true); MyLog('Ausgeführt RobbiStart') } else { MyLog('Nicht möglich RobbiStart')} } function RobbiStop() { if((getState('vr200.0.Robbi.status.canStop').val) == true) { setState(cRobbiStart ,false); setState(cRobbiNachHause ,false); setState(cRobbiStop ,true); MyLog('Ausgeführt RobbiStop') } else { MyLog('Nicht möglich RobbiStop')} } function RobbiNachHause() { if(getState('vr200.0.Robbi.status.canGoToBase').val == true) { setState(cRobbiStop ,false); setState(cRobbiStart ,false); setState(cRobbiNachHause ,true); MyLog('Ausgeführt RobbiNachHause') } else { MyLog('Nicht möglich RobbiNachHause')} } function MyLog(LogString){if(doLog == true){console.log(LogString)}}