Scene Pre/post-scripting not working

  • 90 Views
  • Last Post 11 March 2013
MadSci posted this 28 February 2013

Using the email script. Works fine if it is used directly as a rule but not if it is part of a scene. The device changes in the scene work fine. Test emails also work fine. Any ideas? Am I using this feature wrong?

Order By: Standard | Newest | Votes
Ryan-Scott posted this 03 March 2013

Using the email script. Works fine if it is used directly as a rule but not if it is part of a scene. The device changes in the scene work fine. Test emails also work fine. Any ideas? Am I using this feature wrong?


See any errors in your logs by chance? I've got an email script that looks like this in a scene and it works great:


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

///
/// This script will send an email when a node is at a level higher than 0.
///
/// ALWAYS MAKE COPIES OF SCRIPTS YOU INTEND TO CUSTOMIZE OR YOUR CHANGES
/// COULD BE LOST.
///

public class SendEmailWhenActive : ScriptBase, ScriptInterface {

public void runScript() {
try {

sendEmail("Lights off", "Light off");

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

MadSci posted this 07 March 2013

Thanks. Your script worked. The problem is that I don't quite understand what's going on in some of these scripts, haha. I was using the email script which emails device state. That script works fine as a "on device state change" rule script but not in the scene scripts. Looking at it now, I can see that if there is no device ID passed to this script, no email will occur.

Thanks again.

PS - I still can't get a script to run a shortcut file (.lnk), just as if you would click on it. I have shortcut that records video of the IP camera to the folder location where the .lnk is by running VLC with cmd line options.

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

public class Recordxmin : ScriptBase, ScriptInterface {

///


/// ALWAYS MAKE COPIES OF SCRIPTS YOU INTEND TO CUSTOMIZE OR YOUR CHANGES
/// COULD BE LOST.
///

public void runScript() {
try {
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.FileName = @"D:\IPCam Rec\Foscam\VLC_Record.lnk";
System.Diagnostics.Process.Start(psi);

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

Ryan-Scott posted this 08 March 2013

Thanks. Your script worked. The problem is that I don't quite understand what's going on in some of these scripts, haha. I was using the email script which emails device state. That script works fine as a "on device state change" rule script but not in the scene scripts. Looking at it now, I can see that if there is no device ID passed to this script, no email will occur.

Thanks again.

PS - I still can't get a script to run a shortcut file (.lnk), just as if you would click on it. I have shortcut that records video of the IP camera to the folder location where the .lnk is by running VLC with cmd line options.


Here's a video that I made showing how to setup a scene to run VLC and record a video.

MadSci posted this 08 March 2013

You're the man, Ryan. Thanks for adding that.

I DL 2.211 (RC) but I don't see the new script file. Is there a newer version with the FoscamRecord.cs file included? I do have my other scripts in that scripts folder, if that causes any installation issues.

MadSci posted this 08 March 2013

You're the man, Ryan. Thanks for adding that.

I DL 2.211 (RC) but I don't see the new script file. Is there a newer version with the FoscamRecord.cs file included? I do have my other scripts in that scripts folder, if that causes any installation issues.

Ryan-Scott posted this 08 March 2013

You're the man, Ryan. Thanks for adding that.

I DL 2.211 (RC) but I don't see the new script file. Is there a newer version with the FoscamRecord.cs file included? I do have my other scripts in that scripts folder, if that causes any installation issues.


Download it from the main site: http://www.incontrolzwave.com/page/Download.aspx

MadSci posted this 08 March 2013

Ah crap. Set it up and nothing happens. The logfile shows the command executed (the syntax and parameters look correct) but I get no VLC cone in the task bar indicating it's running and no .asf file. Considering my other trouble executing the shortcut and also trying to write my own VLC record command, I'm wondering if there a permission issue or something else which is preventing InControl from executing these commands. Any ideas?

Ryan-Scott posted this 08 March 2013

Ah crap. Set it up and nothing happens. The logfile shows the command executed (the syntax and parameters look correct) but I get no VLC cone in the task bar indicating it's running and no .asf file. Considering my other trouble executing the shortcut and also trying to write my own VLC record command, I'm wondering if there a permission issue or something else which is preventing InControl from executing these commands. Any ideas?



Perhaps... are you running it as a service?

MadSci posted this 08 March 2013

Yeah, I'm running InControl as a service. This is on Windows 8 but I was having trouble in W7 too.

Ryan-Scott posted this 11 March 2013

Ah crap. Set it up and nothing happens. The logfile shows the command executed (the syntax and parameters look correct) but I get no VLC cone in the task bar indicating it's running and no .asf file. Considering my other trouble executing the shortcut and also trying to write my own VLC record command, I'm wondering if there a permission issue or something else which is preventing InControl from executing these commands. Any ideas?



What happens if you manually execute the same command that you see dumped to the logfile.txt? Does it work then?

MadSci posted this 11 March 2013

By manually, do you mean taking the command from the log file and executing it from the command prompt? If so, I'll give that a try tonight. I know it works by pasting the command into a shortcut (.lnk) file and running it that way.

Ryan-Scott posted this 11 March 2013

By manually, do you mean taking the command from the log file and executing it from the command prompt? If so, I'll give that a try tonight. I know it works by pasting the command into a shortcut (.lnk) file and running it that way.


Yes, that's what I meant... open a CMD, copy/paste what you see in logfile.txt and see if it works. Let me know.

MadSci posted this 11 March 2013

This is what is in the logfile:

CamRecord:"http://192.168.1.111:8000/videostream.asf?user=skroob&pwd=12345" --qt-start-minimized --no-qt-notification --run-time=10 :sout=#duplicate{dst=file{dst=F:\Google Drive\Foscam\2013-03-10-12-09-38.asf}} vlc://quit

Running as is in the command prompt, i get, "The system cannot find the file path specified."

This is what is in my shortcut file, which works:

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" http://192.168.1.111:8000/videostream.asf?user=skroob&pwd=12345 --qt-start-minimized --no-qt-notification --run-time=15 :demux=dump :demuxdump-file=F://MyCamera1_test.asf --demuxdump-append vlc://quit



Ryan-Scott posted this 11 March 2013

This is what is in the logfile:

CamRecord:"http://192.168.1.111:8000/videostream.asf?user=skroob&pwd=12345" --qt-start-minimized --no-qt-notification --run-time=10 :sout=#duplicate{dst=file{dst=F:\Google Drive\Foscam\2013-03-10-12-09-38.asf}} vlc://quit

Running as is in the command prompt, i get, "The system cannot find the file path specified."

This is what is in my shortcut file, which works:

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" http://192.168.1.111:8000/videostream.asf?user=skroob&pwd=12345 --qt-start-minimized --no-qt-notification --run-time=15 :demux=dump :demuxdump-file=F://MyCamera1_test.asf --demuxdump-append vlc://quit





The stuff that gets dumped is only the parameters, so you'd need to pre-pend the path to vlc in front of it.

"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" "http://192.168.1.111:8000/videostream.asf?user=skroob&pwd=12345" --qt-start-minimized --no-qt-notification --run-time=10 :sout=#duplicate{dst=file{dst=F:\Google Drive\Foscam\2013-03-10-12-09-38.asf}} vlc://quit

Close