First time scripter need s help

  • 407 Views
  • Last Post 24 January 2015
blindman75 posted this 24 January 2015

I know this has got to be simple. I'm just trying to get a light to turn off after a certain time using the built in script "LightsOffAfter10Minutes"

I put in the Object Provider ID "26" in the () on line 20 and get an error.

using System;
using System.Collections.Generic;
using System.Text;
using MLS.ZWave.Service.Rules;
using MLS.ZWave.BusinessObjects;


public class LightsOffAfter10Minutes : ScriptBase, ScriptInterface {

///


/// This script looks for any light supplied in the NodeIds list that has been on for more than 10 minutes and shuts it off.
///
/// ALWAYS MAKE COPIES OF SCRIPTS YOU INTEND TO CUSTOMIZE OR YOUR CHANGES
/// COULD BE LOST.
///

public void runScript() {
try {

// Get all the devices specified in the above list
var devices = getNodes(26);

// Loop through all the nodes
foreach (var d in devices) {
if (d.stateTracker.timeSinceLastChange.TotalMinutes > 1) {
// Turn off the device by setting the level to 0
setDeviceLevel(d.deviceId, 0);
}
}

} catch (Exception ex) {
// Log the exception here
var message = ex.Message;
}
}

Logfile
1/24/2015 10:44:38 AM: Script failed to compile with error: The best overloaded method match for 'MLS.ZWave.Service.Rules.ScriptBase.getNodes(System.Collections.Generic.List)' has some invalid arguments on line 20.
1/24/2015 10:44:38 AM: Script failed to compile with error: Argument 1: cannot convert from 'int' to 'System.Collections.Generic.List' on line 20.

Can someone tell me what I'm doing wrong? Thanks


Order By: Standard | Newest | Votes
blindman75 posted this 24 January 2015

Also I'm assuming this would be a post-script. What is the difference between a pre-script and post-script. Sorry for the ignorance, I have zero programming skills.

Robert.Rosal posted this 24 January 2015

Hi Blindman,

Do you really need to use a script?

You can accomplish the same thing by adding a virtual device to your scene. I can help you with that if all you want is turn on a device for a specific amount of time.

-Robert

blindman75 posted this 24 January 2015

That would be fine. I have my outside flood lights turning On when my garage door is opened. I would just like to turn off the lights after a certain amount of time after they are triggered.

Ryan-Scott posted this 24 January 2015

That would be fine. I have my outside flood lights turning On when my garage door is opened. I would just like to turn off the lights after a certain amount of time after they are triggered.


There are a few ways you could accomplish this. Probably the simpliest would be to modify your existing scene and add a "pause" to it, then add the light in the off position. To add a pause, click on the arrow on the "Device" button.

http://www.incontrolzwave.com/page/Scene-Screen.aspx

The other option would be to use the device "auto toggle" off feature. You can find that on your main device screen. Select the device and then able the box in the right hand portion of the screen.

Close