Author Topic: i need a sinple way to send http commands to our home automation server  (Read 1524 times)

Madmax

  • Newbie
  • *
  • Posts: 4
    • View Profile
hi guys

im in need of an easy way to send a hand full of simple one line http commands to our home automation z-wave hub/server on our local home network..

im quite new to .net programming, ive tried a few options I have found over the net but i dont really know how to correctly enter the various examples iv found, and i generally end up with multiple errors

all the commands are doing are turning on or off switches etc that are connected to the controller hub, there is no need to open a page or any thing like that, just need to send the various commands over the local home network

example of a command:
http://192.168.1.104:3480/data_request?id=lu_action&output_format=json&DeviceNum=18&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1

ive seen the generictcpclient option posted on this forum but again i get a bit lost getting the code in the right places...

any help would be greatly apprieciated

cheers Matt


dmroeder

  • Administrator
  • Full Member
  • *****
  • Posts: 212
    • View Profile
Re: i need a sinple way to send http commands to our home automation server
« Reply #1 on: January 10, 2019, 11:07:16 AM »
I'm no expert on sending web requests, but this worked on a system that I have access to.  In the example below, I created a brand new blank project, added a button to the form.  Try this:

Code: [Select]
Imports System.Net
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim url As String = "http://192.168.1.104:3480/data_request?id=lu_action&output_format=json&DeviceNum=18&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1"
        Using client As New WebClient
            Dim result = client.DownloadString(url)
            MessageBox.Show(result)
        End Using
    End Sub
End Class

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: i need a sinple way to send http commands to our home automation server
« Reply #2 on: January 10, 2019, 11:22:30 AM »
Here is another method:
Code: [Select]
       Dim request As Net.HttpWebRequest = Net.WebRequest.Create("http://192.168.1.104:3480/data_request?id=lu_action&output_format=json&DeviceNum=18&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1")
        Dim response As Net.HttpWebResponse = request.GetResponse()
        Dim responseString As String
        Using sr As New System.IO.StreamReader(response.GetResponseStream())
            responseString = sr.ReadToEnd()
        End Using

Madmax

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: i need a sinple way to send http commands to our home automation server
« Reply #3 on: January 11, 2019, 03:29:57 AM »
Spot on guys, works a treat..... cheers...

and by the way Archie, thanks for the great bit of software...now hopefully i can convince the AB loving PLC tech at work that this software is easier to use and build with, and as good as if not better than the applications we are using now.....

thanks again
Matt

larryhts

  • Jr. Member
  • **
  • Posts: 98
    • View Profile
Re: i need a sinple way to send http commands to our home automation server
« Reply #4 on: January 11, 2019, 07:01:13 AM »
Spot on guys, works a treat..... cheers...

and by the way Archie, thanks for the great bit of software...now hopefully i can convince the AB loving PLC tech at work that this software is easier to use and build with, and as good as if not better than the applications we are using now.....

thanks again
Matt

Madmax,   I am one of the old AB guys and have been looking for years to find a better way. I think Archie's drivers are the best. I have convinced my company away from AB's high cost. Check out AutomationDirect's Productivity series PLC's they are more powerful then the AB and only a fraction of the cost. The software is free and the support is better. I have two of Archie's 10 inch panels both are talking to 2 PLC one AB and one  P2-250. All are working very well and with the AdvancedHMI software I can scan a barcode pass it to the Database and get a valid or invalid with in 1 sec. Lot of people on here to help with anything. Better support than AB. Good Luck.

Phrog30

  • Guest
Re: i need a sinple way to send http commands to our home automation server
« Reply #5 on: January 11, 2019, 01:14:46 PM »
While I like the productivity stuff, they aren't more powerful than the Logix line of processors. Once they add AOIs then maybe you will have a case.