-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Q: Possible to control command/device nodes via code? #10
Comments
+1 |
Could it be as simple as the if statement inserted below? i.e. if the inbound message has a json payload with a command property, copy the command, type and deviceId property to the action object.
|
I have it working locally, with these changes in harmony.js. The updated node will accept either a string or JSON payload that looks like this:
|
I can implement the possibility to provide a command as stanza via msg.payload, it would be hard however to hand in a command like described above. It would require to look up a command by name, on the other hand you assume the device is identified by ID. |
@BladeRunner68 and @skavan can you explain the use case, why you would want to do that? |
When use cases are available, we'll reconsider this. Closing for now. |
my suggestion was added in Nov 2017 and the world has moved on now. :) |
So...here's an example. Hope it makes sense. It's sometimes hard to describe these things.
If I could pass a json payload to a variant of your command node, called for example H device, and in that payload specify a command, such as {"command":"menu"} and optionally a deviceId, such as {"deviceId": "25252525"}, then I could use a single H device for all commands to that device. The H device would allow the designer to select an harmony device from a specified hub - and inspect the ID's of all devices on that hub. It would also display the commands available for the chosen device. If H device received, {"command":"menu"}, it would simply send that command to the pre-selected device in the node. If it received {"command":"menu", "deviceId": "3737373737"} it would ignore the preselected device and use the passed in Id. Harmony does a pretty good job of "Harmonizing" device commands, but if necessary, an intermediate "change" or "function" node could easily map an MQTT message of "on" to "ON", for example. The only "issues" with this approach are the device command discovery and possible mapping needs. Here;s an example - which looks much more complicated than it actually is -- using my own hack of your code. This flow controls a FireTV using the harmony as a controller. The really cool part is that the downstream GUI or Alexa based input doesn't need to know anything about the fact that the work is being done by the Harmony node. It doesn't care. It simply sends {"command", "Menu"} to a topic "MyHouse/LivingRoom/FireTV" via MQTT. So, my ask, is:
|
Thank you for the detailed description @skavan ! Makes sense. Here is what I suggest: A new node is not really needed. What you describe can be achieved with the H command node. I would change the node so that it parses the input it receives. If the input is an object with the properties "command" and "deviceId", it checks if the deviceId of the input object matches the deviceId configured in the command node. If yes, the node sends the command that was handed in. As an easy way to acquire a list of commands, I'll add a button in the H command node that triggers a node-RED notification (pop-up) with the available commands for the selected device. I believe the above covers your use case. For each device or activity, you would create one H command node, select a Hub and Device/Activity once, get the commands for your reference, and then hand in the commands as needed. Since I'm traveling for a while, I'll probably do this in roughly 2 weeks from now. |
no worries on timeline...I'm glad it made sense. node gui:
node code:
|
Hiya, any update? |
I'll get to it soon :) |
Looking forward to it |
I dont know if this node is still under development but the |
Is it possible we can provide the device and command via msg properties (and thus via code) rather than hardcoding the command and (hopefully forthcoming device) node with the activities/commands?
The text was updated successfully, but these errors were encountered: