c# homeseer homeseer 3 hs3 hs3-pi

Enable remote plugins on your HomeSeer Zee

I promised a way to connect your HomeSeer 3 plugins remotely to your HS3-Pi or HomeSeer HomeTroller Zee. Running through some hoops it has (partly) succeeded. You might want to read the previous posts on the topic before getting your hands dirty.

How it works

The current version of hslinux_zee (3.0.0.106) does not allow remote plugin connections, the feature is basically disabled. What the HSPI_EnableRemotePlugins-plugin does, is re-using the available out-of-box HomeSeer framework API to (re)enable it. The source-code is available on github.com/ihomeautomate under the LGPL-2.1 license. Definitely check out its readme-page for the most up-to-date information.

Running through hoops

One might expect that invoking HomeSeer Communication Framework aka HSCF would be enough to achieve our goal.

scsServiceApplication = ScsServiceBuilder.CreateService (new ScsTcpEndPoint ("127.0.0.1", PLUGIN_API_PORT));
scsServiceApplication.AddService<IHSApplication, hsapplication> (hsApplication);
scsServiceApplication.AddService<IAppCallbackAPI, clsHSPI> (appCallbackAPI);

… unfortunately it wasn’t. Somehow out-of-box HomeSeer code fails to get the remote plugin initialized. That’s where we’ve needed to disable some core functionality.

appCallbackAPI.StopCheckTimer(); 
// It'll make sure the out-of-box plugin check is disabled for our custom initialization to be triggered.

… and replace it with our custom implementation, leveraging the available appCallbackAPI. This seems to do the trick.

for (int i = 0; i < appCallbackAPI.IOobjsPending.Count; i++) {
	clsHSPI.PluginHolder pluginHolder = (clsHSPI.PluginHolder)appCallbackAPI.IOobjsPending.GetByIndex (i);
					
	// ...
 
	HomeSeerAPI.IPlugInAPI clientProxy = pluginHolder.client.GetClientProxy<HomeSeerAPI.IPlugInAPI> ();
	pluginHolder.obj_ref = clientProxy; 
 
	hsApplication.WriteLog (PLUGIN_NAME, "'" + pluginHolder.obj_name + ":" + pluginHolder.InstanceName + "'.InitIO(" + pluginHolder.sPortNumber + ")");
	string text = clientProxy.InitIO (pluginHolder.sPortNumber);
 
	// ...
}
Licensed plugins won’t work out-of-box

From this thread we understand that when using licensed remote plugins, there needs to be a copy located on the HomeSeer server. This is how HomeSeer checks the plugins AccessLevel. Unfortunately for us, hslinux_zee disables the scanning of HSPI_ .exe files in /usr/local/HomeSeer.

Our workaround – implementing our own scanning mechanism – won’t work with out-of-box licensed plugins. Invoking such hs3_linux-plugin through reflection fails due to conflicting HomeSeerAPI interface(s). Not much we can do about that, except asking the plugin author to recompile against the proper hslinux_zee DLL binaries and release a hslinux_zee version. In theory, when that is done, and, a copy of the .exe is located in /usr/local/HomeSeer of the HomeSeer server, the HSPI_EnableRemotePlugins-plugin should do the rest. This is un-tested, feel free to confirm my theory.

Good news however, for free plugins AccessLevel == 1, this all should work without having a copy on the HomeSeer server.

Get started

Grab the latest release available on Bintray, copy it to /usr/local/HomeSeer on your HS3-Pi or HomeTroller Zee and restart. The plugin should then be visible in the manage plugins section, ready to be enabled. Please refer to the readme on github on how to proceed in detail.

In case you want to use the latest snapshot build, they should be available in JFrogs OSS artifactory.