No announcement yet.

Import data from CAI WebControl WC8 into a HS4 Virtual Device

  • Filter
  • Time
  • Show
Clear All
new posts

    Import data from CAI WebControl WC8 into a HS4 Virtual Device

    I am very new to Homeseer HS4 and learning how many of the features work and I am stalled on the challenge of getting some external data into Homeseer.

    I have a CAI WebControl PLC WC8 that I use to monitor around the house. The challenge is to get the monitored local outside temperature from the WC8 into Homeseer so I can use the true local temperature in my events. Storing the WC8 output in a Virtual Device on HS4 is my objective.

    The WC8 has internal programming capability and to reduce the instability of real time temperature variability, the internal program takes multiple readings over five minutes and averages them. The WC8 web interface has the ability to push the result out to another system with its internal REST capability and programming options. I think this interface was manly developed to service the Universal Devices ISY controller, but I was hoping to use the same to push the average temperature to Homeseer as well.

    The internal tool to output the data, specifies the IP and port of the destination system, the path for REST GET URL and the authentication required to access that system... the command to send the data is part of the PLC Program and is programmatically set to send every 5 minutes. The example given for the REST GET path is GET URL example: /api/setvar.cgi?varid=2&value=​ ... in the case of what I do with the ISY that setting is /rest/vars/set/2/1. The latter ISY setting is obviously designed to work with the ISY file structure, if possible, I would like to know if there is an equivalent for HS4 when the destination is a Virtual Device?

    In doing some additional digging today, I found that I can use a URL command to pull the data from the WC8. So will return the raw temperature value from the WC8 and will return the value for the 5 minute average. So, this is a good option and while I am not familiar with how to use the hs.getURLAction, that should allow me to pull the raw data in Homeseer with a simple script... I will have to play with that.

    Just curious if anyone has attempted the same and what they would recommend as the best method. Thank you in advance. I am running HS4 Standard Linux on Raspberry Pi4

    I experimented/explored a few options and ended up wiggling my way through my first script to accomplish this task. It might not be the cleanest, but for now it works and for anyone that might want to do the same, I have shared the vb script below:

    Sub Main(ByVal Parm As Object)
    Imports System.Text

    Const host As String = "IP_for_the CAI_WC8"
    ' The next line retrieves the VAR1 variable, but there are other items that can be retrieved from the CAI WC8
    Const page As String = "getvar1.cgi"
    Const user As String = "WC8_UserName"
    Const pass As String = "WC8_PassWord"

    Dim auth As String = user & ":" & pass
    Dim autha As Byte() = System.Text.ASCIIEncoding.ASCII.GetBytes(auth)

    Dim headers As String = "Authorization: Basic " & System.Convert.ToBase64String(autha)
    Dim url As String = String.Format("http://{0}/{1}", host, page)

    Dim s As String = hs.URLAction(url, "GET", "", headers)
    ' The next line stores the output in the Virtual Device ID=78
    hs.SetDeviceValueByRef(78, s, True)

    End Sub​