Announcement

Collapse
No announcement yet.

Help using &hs.GetURLIE immediate script command

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

  • DMT
    replied
    Solved

    Thank you ever so much mrhappy !!!

    Both your solutions work 100% without modification, no log errors whatsoever

    &hs.GetURL - works

    httpWebRequest script - works and logs the response from the webserver switch (example off)
    p61=0
    OK

    I must have done something wrong before with &hs.GetURL

    Very much appreciate your guidance. Thanks again.

    Leave a comment:


  • mrhappy
    replied
    Suprised the geturl does not work but not having the hardware to test with makes things quite difficult, the same with any other script. Does

    &hs.GetURL("http://192.168.2.10/set.cmd?user=admin+pass=password+cmd=setpower+p61=1","",TRUE ,80)

    Work out of interest? Does it also put any errors in the HS log?

    In response to the question about using httpWebRequest then this would be a start (which is a straight lift from MSDN https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx just adapted to HS).

    Code:
    Imports System.Net
    Imports System.Text
    Imports System.IO
    
    Sub Main(ByVal Parms As Object)
    
        Try
            ' Create a request for the URL. 
            Dim request As WebRequest = WebRequest.Create("http://192.168.2.10:80/set.cmd?user=admin+pass=password+cmd=setpower+p61=0")
            ' If required by the server, set the credentials.
            request.Credentials = CredentialCache.DefaultCredentials
            ' Get the response.
            Dim response As WebResponse = request.GetResponse()
            ' Display the status.
            hs.writelog("", CType(response, HttpWebResponse).StatusDescription)
            ' Get the stream containing content returned by the server.
            Dim dataStream As Stream = response.GetResponseStream()
            ' Open the stream using a StreamReader for easy access.
            Dim reader As New StreamReader(dataStream)
            ' Read the content.
            Dim responseFromServer As String = reader.ReadToEnd()
            ' Display the content.
            hs.writelog("", responseFromServer)
            ' Clean up the streams and the response.
            reader.Close()
            response.Close()
        Catch ex As Exception : hs.writelog("", "Exception: " & ex.message)
        End Try
    
    End Sub

    Leave a comment:


  • DMT
    replied
    httpWebRequest

    I am still trying to solve a problem with hs.GetURLIE

    This simple script turns a web switch on or off by changing the p61= parameter. It works fine for a bit then productes an ActiveX error in the log and won't work again until a reboot.

    Sub Main()
    Dim Page

    Page = hs.GetURLIE("http://192.168.2.10:80/set.cmd?user=admin+pass=pass+cmd=setpower+p61=0",TRUE)

    End Sub

    HomeSeer support said this appears to be a bug in HS3 and in the meantime I could "use native .net calls to do the same thing. Check out the httpWebRequest .net class.".

    One earlier suggestion was to try hs.GetURL however that doesn't work at all. I have to admit I am very new to this and have no idea how to create a script using httpWebRequest.

    Any guidance would be appreciated while I continue to research and learn.

    HomeSeer HS3 3.0.0.208
    Windows 10 Pro Version 1511

    Many thanks.

    Leave a comment:


  • DMT
    replied
    Thanks for your help. I tried GetURL in various forms and while I can get a version not to produce any log errors, nothing I tried will actually operate the switch. Only the GetURLIE command works.

    Regards

    Leave a comment:


  • mrhappy
    replied
    hs.geturlie uses/used Internet Explorer and has been a HS command for some time (I think the intention was that IE rendered some pages rather than just try and get all of the raw data), being as though you use Windows 10 (and it is now Edge) I wonder if this is a bug that has not come up before. Wikipedia even says "In 2015, Microsoft Edge, the replacement for Internet Explorer, dropped ActiveX support, marking the end of the technology" so it may be that it can't create the component because Edge no longer supports it. Try instead:

    &hs.GetURL("http://192.168.2.10","/set.cmd?user=admin+pass=password+cmd=setpower+p61=1",TRUE,80 )

    Leave a comment:


  • DMT
    started a topic Help using &hs.GetURLIE immediate script command

    Help using &hs.GetURLIE immediate script command

    Hi, new to HomeSeer, really enjoying so far. My Z-Wave devices are working extremely well.

    I have an IP power switch with 4 relays on my LAN that can be controlled as follows:
    ON (Relay1)
    http://192.168.2.10:80/set.cmd?user=admin+pass=password+cmd=setpower+p61=1
    OFF (Relay1)
    http://192.168.2.10:80/set.cmd?user=admin+pass=password+cmd=setpower+p61=0
Working...
X