If possible, could you consider adding these as child devices?
Are you suggesting adding each Harmony Device as a child device?
I was simply adding the following 1 liner to the Parent Device as a starting point.
command "deviceCommand", ["String", "Number"]
As this would allow you to issue any Device Command you'd like via Rule Machine, asssuming you know the command string and the numeric Device ID.
I have a new version of the Logitech Harmony Hub Parent Driver available in my GitHub repo for you guys to test. It simply exposed the 'deviceCommand()' function as a Custom Command.
I'll look into parsing the list of device from the hub next to expose their ID's, but that may take some time...
I have the list of Harmony Devices showing up as a state variable on the device details page. Next step would be to make each of them appear as a child device, which would give you basic PowerOn and PowerOff commands like normal Hubitat Switch devices.
How does that sound @aaiyar?
That's just about perfect. Thank you for considering the request.
Well, some not so great news. I just figured out that while you would be able to issue commands to devices, there is no way to know whether or not the device performed the command. So, there would be no way to update the status of a 'Harmony Device' child switch device. Its state would never be correct. I am not a fan of that behavior.
I could easily add to the Parent Device two new custom commands - "devicePowerOn(deviceID)" and "devicePowerOff(deviceID)" to make it simpler to call these functions. You could look up the deviceID's from the State Variable which is displayed on the Parent Device's detail page. Then, in RM you would use a custom action and paste in the deviceID you want.
Not sure...probably need to think about it some more...
For now, I have uploaded the current code to my GitHub that exposes the deviceID's so you can at least use the 'deviceCommand()' custom command.
I have tested the 'deviceCommand("PowerOn", deviceID)' and 'deviceCommand("PowerOff", deviceID)' successfully.
Please be aware that turning on or off devices that are used in Activities will get the Harmony Hub out of sequence.
I can see that being an issue.
Out of curiosity, does it need to have a state? I mean, right now I'm using HTTP momentary switch and the harmony-api, and those virtual devices have no state either ....
Yea, I wondering the same thing. The HTTP Momentary switch does properly implement the 'switch' attribute's state, but also automagically turns the switch back to off after a few seconds. So, it does generate an event which could be used by an app, but probably would never be.
Button Controllers are the closest thing in Hubitat to a true stateless actuator, like what you find on a typical remote control. The typical IR remote control maintains no state about each of the devices you command on or off. The Momentary Capability is another option as it implements the push() command. But since it is only one command, it does not really help.
So, that leaves us with a custom device driver, that implements the Harmony PowerOn() and PowerOff() as custom commands, without any state... Thoughts?
From the perspective of the end user (and admittedly, this is a specialized subgroup who need to control individual devices and not just activities), its no different than what we're currently doing.
So, I'd say its your call.
I definitely didn't mean to suggest either that you should do it, or that it was easy . Sorry if it came across that way, just wanted to voice that it's a use case.
I don't know anything about the programming of it so I don't know if any ideas I have are useful. I think the Harmony-api solution dealt with the varying commands issue by having a few generic devices 'climate' 'av' I think they had a vacuum and a few others, I only know what I dealt with. The state tracking was done by having whatever device plugged in to a separate energy monitor. It clearly couldn't tell anything other than on/off, but worked reasonably well for that.
I'm on the road so haven't been able to play with what you've uploaded, but thanks muchly for even considering it, let alone the progress.
Wow, that was quick. I will test it as soon as possible. Thank you for the support!
Wow. I go to bed having thrown out a suggestion and when I wake up Dan's @ogiewon already done it! Thanks Dan
I've replaced my bodged custom code with Dan's latest version from github and it all works beautifully. It's much better than hard coding the various device commands into the driver like I did and gives total flexibility to send any command to any device in the future.
This driver officially rocks!
I've been playing around with my own driver to implement something like this.
If you want to get really detailed,
You could have a custom driver with various buttons as commands (similar to a remote). Then have an input setting for each that allows you to pick the command that gets executed when that button is pressed. Its like assigning the command to the button on the harmony remote.
All of the commands available to that device are actually exposed in the json responses under "device". You can parse them out there and drop them in the device data section so they can be used in the input.
I don't think we care about the state of the device. Just sending the command. Kind of like how a dumb remote works.
All this is in theory. I'm playing around with it on my own app but thought I would share a way that it could possibly be done.
I think @armand's Roku TV integration, which I've found to be very useful, works something like that.
Dan - just got a chance to try it out. It works very well! Thank you so much for considering and implementing @Geoff_T's suggestion.
Yep, this all makes sense to me as well. I was considering a very similar approach last night as well. To me, though, it seems like a ton of work that has very little reward for my personal use-case. I know that this is valuable to some users, so I am not trying to stifle anyone's creativity. I look forward to seeing what you come up with. Please feel free to borrow as much code from my Harmony Hub Driver as you'd like!
No worries @adiventure! I wasn't trying to unload on you whatsoever. Sorry if I came across that way.
I am always willing to evaluate and incorporate changes from other users. Or, if someone is willing to build a better solution altogether, I am happy to let them take over as the new czar of Harmony Hub integrations. My feelings really would not be hurt. I wrote this integration because I like solving problems/puzzles like this. I selfishly focused on what was most important to me and my family. After the initial challenge is complete, my focus/interest usually moves elsewhere for a while. I am happy to make changes based on user feedback, as long as what is being asked for is useful to many and within my skill-set to implement in a reasonable time-frame. Last night's tweaks were very simple to implement. Adding new child devices that correspond to each Harmony Device appeared to me like a significant refactoring of the existing code base. A worthwhile endeavor, however not one that I feel I have the time for right now.
This is what I did on my end. It wasn't really hard at all. I can share the relevant pieces of code via pm if you want and you may have to adapt it a bit to your code but should be easy.
My devices and activities all show up as child devices to my hub.
Then in each device I have the relevant commands and the options to assign (I've only done power for now). I store the data in the data section to use.
Just finished it and did some quick tests and it works. I can send commands without affecting the activities. I was going to look into the hub json responses a bit and see if I could auto assign the commands based on how the remote is setup and if I can it will stay in sync with how the remote is configured. I would just have to actually look at the remote assignments in device mode and not in the activity mode. May or may not be possible or worth it.