MyController 1.0.0.Final version released



  • Build download location

    RELEASE NOTES AND USER DOCUMENT NEEDS TO BE UPDATED. STAY TUNED!


  • MOD

    👍 great!!! congratulations!! switching to the final release now!!
    Really great work!!
    😃



  • Amazing progress = well done!!!!

    So, version 2 beta, when will we see that then ? 😉



  • @skywatch You can see version 2 beta soon 😉



  • Hi Guys,
    Good work on the new release. I have updated to the new Build and i am now experiencing issues my timers/scripts not executing. This was based off this topic (https://forum.mycontroller.org/topic/45/timers-and-scripts/15)

    Im now getting the below error:

    2017-11-06 09:05:00,430 ERROR [Quartz_Scheduler_Worker-6] [org.mycontroller.standalone.operation.model.OperationExecuteScript:133] Exception on McScript(engineName=null, mimeType=null, extension=js, name=/opt/mycontroller/conf/resources/scripts/operations/Timer-Garden-Schedule-Front.js, canonicalPath=null, type=OPERATION, size=0, lastModified=0, bindings={})
    javax.script.ScriptException: TypeError: (mcApi.uidTag().getByUid("GardenFront-Maser")).getSensorVariable is not a function in <eval> at line number 14
    	at jdk.nashorn.api.scripting.NashornScriptEngine.throwAsScriptException(NashornScriptEngine.java:467)
    	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:451)
    	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:403)
    	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:399)
    	at jdk.nashorn.api.scripting.NashornScriptEngine.eval(NashornScriptEngine.java:150)
    	at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:249)
    	at org.mycontroller.standalone.scripts.McScriptEngine.executeScript(McScriptEngine.java:86)
    	at org.mycontroller.standalone.operation.model.OperationExecuteScript.executeScript(OperationExecuteScript.java:130)
    	at org.mycontroller.standalone.operation.model.OperationExecuteScript.execute(OperationExecuteScript.java:112)
    	at org.mycontroller.standalone.timer.jobs.TimerJob.executeTimer(TimerJob.java:58)
    	at org.mycontroller.standalone.timer.jobs.TimerJob.doRun(TimerJob.java:94)
    	at org.knowm.sundial.Job.execute(Job.java:57)
    	at org.quartz.core.JobRunShell.run(JobRunShell.java:178)
    	at org.quartz.core.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:515)
    Caused by: jdk.nashorn.internal.runtime.ECMAException: TypeError: (mcApi.uidTag().getByUid("GardenFront-Maser")).getSensorVariable is not a function
    	at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57)
    	at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:213)
    	at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:185)
    	at jdk.nashorn.internal.runtime.ECMAErrors.typeError(ECMAErrors.java:172)
    	at jdk.nashorn.internal.runtime.Undefined.lookup(Undefined.java:102)
    	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:106)
    	at jdk.nashorn.internal.runtime.linker.NashornLinker.getGuardedInvocation(NashornLinker.java:98)
    	at jdk.internal.dynalink.support.CompositeTypeBasedGuardingDynamicLinker.getGuardedInvocation(CompositeTypeBasedGuardingDynamicLinker.java:176)
    	at jdk.internal.dynalink.support.CompositeGuardingDynamicLinker.getGuardedInvocation(CompositeGuardingDynamicLinker.java:124)
    	at jdk.internal.dynalink.support.LinkerServicesImpl.getGuardedInvocation(LinkerServicesImpl.java:154)
    	at jdk.internal.dynalink.DynamicLinker.relink(DynamicLinker.java:253)
    	at jdk.nashorn.internal.scripts.Script$132$\^eval\_.:program(<eval>:14)
    	at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:637)
    	at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:494)
    	at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:393)
    	at jdk.nashorn.api.scripting.NashornScriptEngine.evalImpl(NashornScriptEngine.java:446)
    

    My script is as follows:

    var myImports = new JavaImporter(java.io, java.lang, java.util);
    
    with(myImports) {
      
      var valveStatus = mcApi.variable().get("Timer-Garden-Schedule-Front-Status");
    
      //Check already running?
      if(valveStatus.value !== 'running'){
        //Update as running
        valveStatus.value = "running";
        mcApi.variable().update(valveStatus);
        mcApi.logger().debug("valve-control script triggered...");
        
        var masterValve = mcApi.uidTag().getByUid("GardenFront-Maser").getSensorVariable();
        var valve01 = mcApi.uidTag().getByUid("GardenFront-Driveway-Bottom-Front").getSensorVariable();
        var valve02 = mcApi.uidTag().getByUid("GardenFront-Driveway-Bottom-Back").getSensorVariable();
        var valve03 = mcApi.uidTag().getByUid("GardenFront-Driveway-Top-Front").getSensorVariable();
        var valve04 = mcApi.uidTag().getByUid("GardenFront-Driveway-Top-Back").getSensorVariable();
        var valve05 = mcApi.uidTag().getByUid("GardenFront-FrontHouse").getSensorVariable();
        var valve06 = mcApi.uidTag().getByUid("GardenFront-Side").getSensorVariable();
        var valve07 = mcApi.uidTag().getByUid("GardenFront-Driveway-Trees").getSensorVariable();
        var valve08 = mcApi.uidTag().getByUid("GardenFront-NatureStrip-Trees").getSensorVariable();
    
          
        var delayTime = 1000 * 60 * 15; //15 minutes
      
        //Turn ON master valve and Valve01
        masterValve.value = "1"; //Update master valve ON state
        mcApi.sensor().sendPayload(masterValve); //send state
        valve01.value = "1"; //Update valve01 ON state
        mcApi.sensor().sendPayload(valve01); //send state
          
        //Update valve01 is running
        valveStatus.value2 = "valve01";
        mcApi.variable().update(valveStatus);
      
      
        //Wait time
        Thread.sleep(delayTime);
      
        //Turn OFF valve01 and turn ON valve02
        valve01.value = "0"; //Update valve01 OFF state
        mcApi.sensor().sendPayload(valve01); //send state
        valve02.value = "1"; //Update valve02 ON state
        mcApi.sensor().sendPayload(valve02); //send state
        
        //Update valve02 is running
        valveStatus.value2 = "valve02";
        mcApi.variable().update(valveStatus);
        
        //Wait time
        Thread.sleep(delayTime);
      
        //Turn OFF valve02 and turn ON valve03
        valve02.value = "0"; //Update valve02 OFF state
        mcApi.sensor().sendPayload(valve02); //send state
        valve03.value = "1"; //Update valve03 ON state
        mcApi.sensor().sendPayload(valve03); //send state
      
        //Update valve03 is running
        valveStatus.value2 = "valve03";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
        //Turn OFF valve03 and turn ON valve04
        valve03.value = "0"; //Update valve03 OFF state
        mcApi.sensor().sendPayload(valve03); //send state
        valve04.value = "1"; //Update valve04 ON state
        mcApi.sensor().sendPayload(valve04); //send state
      
        //Update valve04 is running
        valveStatus.value2 = "valve04";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve04 and turn ON valve05
        valve04.value = "0"; //Update valve04 OFF state
        mcApi.sensor().sendPayload(valve04); //send state
        valve05.value = "1"; //Update valve05 ON state
        mcApi.sensor().sendPayload(valve05); //send state
      
        //Update valve05 is running
        valveStatus.value2 = "valve05";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve05 and turn ON valve06
        valve05.value = "0"; //Update valve05 OFF state
        mcApi.sensor().sendPayload(valve05); //send state
        valve06.value = "1"; //Update valve06 ON state
        mcApi.sensor().sendPayload(valve06); //send state
      
        //Update valve06 is running
        valveStatus.value2 = "valve06";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve06 and turn ON valve07
        valve06.value = "0"; //Update valve06 OFF state
        mcApi.sensor().sendPayload(valve06); //send state
        valve07.value = "1"; //Update valve07 ON state
        mcApi.sensor().sendPayload(valve07); //send state
      
        //Update valve07 is running
        valveStatus.value2 = "valve07";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve07 and turn ON valve08
        valve07.value = "0"; //Update valve07 OFF state
        mcApi.sensor().sendPayload(valve07); //send state
        valve08.value = "1"; //Update valve08 ON state
        mcApi.sensor().sendPayload(valve08); //send state
      
        //Update valve08 is running
        valveStatus.value2 = "valve08";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
        //Turn OFF valve08 and turn OFF master valve
        valve08.value = "0"; //Update valve08 OFF state
        mcApi.sensor().sendPayload(valve08); //send state
        masterValve.value = "0"; //Update master valve OFF state
        mcApi.sensor().sendPayload(masterValve); //send state
        
        //Update not running
        valveStatus.value = "stopped";
        valveStatus.value2 = "-";
        mcApi.variable().update(valveStatus);
        mcApi.logger().debug("valve-control script completted...");
      }else{
        mcApi.logger().warn("valve-control script is already running...");
      }
    }
    

    Any pointers on getting this to function again? (This has been working ok for the past year or so with no problems)

    All the best and thank in advance.

    Gouds



  • @gouds The function getSensorVariable() is deprecated and removed.

    mcApi.uidTag().getByUid("GardenFront-Maser").getSensorVariable();
    

    You have to change this function as getResource().

    Your script should be looking as follows,

    var myImports = new JavaImporter(java.io, java.lang, java.util);
    
    with(myImports) {
      
      var valveStatus = mcApi.variable().get("Timer-Garden-Schedule-Front-Status");
    
      //Check already running?
      if(valveStatus.value !== 'running'){
        //Update as running
        valveStatus.value = "running";
        mcApi.variable().update(valveStatus);
        mcApi.logger().debug("valve-control script triggered...");
        
        var masterValve = mcApi.uidTag().getByUid("GardenFront-Maser").getResource();
        var valve01 = mcApi.uidTag().getByUid("GardenFront-Driveway-Bottom-Front").getResource();
        var valve02 = mcApi.uidTag().getByUid("GardenFront-Driveway-Bottom-Back").getResource();
        var valve03 = mcApi.uidTag().getByUid("GardenFront-Driveway-Top-Front").getResource();
        var valve04 = mcApi.uidTag().getByUid("GardenFront-Driveway-Top-Back").getResource();
        var valve05 = mcApi.uidTag().getByUid("GardenFront-FrontHouse").getResource();
        var valve06 = mcApi.uidTag().getByUid("GardenFront-Side").getResource();
        var valve07 = mcApi.uidTag().getByUid("GardenFront-Driveway-Trees").getResource();
        var valve08 = mcApi.uidTag().getByUid("GardenFront-NatureStrip-Trees").getResource();
    
          
        var delayTime = 1000 * 60 * 15; //15 minutes
      
        //Turn ON master valve and Valve01
        masterValve.value = "1"; //Update master valve ON state
        mcApi.sensor().sendPayload(masterValve); //send state
        valve01.value = "1"; //Update valve01 ON state
        mcApi.sensor().sendPayload(valve01); //send state
          
        //Update valve01 is running
        valveStatus.value2 = "valve01";
        mcApi.variable().update(valveStatus);
      
      
        //Wait time
        Thread.sleep(delayTime);
      
        //Turn OFF valve01 and turn ON valve02
        valve01.value = "0"; //Update valve01 OFF state
        mcApi.sensor().sendPayload(valve01); //send state
        valve02.value = "1"; //Update valve02 ON state
        mcApi.sensor().sendPayload(valve02); //send state
        
        //Update valve02 is running
        valveStatus.value2 = "valve02";
        mcApi.variable().update(valveStatus);
        
        //Wait time
        Thread.sleep(delayTime);
      
        //Turn OFF valve02 and turn ON valve03
        valve02.value = "0"; //Update valve02 OFF state
        mcApi.sensor().sendPayload(valve02); //send state
        valve03.value = "1"; //Update valve03 ON state
        mcApi.sensor().sendPayload(valve03); //send state
      
        //Update valve03 is running
        valveStatus.value2 = "valve03";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
        //Turn OFF valve03 and turn ON valve04
        valve03.value = "0"; //Update valve03 OFF state
        mcApi.sensor().sendPayload(valve03); //send state
        valve04.value = "1"; //Update valve04 ON state
        mcApi.sensor().sendPayload(valve04); //send state
      
        //Update valve04 is running
        valveStatus.value2 = "valve04";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve04 and turn ON valve05
        valve04.value = "0"; //Update valve04 OFF state
        mcApi.sensor().sendPayload(valve04); //send state
        valve05.value = "1"; //Update valve05 ON state
        mcApi.sensor().sendPayload(valve05); //send state
      
        //Update valve05 is running
        valveStatus.value2 = "valve05";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve05 and turn ON valve06
        valve05.value = "0"; //Update valve05 OFF state
        mcApi.sensor().sendPayload(valve05); //send state
        valve06.value = "1"; //Update valve06 ON state
        mcApi.sensor().sendPayload(valve06); //send state
      
        //Update valve06 is running
        valveStatus.value2 = "valve06";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve06 and turn ON valve07
        valve06.value = "0"; //Update valve06 OFF state
        mcApi.sensor().sendPayload(valve06); //send state
        valve07.value = "1"; //Update valve07 ON state
        mcApi.sensor().sendPayload(valve07); //send state
      
        //Update valve07 is running
        valveStatus.value2 = "valve07";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
    
        //Turn OFF valve07 and turn ON valve08
        valve07.value = "0"; //Update valve07 OFF state
        mcApi.sensor().sendPayload(valve07); //send state
        valve08.value = "1"; //Update valve08 ON state
        mcApi.sensor().sendPayload(valve08); //send state
      
        //Update valve08 is running
        valveStatus.value2 = "valve08";
        mcApi.variable().update(valveStatus);
      
        //Wait time
        Thread.sleep(delayTime);
    
        //Turn OFF valve08 and turn OFF master valve
        valve08.value = "0"; //Update valve08 OFF state
        mcApi.sensor().sendPayload(valve08); //send state
        masterValve.value = "0"; //Update master valve OFF state
        mcApi.sensor().sendPayload(masterValve); //send state
        
        //Update not running
        valveStatus.value = "stopped";
        valveStatus.value2 = "-";
        mcApi.variable().update(valveStatus);
        mcApi.logger().debug("valve-control script completted...");
      }else{
        mcApi.logger().warn("valve-control script is already running...");
      }
    }
    


  • @jkandasa Thanks for your prompt reply. This seems to have corrected the issue that i was experiencing.

    Thanks once again.

    Cheers

    Gouds


 

Suggested Topics

15
Online

407
Users

371
Topics

2.3k
Posts