Skip to content

Added new commands and functionality to the harmony remote component.#7113

Merged
balloob merged 7 commits into
home-assistant:devfrom
everix1992:harmony-commands-upgrade-feature
May 24, 2017
Merged

Added new commands and functionality to the harmony remote component.#7113
balloob merged 7 commits into
home-assistant:devfrom
everix1992:harmony-commands-upgrade-feature

Conversation

@everix1992
Copy link
Copy Markdown
Contributor

-This includes the ability to optionally specify a number of times to repeat a specific command, such as pressing the volume button multiple times.
-Also added a new command that allows you to send multiple commands to the harmony at once, such as sending a set of channel numbers.
-Updated the unit tests for these changes.

Description:

Related issue (if applicable): fixes #

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.io#2432

Example entry for configuration.yaml (if applicable):

Checklist:

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@homeassistant
Copy link
Copy Markdown
Contributor

Hi @everix1992,

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@mention-bot
Copy link
Copy Markdown

@everix1992, thanks for your PR! By analyzing the history of the files in this pull request, we identified @iandday, @titilambert and @fabaff to be potential reviewers.

Comment thread tests/components/remote/test_init.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (98 > 79 characters)

Comment thread tests/components/remote/test_init.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains mixed spaces and tabs
expected an indented block

Comment thread tests/components/remote/test_init.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains tabs
TabError: inconsistent use of tabs and spaces in indentation

Comment thread tests/components/remote/test_init.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indentation contains tabs
indentation contains mixed spaces and tabs
blank line contains whitespace

Comment thread tests/components/remote/test_init.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (92 > 79 characters)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (91 > 79 characters)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not add a new service. Instead, by using cv.ensure_list you can make the existing send_command support multiple commands and stay backwards compatible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default implementation of send_commands on the abstract base class should be to just call send_command once for each command.

Copy link
Copy Markdown
Contributor Author

@everix1992 everix1992 May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the comment about the default implementation of send_commands. However, if we are keeping the num_repeats parameter as we were discussing below, I'm not sure if we'd want to fold send_command and send_commands into one service, unless we're fine with being able to repeat a list of commands as well. I don't actually see a problem with this, but I just hadn't thought of it originally.

Also, I'm slightly confused about the backwards compatible comment. These changes shouldn't break backward compatibility because the new parameters for the send_command service have defaults specified. And send_commands wouldn't break backwards compatibility because it's a new service.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can setup the send_command schema validation in such a way that it is backwards compatible but still takes in multiple commands.

I prefer to keep it in 1 function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, I'll make this change as soon as I have some free time, which will be at latest tomorrow night.

Copy link
Copy Markdown
Contributor Author

@everix1992 everix1992 May 5, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like merging everything back into one service is going to require some changes to pyharmony, so this'll be on hold until I can get another release out with that change in it.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pyharmony 1.0.16 is up with your changes @everix1992, thanks for your hard work!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flakiness in a connection between remote and device is a concern for the platform. We should not have to add it to the main component.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you can add it as platform config to the harmony platform ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious, what do you mean by flakiness? If you're talking about the number of repeats parameter, that has nothing to do with flakiness. The intent of that it to allow you to repeat a command X number of times. For example, if you wanted to increase the volume by 5, you could send the volume up command with a number of repeats of 5.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not add this for now as it can already be achieved differently: by just sending multiple commands.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct, but letting this be specified as a number allows for much easier integration. If I'm trying to trigger something through IFTTT, I can't generate a list of commands on the fly. I can, however, take the number given to me and pass that on to home assistant.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, let's keep it in 👍

@cdrage
Copy link
Copy Markdown

cdrage commented May 1, 2017

Hi @everix1992

Before, I used a work-around to repeat the commands (using the script functionality of home assistant, so simply enter the command X amount of times). The unfortunate part was that it was delayed about 2-3 seconds each-time it inputted the command. My assumption was that it was either a built-in hass delay or an issue with communicating to the harmony remote back-end API.

Does this implementation experience that same issue? (I'm not home yet to try this PR out with my Harmony Hub)

Copy link
Copy Markdown

@cdrage cdrage May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Harmony Hubs have built-in delays for each command. So each-command would be 400ms + Harmony's configured delay (for ex. mine is set to 300ms). So for each vol-up it'd be 700ms which would still be slower than using a physical remote.

Is there a way to change this delay value within configuration.yaml, also, have you tested it with a lower configured delay? I'm assuming HA is multi-threaded so it could handle these commands.

Copy link
Copy Markdown
Contributor Author

@everix1992 everix1992 May 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In response to your first question, no this PR doesn't experience that issue. The reason that behavior occurred within the script was due to how commands were being sent in the pyharmony library. I've worked with the developer of pyharmony to get that issue fixed.

With that issue gone, 0.4 seconds was the appropriate delay for my setup in which I was using the default delay for Harmony Hubs (didn't even realize there was a setting to change for that).

And yes, I did some testing when I was testing this and 0.4s seemed about right. Any faster (0.1 or 0.2) and I would drop commands. There was no benefit to going any slower.

Take this with a grain of salt since I'm fairly new to HASS development, but I think that it would be possible to add a default delay value to the configuration.yaml that would override the 0.4 seconds.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@everix1992 Awesome! Thanks a lot man. I'll test this PR on my personal Harmony Hub as well this week.

@cdrage
Copy link
Copy Markdown

cdrage commented May 3, 2017

This LGTM 👍

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All remote platforms have to be updated to accommodate for a list of commands being passed in. Not just the demo and harmony platforms.

@everix1992
Copy link
Copy Markdown
Contributor Author

@balloob Ah, my bad. The commit I was working off of did not have any other remotes added. I'll rebase and get them fixed up.

Comment thread homeassistant/components/remote/kira.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'commands'

Copy link
Copy Markdown
Member

@balloob balloob left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to merge when tests pass 👍

Comment thread tests/components/remote/test_demo.py Outdated
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing whitespace around operator

@balloob
Copy link
Copy Markdown
Member

balloob commented May 23, 2017

Ok to merge when conflicts resolved. Not sure what has changed.

-This includes the ability to optionally specify a number of times to repeat a specific command, such as pressing the volume button multiple times.
-Also added a new command that allows you to send multiple commands to the harmony at once, such as sending a set of channel numbers.
-Updated the unit tests for these changes.
@everix1992
Copy link
Copy Markdown
Contributor Author

everix1992 commented May 23, 2017 via email

@balloob balloob merged commit 3638b21 into home-assistant:dev May 24, 2017
@balloob balloob mentioned this pull request Jun 2, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Sep 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants