How to setup Grandstream GDS3710/3705 to Open Door via Homeseer home automation?

The Grandstream GDS3710/3705 SIP Intercom comes with a door/gate open feature via wired comms to your gate or door latch system. It also comes with a HTTP API that can be called where direct access to the GDS unit is available (whether on private network or public network through port forwarding)

Homeseer is an established smart home automation solution allowing comprehensive control of devices throughout your office or home through inbuilt features, plugins and scripting. See https://homeseer.com/

Below is a script that can be used as a triggered action for an event to open your door/gate via API. Note this is an alternative method to the more advanced Keep Door Open API command as referenced in our other FAQ entry here which can be used to set a timer to keep the door open from 5 to 480 minutes.

The Enable HTTP API Remote Open Door setting must be enabled on your GDS Admin Settings for this script to work.

The script is written in vb.net (Homeseer scripting language) and must be deployed in your Homeseer deployment custom scripts directory. In a Linux deployment of Homeseer this directory is /usr/local/HomeSeer/scripts/. The file should be named with a .vb extension e.g. opengate.vb

Once saved you can create an event that executes this script when triggered. I suggest that you create an Event that is manually triggered that can then be triggered as an action of any other Event e.g. Geofence triggered action when you arrive home or voice command "Open Gate"

Change sServer, sPin and sAdminPassword to your values

  • sServer is the server name in url format with port as necessay e.g. https://192.168.1.100 or https://dynamicdns.host:1234
  • sPin is the Remote PIN to Open the Door as set in the GDS Admin Settings
  • sAdminPassword is the password for the admin user to your GDS Admin GUI.

 

Credits to @zwolfpack for the MD5 function and to this thread on the Homeseer forum for assistance in generating this script

 

Sub Main(p AS object)

Dim sResCode AS String 
Dim sRetMsg AS String 
Dim sChallengeCode AS String 
Dim sIDCode AS String 
Dim GateXMLDoc As New System.XML.XmlDocument()
Dim sServer As String = "http://192.168.1.100"
Dim sPIN As String = "1234"
Dim sAdminPassword As String = "AdminPassword1234"
Dim sURL As String = ""

Try
	Dim sAuthQuery As String = "/goform/apicmd?cmd=0&user=admin"
	sURL=sServer+sAuthQuery
	'hs.writelog("Gate Auth: URL", sURL)
	
	GateXMLDoc.Load(sURL)

	sResCode = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/ResCode").InnerText
	'hs.writelog("Gate Auth: Result", sResCode)

	If sResCode=0 Then
		sChallengeCode = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/ChallengeCode").InnerText
		'hs.writelog("Gate: Challenge Code", sChallengeCode)

		sIDCode = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/IDCode").InnerText
		'hs.writelog("Gate: ID Code", sIDCode)

		Dim sAuthCode AS String = sChallengeCode + ":" + sPIN +":" + sAdminPassword
		'hs.WriteLog("Gate: Auth Code", sAuthCode)

		Dim sAuthCodeMD5 AS String = md5sum(sAuthCode)
		'hs.WriteLog("Gate: Auth Code MD5", sAuthCodeMD5)
		
		Dim sOpenQuery AS String = "/goform/apicmd?cmd=1&user=admin&authcode=" + sAuthCodeMD5 + "&idcode=" + sIDCode + "&type=1"
		sURL=sServer+sOpenQuery
		'hs.writelog("Gate Auth: URL", sURL)

		GateXMLDoc.Load(sURL)
		
		sResCode = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/ResCode").InnerText
		'hs.writelog("Gate Open: Result", sResCode)
		If sResCode=0 Then
			hs.writelog("Gate Open: Success", sResCode)
		Else
			sRetMsg = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/RetMsg").InnerText
			hs.writelog("Gate Open: Return Message", sRetMsg)
		End If
	Else
		sRetMsg = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/RetMsg").InnerText
		hs.writelog("Gate Auth: Falied", sRetMsg)
	End If

Catch ex As Exception

	hs.WriteLog ("Gate: XML Error", ex.Message)

End Try

End Sub

Function md5sum(ByVal strToHash As String) As String

	Dim md5Obj As New Security.Cryptography.MD5CryptoServiceProvider
	Dim bytesToHash() As Byte = System.Text.Encoding.ASCII.GetBytes(strToHash)

	bytesToHash = md5Obj.ComputeHash(bytesToHash)

	Dim strResult As String = ""

	For Each b As Byte In bytesToHash
		strResult += b.ToString("x2")
	Next

	Return strResult

End Function
  • 80 Users Found This Useful
Was this answer helpful?

Related Articles

How to use Microsip for Windows with my Call Plan

We recommend Microsip as a comprehensive, lightweight and free SIP client for Windows based...

What Port do I use?

We prefer that you don't specify a port. If your client offers a setting to "Use DNS SRV" then...

How to use Bria Mobile for iOS with my Call Plan?

Bria Mobile is an excellent app for your Apple iPhone that can be used with Irish VoIP to make...

Sample Solution for Medical Practice

Scenario below is hypothetical to give an idea of a potential solution provided by Irish VoIP to...

Sample Solution for Medium Sized Office

Scenario below is hypothetical to give an idea of a potential solution provided by Irish VoIP to...