• Categories
    • Recent
    • Tags
    • Popular
    • Register
    • Login
    1. Home
    2. gouds
    G
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 6
    • Posts 17
    • Groups 0

    gouds

    @gouds

    2
    Reputation
    747
    Profile views
    17
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    gouds Unfollow Follow

    Best posts made by gouds

    • Timers and scripts

      Hi Guys. Liking this controller 🙂 I would like to know how to add in a timer that works like the following:
      I have a bunch of Valves (On/Off)
      Would like the rule to do the below:

      Master Valve - On
      Valve01 - On (Run for 10min); then
      Valve01 - Off; then
      Valve02 - On (Run for 10min); then
      Valve02 - Off; then
      Valve03 - On (Run for 10min); then
      Valve03 - Off; then
      Master Valve - Off

      Any pointers would be a great help.

      posted in Scripts script javascript valve
      G
      gouds
    • RE: Widget - Running Sensors

      Thanks very much. This worked a treat. 🙂

      posted in General Discussion
      G
      gouds

    Latest posts made by gouds

    • RE: MyController 1.2.0.Final version released

      Hi jkandasa,
      The new build looks good. I have a small problem with the Sensor Names resetting to all the same name. '1.0' I found this was the case when updating to the new 1.2 final. I went through and updated all the sensor names and came back an hour or so later and all the sensor names had changed cack to txt '1.0'.

      Any ideas on why this would happen. Something new in the update?

      Thanks

      posted in Announcements
      G
      gouds
    • RE: MyController 1.0.0.Final version released

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

      Thanks once again.

      Cheers

      Gouds

      posted in Announcements
      G
      gouds
    • RE: MyController 1.0.0.Final version released

      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

      posted in Announcements
      G
      gouds
    • Custom Dashboard Item to Trigger JavaScript/Operations

      Hi,

      I have a JavaScript/Operations that i would like to run from the dashboard. I was thinking that a custom button that when pressed triggers the JavaScript/Operations. Currently i have a trigger that is executed on a timer but would like to be able to execute this a any time (outside of the schedule).

      Basic button that when pressed executes the JavaScript/Operation.
      Dashboard item (Custom Widget)?

      Thanks in advance

      posted in General Discussion
      G
      gouds
    • RE: Widget - Running Sensors

      Thanks very much. This worked a treat. 🙂

      posted in General Discussion
      G
      gouds
    • RE: Widget - Running Sensors

      cheers. It would be a great help.... Thanks

      posted in General Discussion
      G
      gouds
    • RE: Widget - Running Sensors

      @jkandasa List sensors that are currently 'ON'

      posted in General Discussion
      G
      gouds
    • Widget - Running Sensors

      Dashboard Item - List all running sensors. Anyone done anything? (Just a nice table to show a list)

      posted in General Discussion
      G
      gouds
    • RE: Send Email (Bug)?

      I can now confirm email from a timer works by using the new distro 🙂 Thanks

      However the below does not seem to work correctly. Does not trigger an email. (Perhaps i am doing this incorrectly)

      The 0_1482879717922_upload-cc9a90c0-decb-4b07-874f-613b5d749d2f

      posted in General Discussion
      G
      gouds
    • RE: Send Email (Bug)?

      Further more on this i have found that in a post it may not be supported using timers. I have attempted to also use a rule. Monitor a valve for Active (on) time set to 20secs (Test) then to send email. This also does not work. But... Setting the rule to just look at ==On. Triggers an email event straight away. Whats the best way to monitor all Valves and running time and send email if on for X time?

      posted in General Discussion
      G
      gouds