-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
hue: add support for username configuration option #3766
hue: add support for username configuration option #3766
Conversation
@craigcabrey, thanks for your PR! By analyzing the history of the files in this pull request, we identified @fabaff, @balloob and @rhooper to be potential reviewers. |
"""Setup a phue bridge based on host parameter.""" | ||
import phue | ||
|
||
try: | ||
bridge = phue.Bridge( | ||
host, | ||
username=username, | ||
config_file_path=hass.config.path(filename)) | ||
except ConnectionRefusedError: # Wrong host was given | ||
_LOGGER.error("Error connecting to the Hue bridge at %s", host) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be beneficial to add username in here? So it can give a more fruitful message for the user to fix the problem. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Problem with outputting the username that it is actually an auth token (user+pass in 1), there is no password.
2f541d6
to
e00f744
Compare
@@ -22,7 +22,8 @@ | |||
FLASH_LONG, FLASH_SHORT, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, | |||
SUPPORT_EFFECT, SUPPORT_FLASH, SUPPORT_RGB_COLOR, SUPPORT_TRANSITION, | |||
SUPPORT_XY_COLOR, Light, PLATFORM_SCHEMA) | |||
from homeassistant.const import (CONF_FILENAME, CONF_HOST, DEVICE_DEFAULT_NAME) | |||
from homeassistant.const import ( | |||
CONF_FILENAME, CONF_HOST, CONF_USERNAME, DEVICE_DEFAULT_NAME) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add username
option also to voluptuous
def test_setup_platform_uses_discovery_info(self, | ||
socket_mock, | ||
setup_bridge_mock): | ||
hue.setup_platform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use component_setup
from bootstrap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
component_setup()
is scoped inside of from_config_dict()
in homeassistant.bootstrap
. Did you mean setup_component()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
del self.config[CONF_HOST] | ||
|
||
self.assertFalse( | ||
hue.setup_platform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use component_setup
from bootstrap
|
||
hue._CONFIGURED_BRIDGES['test'] = True | ||
|
||
hue.setup_platform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use component_setup
from bootstrap
|
||
hue._CONFIGURING['test'] = True | ||
|
||
hue.setup_platform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use component_setup
from bootstrap
def test_setup_platform(self, socket_mock, setup_bridge_mock): | ||
socket_mock.return_value = 'test' | ||
|
||
hue.setup_platform( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use component_setup
from bootstrap
e00f744
to
0afa630
Compare
Have you test you code in your env? This code work only with you unittest but will not work on a real config in first state who had open the PR. |
@pvizeli I'm not sure what you mean. I'm running with these changes right now. |
@pvizeli can you provide any clarification? I'm eager to get this in mergable (mergeable?) shape 😄 |
@@ -51,6 +52,7 @@ | |||
vol.Required(CONF_HOST): cv.string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whilte testing your PR I realized that this one should actually be vol.Optional
. Could you change that ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Tested locally, code works with config files. Check Travis logs, it actually found a bug 👍 Line 199 calls You can disable the pylint warning for too many arguments. |
0afa630
to
2322ce2
Compare
Is |
@craigcabrey The call to |
This option will remove the need to specify an external configuration (though this change doesn't stop you from doing that if you still like).
2322ce2
to
cba76a8
Compare
Don't use |
@pvizeli I'd argue that those tests are not ideal. I'm looking at It would essentially invalidate the unit test results -- there would be too much noise for very little signal. Unless you're thinking of these as integration tests, I'd strongly recommend keeping the tests scoped to as little code as possible. However, if you and @balloob insist on this, then I'll be happy to oblige. |
|
The reason we have been migrating tests to use It also seems like you have 2 lint issues left. PyLint is a bit too strict here so you can disable them by adding this comment
|
This PR seems to have gone stale. Closing it. You can reopen it when you're ready to finish it. |
Description:
Allow a Hue bridge username to be specified in
configuration.yaml
. This removes the external dependency on the Phue configuration. The motivation here is to keep secrets all insecrets.yaml
.Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#1186
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:
tox
run successfully. Your PR cannot be merged unless tests passREQUIREMENTS
variable (example).requirements_all.txt
by runningscript/gen_requirements_all.py
..coveragerc
.If the code does not interact with devices:
tox
run successfully. Your PR cannot be merged unless tests passThis option will remove the need to specify an external configuration
(though this change doesn't stop you from doing that if you still like).