No announcement yet.

Need help with some scripting

  • 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!


    Hi Brad,

    Would this do what you need:

    Here's an example of a script as well:

    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 = ""  
    	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
    	MyNodeList = MyRSS.SelectNodes("*/*")
    	For Each MyNode In MyNodeList
    		Title = ""
    			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
    	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.SetDeviceString(1536, Title, True)
    			hs.SetDeviceValueByRef(1536, 1, True)
    			hs.SetDeviceString(1537, Summary, True)
    			hs.SetDeviceValueByRef(1537, 1, True)
    		End If
    		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
    HS 1990 Devices 1172 Events
    Z-Wave 126 Nodes on one Z-Net


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

      Thank you!!