Announcement

Collapse
No announcement yet.

Need help with some scripting

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

    Need help with some scripting

    Hey Everyone.

    I'm looking to figure out how to make a script (or another easier way) that would get a couple variables from an RSS feed from a local server and set those two variables as values for two seperate virtual devices. Was looking around for a few hours to see if someone had an example that I could figure how to work in my case, but came up with nothing.

    Wondering if anyone would be willing to help as I am very new to scripting. Im also open to other ways to get the same thing accomplished, but it would appear that scripting is the only way to go!

    Thanks in advance!

    Brad

    #2
    Hi Brad,

    Would this do what you need: http://board.homeseer.com/showthread.php?t=171405?

    Here's an example of a script as well:

    Code:
    Sub Main(ByVal Parms As object)
    
    	Dim logName = "AB Alert"						'set log type for HS log
    	Dim debug = False								'send debug info to the HS log
    	Dim NL = Chr(13) & Chr(10)						'newline character to force message split
    
    	Dim RSSURL = "http://emergencyalert.alberta.ca/aeapublic/feed.atom"  
    	Dim MyNode As XmlNode
    	Dim MyNodeList As XmlNodeList
    	Dim MyRSS As XmlDocument = New XmlDocument()
    	Dim RSSTitle As String
    	Dim Title As String = ""
    	Dim AlertTitle As String = ""
    	Dim Summary As String = ""
    	Dim count = 0
    
    	MyRSS.Load(RSSURL)
    	MyNodeList = MyRSS.SelectNodes("*/*")
    
    	For Each MyNode In MyNodeList
    		Title = ""
    		Try
    			Title = MyNode.Item("title").InnerText
    		Catch ex As Exception
    		End Try
    		If Title > "" Then
    			Count = Count + 1
    			AlertTitle = AlertTitle & " - " & Title
    			Summary = Summary & NL & NL & MyNode.Item("summary").InnerText
    		End If
    	Next
    
    	If Count > 0 Then
    		If Debug Then hs.writelog(logname,Title)
    		If Debug Then hs.writelog(logname,hs.DeviceString(1536))
    		If Debug Then hs.writelog(logname,Summary)
    		If Title <> hs.DeviceString(1536) Then
    			hs.SendEmail("testalert@domain.ca","testseer@domain.ca","","",Title,Summary,"")
    			hs.SetDeviceString(1536, Title, True)
    			hs.SetDeviceValueByRef(1536, 1, True)
    			hs.SetDeviceString(1537, Summary, True)
    			hs.SetDeviceValueByRef(1537, 1, True)
    		End If
    	Else
    		If Title <> hs.DeviceString(1536) Then
    			hs.SetDeviceString(1536, "No Alert", True)
    			hs.SetDeviceValueByRef(1536, 0, True)
    			hs.SetDeviceString(1537, "No Alert", True)
    			hs.SetDeviceValueByRef(1537, 0, True)
    		End If
    	End If
    
    
    End Sub
    Cheers
    Al
    HS 3.0.0.548: 1990 Devices 1172 Events
    Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

    Comment


      #3
      That kind of does look like something that would work for me! Let me play around with it and see what happens!

      Thank you!!

      Comment

      Working...
      X