Announcement

Collapse
No announcement yet.

Triggering events based on device values

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Triggering events based on device values

    Hi,

    I have an event that triggers whenever a particular network device has it's value set to something less than 0. The event calls a script that records the value in a log file, but the log file contains entries with positive values as well as negative.

    Here's the script:

    Code:
    Sub main(devname)
    
    ' run whenever a nucleus network device is set to a value less than zero
    
    	devnamefull = devname & " Nucleus"
    	val = hs.GetDeviceByRef(hs.GetDeviceRefByName(devnamefull)).devvalue(hs)
    	
    	Dim fso, objfile
    
    	filepath = "C:\Program Files\HomeSeer HS3\html\logs\nucleus" & devname & ".txt"
    	Set fso = CreateObject("Scripting.FileSystemObject")
    	Set file = fso.OpenTextFile(filepath, 8,True)     '8 = appending
    
    	file.WriteLine(date & "   " & time & "   " & devname & " Nucleus value is " & val)
    
    end sub
    The only think I can think of is that the value is changing in the time between the event being triggered and the call to retrieve the device value. I suppose this is possible if the plugin is triggering a second ping as soon as the first problem ping is detected, but that isn't the likely way for you to have written the plugin (I am guessing).

    Any idea what is going on?

    Thanks in advance for your help.
Working...
X