How to setup Grandstream GDS3710/3705 to Keep Door Open 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

Below is a script that can be used as a triggered action for an event to keep your door/gate open via API. Note this is an alternative method to the simple Open API command as referenced in our other FAQ entry here which simply passes an open command and then gate closes immediately after.

Note:  you need to be able to interact with the .Net Http classes. To enable this you need to have the following line in the [Settings] block of your Homeseer settings.ini file. Homeseer will need to be restarted after changing this.


The script is written in (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. gatetimer.vb

The script expects a parameter from the Event which is the time to keep the gate open. Passing 0 will disable any active timer and close the gate. Passing a value or 5 to 480 will keep the gate open for that number of minutes.

Once saved you can create mutiple events that execute this script when triggered e.g. Disable Timer with parameter of 0 or Open Gate 1 Hour with parameter of 60. I suggest that you create these Events as manually triggered and they can then be triggered as an action of any other Event e.g. Geofence triggered action when you arrive home to Open Gate for 5 Minutes

Change sServer, sAdminPassword and sDoor to your values

  • sServer is the server name in url format with port as necessay e.g. or
  • sAdminPassword is the password for the admin user to your GDS Admin GUI.
  • sDoor is the Door to open. For door 1 set the value to "1", for door 2 set the value to "2" and for both doors set the value to "3"

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


Sub Main(ByVal sTime As String)

'**********Your Custom Values************
' GDS3710 IP Address or Hostname e.g. https:/
Dim sServer As String = ""
' GDS3710 Password for Admin User
Dim sAdminPassword As String = "Password1234"
'Door 1 = 1, Door 2 = 2, Both Doors = 3
Dim sDoor As String = "3"
'**********Your Custom Values************

'Fixed Variables
Dim sResCode AS String
Dim sRetMsg AS String
Dim sChallengeCode AS String
Dim sIDCode AS String
Dim GateXMLDoc As New System.XML.XmlDocument()
Dim handler AS New System.Net.Http.HttpClientHandler()
Dim sGSKey As String = "GDS3710lZpRsFzCbM"
Dim sDoor1CodeEnable As String = "P15429"
Dim sDoor1CodeTime As String = "P15430"
Dim sDoor2CodeEnable As String = "P15455"
Dim sDoor2CodeTime As String = "P15456"
Dim sURL As String = ""
Dim sXML As String = ""
Dim sCookieUname As New System.Net.Cookie("uname", "admin")
Dim sCookieGDSKey As New System.Net.Cookie("gdsauthkey443", "643e985e113a50979fd245762be01a57")
Dim sEnable As String = "1"

'Parse Time Paramter - 0 disables timers
Dim iTime As Integer = CInt(sTime)
If iTime > 480 Then
	sTime = "480"
ElseIf iTime > 0 and iTime < 5 Then
	sTime = "5"
ElseIf iTime = 0 Then
	sEnable = "0"
End If

hs.writelog("Gate Schedule: Params", "Door:" + sDoor + " Enable: " + sEnable + " Time: " + sTime)


	'First step of authorisation - Get Challenge Code
	Dim sAuthStep1Query As String = "/goform/login?cmd=login&user=admin&type=0"
	'hs.writelog("Gate Auth S1: URL", sURL)


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

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

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

		Dim sAuthCodeMD5 AS String = md5sum(sAuthCode)
		'hs.WriteLog("Gate: Auth Code MD5", sAuthCodeMD5)

		'Second step of authorisation - Authorise and set cookie with session code. Set Cookie Values as prescribed by Grandstream
		Dim sAuthStep2Query AS String = "/goform/login?cmd=login&user=admin&authcode=" + sAuthCodeMD5

		'hs.writelog("Gate Auth S2: URL", sURL)

		Dim authuri As New System.Uri(sURL)
		handler.CookieContainer = new System.Net.CookieContainer()
		handler.CookieContainer.Add(authuri, sCookieUname)
		handler.CookieContainer.Add(authuri, sCookieGDSKey)

		Dim client As new System.Net.Http.HttpClient(handler)
		sXML = client.GetStringAsync(authuri).Result


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

		If sResCode=0 Then
			'hs.writelog("Gate Auth S2: Success", sResCode)

			'Set Timer - Depending on sDoor value this can be either door or both
			'0 Value for sEnable disables timer and closes door
			Dim sOpenQuery AS String
			If sDoor = "3" Then
				sOpenQuery = "/goform/config?cmd=set&" + sDoor1CodeEnable + "=" + sEnable + "&" + sDoor1CodeTime + "=" + sTime + "&" + sDoor2CodeEnable + "=" + sEnable + "&" + sDoor2CodeTime + "=" + sTime
			ElseIf sDoor = "2" Then
				sOpenQuery = "/goform/config?cmd=set&" + sDoor2CodeEnable + "=" + sEnable + "&" + sDoor2CodeTime + "=" + sTime
				sOpenQuery = "/goform/config?cmd=set&" + sDoor1CodeEnable + "=" + sEnable + "&" + sDoor1CodeTime + "=" + sTime
			End If


			'hs.writelog("Gate Open: URL", sURL)

			Dim openuri as New System.Uri(sURL)

			sXML = client.GetStringAsync(openuri).Result


			sResCode = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/ResCode").InnerText

			If sResCode=0 Then
				'SUCCESFUL Timer Set
				hs.writelog("Gate Timer: Success", sResCode)
				'FAILED Timer Set
				sRetMsg = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/RetMsg").InnerText
				hs.writelog("Gate Timer: Error", sRetMsg)
			End If

			sRetMsg = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/RetMsg").InnerText
			hs.writelog("Gate Auth S2: Error ", sRetMsg)
		End If

		sRetMsg = GateXMLDoc.DocumentElement.SelectSingleNode("/Configuration/RetMsg").InnerText
		hs.writelog("Gate Auth S1: Error", sRetMsg)
	End If

Catch ex As Exception

	hs.WriteLog ("Gate: 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")

	Return strResult

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

Related Articles

How do the Grandstream GDS3710/3705 SIP Intercoms work?

The Grandstream GDS3710/3705 SIP Intercoms allow you to have a fully connected SIP device at your...

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...