Skip to content

Adds commands for changing channel and sending named commands#1

Open
ChrisMD123 wants to merge 11 commits into
rkitover:masterfrom
ChrisMD123:master
Open

Adds commands for changing channel and sending named commands#1
ChrisMD123 wants to merge 11 commits into
rkitover:masterfrom
ChrisMD123:master

Conversation

@ChrisMD123

Copy link
Copy Markdown

Thanks for the great fork. I'm fairly inexperienced with Python so the code might be a little inefficient, but these two commits add change_channel and send_command_named functions.

Change_channel uses the changeChannel call from the Harmony API, while send_command_name uses the show_current_activity and send_command functions to send a "named" command (generally assigned to a remote button) without needing to specify the deviceId.

Adds function to change channel.

Syntax:

PYTHONPATH="." python harmony --email user@example.com --password pass \
--harmony_ip my_hub_host change_channel 123
Searches the activity's profile for a match and executes the command
using the send_command function.
Syntax:
PYTHONPATH="." python harmony --email user@example.com --password pass \
--harmony_ip my_hub_host send_command_named "command name" x
@rkitover

rkitover commented Jun 8, 2016

Copy link
Copy Markdown
Owner

@ChrisMD123 Looks good, but I think we should combine send_command_named and send_command into one command, that is send_command.

The way this would work is it will do the substitutions on the passed in command and use the current activity if no device was passed in.

Also the way you have it now is not going to work, because show_current_activity prints the activity JSON block and does not return anything, you'll have to split that function into get_current_activity and show_current_activity and then use get_current_activity in send_command.

Also you're writing out a data.json file I'm guessing for debugging which you forgot to remove.

I can merge these and do this myself or wait for you to update these if you want, let me know.

Removes the log out to a .json file.
show_current_activity returns the activity for input into
send_command_named.
@ChrisMD123

ChrisMD123 commented Jun 9, 2016

Copy link
Copy Markdown
Author

@rkitover Right you are - sorry about that, I committed an earlier work-in-progress version. The new commit modifies main.show_current_activity to return the activity json block and removes the log out to data.json.

Feel free to make that change to the single send_command function; you'll probably be able to execute it more efficiently that I would. I think it'd be nice to keep the addition of the "repeat" variable (defaulted to 1, presumably), since sometimes a user might want to "press" VolumeDown a few times as part of the same action.

Chris

ChrisMD123 and others added 8 commits July 18, 2016 13:08
Add the former send_command_named parserse to send_command.
Combined the two send_command activities into the single send_command.
Fixes unnecessary recursive process by sending the device_id and command
straight to client.send_command.
Uses client rather than main to get the current activity - saves time.
Documents new combined send_command function.
@ChrisMD123

Copy link
Copy Markdown
Author

I gave it a shot, anyway. It's probably not the most elegant solution, but I added the old "named" function as an "if" statement - if neither the device_id nor the device are passed in the args, it goes looking for the matching device/command pair in the current activity.

The "repeat" argument works across any of the device identification options, and it's pretty snappy now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants