In part 1 we just used groovy standalone to connect to HomeSeer, now we take a step up to improve performance :-).
I finally found time to write about the HomeSeer Groovy Script Server and the HSGroovyScript HomeSeer Plugin. I took me a while before I got all the HomeSeer API functions working from within Groovy, reason: DLL hell and x64/x86 COM component compatibility problems :-).
Basically we have a (standalone) Groovy Server running waiting for commands/scripts to run. This server can run on any (windows) machine, and connects remotely to the HomeSeer host using the HS speakerclient active-x components. A plugin for HomeSeer then does the necessary work to start a groovy script on the applicable machine. Unfortunately I couldn’t find a way to initiate the script other than by an event. I tried fiddling with the scripting possibilities within HomeSeer itself, but failed to get a .groovy
in there. If you guys have another idea, feel free to let me know.
When initializing, the server connects to the HomeSeer host, and prepares the homeseer2.application
COM component and its Scheduler.hsapplication
reference. These 2 objects are injected in each script/command executed as variables hsi
and hs
.
This means that the scripts don’t have to initiate the connection to HomeSeer every time.
Example:
Result looks like this:
Or we could do some more complicated stuff:
On HomeSeer side, the scripts are fired by events:
The result looks like:
If people would be interested in this homeseer plugin, feel free to comment below. Of course opinions and other comments are welcome too :-).