Skip to content
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

Avoid unnecessary commands in Vizio update function #20867

Merged
merged 1 commit into from Feb 28, 2019

Conversation

JeffLIrion
Copy link
Contributor

Description:

If the power is off, we don't need to check the _volume_level, _current_input, and _available_inputs attributes; we can just set them to None.

I'm hopeful that this can help me avoid errors of the form (this occurs in pyvizio when trying to get the volume level):

[pyvizio.vizio] Failed to execute command: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

Related issue (if applicable):

Pull request in home-assistant.io with documentation (if applicable):

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

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

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

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated 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:

  • Tests have been added to verify that the new code works.

@ghost ghost added in progress and removed platform: media_player.vizio small-pr PRs with less than 30 lines. labels Feb 8, 2019
@balloob
Copy link
Member

balloob commented Feb 8, 2019

What do you mean with "I'm hopeful". Did you not test these changes locally?

@JeffLIrion
Copy link
Contributor Author

I'm using this code and it works. I don't know if it fixes that error because I don't see it very often, maybe once a week on average, and I don't know what the cause is.

But whether or not it fixes that error, this is just a small PR to clean up the code -- there's no need to get further attributes when the state is off or unknown. We also don't need 3 lines to do what can be done in 1 line with a list comprehension

@JeffLIrion
Copy link
Contributor Author

I've been using this component for a week and have yet to see that error.

@JeffLIrion
Copy link
Contributor Author

@balloob it's been almost 3 weeks and I haven't seen that error once.

@balloob balloob merged commit 0ebd12f into home-assistant:dev Feb 28, 2019
@ghost ghost removed the in progress label Feb 28, 2019
@balloob balloob mentioned this pull request Mar 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants