I am working on @bptworld’s Magic Cube driver/app and @ogiewon’s Logitech Harmony device driver. What I am stuck on is how to send a device command from one developer app/driver to another. Is there a way to do this?
Example:
Magic Cube rotates left then a Volume Up is sent to the Logitech Harmony Parent driver.
You have to add an "input" to his app to allow you to select the Harmony Hub device. Then, in his app, where the Magic Cube events are being handled, use the Harmony Hub device from the 'input' above to call the commands of the device.
This is the basis of how all Apps work. First section allows users to select devices that will be used by the App, based on their Capabilities. Next, the App subscribes to events from devices. Finally, when an event occurs, the action is usually to call a command of another device.
Alright @ogiewon I spent some time this morning working on the Magic Cub to Harmony integration. I had to add a capability "Switch" to the Parent Device to have the Harmony Parent show up in a list. I have the cube responding and hitting the harmonyHandler() I created in the Magic Cube app. I am attempting to make the following call to the Harmony Parent device driver but it isn't doing anything.
.volumeup
Actual code is setVolup.volumeup
What am I missing? Or do I need to have a way for the parent driver to accept a call from a driver?
You shouldn't need to add a capability. You could use one of the existing capabilities (including actuator and switch level) to find and select the harmony parent.
The command should be deviceInputName.volumeUp()
Of course you would need to change the deviceInputName with the name you gave the input. A code snippet would make helping a lot easier. Specifically the preference section where you declared the input for the harmony parent...and the complete method where you are executing the volume up command.
In addition to @stephack's great advice, it should be noted that Groovy is CaSe SeNsItIvE. Thus, "device.volumeup()" is not the same as "device.volumeUp()". @stephack's code is correct, I just wanted to point out the fact that the language is case sensitive in case this was the root cause of your issue.
As Daniel says you shouldn’t do this, use another existing capability to select the device.
The reason is that you are advertising that the device supports switch capabilities which it would seem it doesn’t. Thus other apps will then allow selection of it as a switch, for example Rule Machine, and may send commands to the device which will throw errors. Declaring that you have switch capabilies requires you to implement some basic on off commands / attributes.
@kevin
Great observation. Unfortunately the Parent device only has the capability of Initialize and Refresh. So something has to be added for an app to be able to select it. Recommendations on a different capability? I am game to use that instead.
@ogiewon, @stephack, @kevin
Turned out to be as suspected a capitalization issue. smh I really need to code in VS like I normally do verses in the HE editor. The HE editor is nice for quick and dirty but when trying to keep everything in sync with capitalization you can easily miss something like I just did.
I just got to ask. Is your whole goal to get your feet wet with groovy (apart from controlling your Harmony with the Magic Cube)? You know you would be done right now if you would use RM and some virtual push buttons, right?
I am pretty good with Groovy when confined in my own little world of app/driver. When venturing outside into other's works I am hesitant. RM won't do what I want for the use case of Magic Cube. This is more of a toy that I am putting WAY too much time into.
Device1: Virtual Switch that disables after 500ms
MagicCube App -> turn left on face 0 -> turn on Device1
RM: Trigger: Device1 on
Actions: Custom Action on Harmony Device calling volumeUp()
What can't RM do????
BTW, I have that same little toy sitting right in front of me