Announcement

Collapse
No announcement yet.

Remotely logging HS2 sensor data with Python

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

  • Remotely logging HS2 sensor data with Python

    I have an Everspring ST814 device (Temp & humidity) I wanted to get the humidity and temp data out of HS2pro to overlay into Blue Iris. I didn't see a clear way to extract that data from HS2 remotely so I wrote a Python script to pull it remotely.

    I usde BeautifulSoup python library to parse the html, but other than that it's pretty straight forward and doesn't require running on your HS2 server.

    Have fun, and I'm guessing I'll have to redo this when I move to HS3Pro

    Code:
     
    import requests
    from bs4 import BeautifulSoup
    # Grab your URL
    r = requests.get("http://your.homeseer.server/stat?location=yourspecificpage")
    temp = r.content
    
    # Get content into BeautifulSoup
    soup = BeautifulSoup(temp)
    
    # Grab your specific content, in this case it's the cell with temp and humidity from the Everspring ST814-2
    # I used Chrome's inpsect element function to find this in HS2's html....right click in the section
    line_temp = soup.find(id="dv_Status6090")
    line_hum  = soup.find(id="dv_Status3869")
    
    ##print(soup.prettify())
    ##line.encode('ascii','ignore')
    # Break the specific string up and get just the data
    field = line_temp.contents
    tempurature = field[2]
    tempurature = tempurature.encode('ascii','ignore')
    #print tempurature
    
    # Break the specific string up and get just the data
    field = line_hum.contents
    humidity = field[2]
    humidity = humidity.encode('ascii','ignore')
    #print humidity
    
    # Remove white space from cell variable
    print("\r")
    tempurature = tempurature.replace(" ", "")
    humidity = humidity.replace(" ", "")
    
    #Print out to file for BlueIris to pickup
    f = open('//your/personal/path/temp.txt', 'w')
    f.write(tempurature)
    f.close()
    
    #Print out to file for BlueIris to pickup
    f = open('//your/personal/path/hum.txt', 'w')
    f.write(humidity)
    f.close()
Working...
X