Tips and FAQs
01 Incompatible HS4 library files
tenScripting4 uses many HS4 functions to simulate the HomeSeer environment, and needs access to the HS libraries containing these functions. Since version 4.5, these libraries have been distributed with the installation package. There may be a situation where the libraries included with tenScripting4 are incompatible with the libraries that are used by your HS4 server. One solution, probably unacceptable, is to upgrade/downgrade your HS4 installation to the same version that the tenScripting4 version is based upon. A less disruptive solution is to just copy the library files from your HS4 installation to the tenScripting4 folder located at \tenScripting4\tenScripting4\Libraries. The following files should be copied:
\HS4\HomeSeerAPI.dll
\HS4\HSCF.dll
\HS4\Scheduler.dll
\HS4\Bin\homeseer\PluginSdk.dll
\HS4\Bin\homeseer\Newtonsoft.Json.dll
\HS4\Bin\homeseer\System.Data.SQLite.dll
After you have copied these six files, open tenScripting4 and click on the Build menu and then Rebuild Solution.
02 Cannot retrieve HsDevice object using hs.GetDeviceByRef() in HS4, works in tenScripting4
UPDATE: HS4 version 4.1.14.0 resolves this problem by making available the IHsController class members instantiated as hs4. When you export your script from tenScripting4 (version 4.7 or higher), the hs4 will NOT be replaced with hs and hs4.GetDeviceByRef(174) will work as expected.
The following code used in a script running under tenScripting4:
hs4.GetDeviceByRef(174)
correctly returns an object of type HomeSeer.PluginSdk.Devices.HsDevice
When run in the HS4 scripting environment, the following:
hs.GetDeviceByRef(174)
returns an object of type Scheduler.Devices.DeviceClass
The problem is that the HS4 hs object is of type hsapplication, which contains the members from both IHSApplication (which is primarily the HS3 scripting functions) and IHsConroller (which contains new functionality added with HS4). Both contain a GetDeviceByRef method with the exact signature, and hence only one could be included, and it appears that HomeSeer included the prior HS3 version of GetDeviceByRef in the HS4 hs object. There is a way to retrieve the HsDevice object for a DeviceRef using the following:
Dim ad As HomeSeer.PluginSdk.Devices.AbstractHsDevice
Dim aDevice As HomeSeer.PluginSdk.Devices.HsDevice
If hs4.IsRefDevice(174) Then
'' DevRef is a Device (root)
ad = hs4.GetDeviceWithFeaturesByRef(174)
Else
'' DevRef is a Feature (child)
ad = hs4.GetFeatureByRef(174)
End If
aDevice = CType(ad, HomeSeer.PluginSdk.Devices.HsDevice)
The code can be greatly simplified if you know if the Reference is to a Device or a Feature.