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

Use sane defaults for zwave #1891

Merged
merged 1 commit into from
Apr 26, 2016

Conversation

danieljkemp
Copy link
Contributor

Description:

Use sane default if libopenzwave is installed. In most cases this will mean that the zwave config path will not need to e manually specified.

Verify write access to the usb device before opening. If write access is missing, print an error indicating the current user, and path of usb device.

Related issue (if applicable): #1884, verifies home-assistant/home-assistant.io#414 with readable error message.

Example entry for configuration.yaml (if applicable):

Checklist:

If code communicates with devices:

  • 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).
  • [n/a] New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • [n/a] 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.

Use sane default if libopenzwave is installed.

Verify write access to the usb device before opening.

DEFAULT_ZWAVE_CONFIG_PATH = os.path.join(os.path.dirname(
libopenzwave.__file__), 'config')
except NameError:
DEFAULT_ZWAVE_CONFIG_PATH = os.path.join(sys.prefix, 'share',
Copy link
Member

Choose a reason for hiding this comment

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

No need to default anything as without openzwave it's not going to work.

Should we detect if openzwave doesn't exist in the setup and link to instructions?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The idea is to default to libopenzwave.__file__ as the config location if one is not specified. This will be the correct location except in edge cases where the user has modified/updated the libopenzwave config manually. The goal is for elimiating config_path: as a required yaml entry except for those rare edge cases.

You're right about the failure mode however, if libopenzwave is not found, we should exit the component then and there.

@danieljkemp danieljkemp force-pushed the zwave-config-defaults branch from fb20e1d to ad64016 Compare April 23, 2016 16:33
@danieljkemp
Copy link
Contributor Author

Updated PR, fixed the clobbering of thermostat command classes, left write access checking to libopenzwave, and changed where imports are being done.

@JshWright
Copy link
Contributor

Looks good to me

@SEJeff
Copy link
Contributor

SEJeff commented Apr 24, 2016

👍

@@ -175,10 +172,14 @@ def setup(hass, config):
# pylint: disable=global-statement, import-error
global NETWORK

import libopenzwave
Copy link
Member

Choose a reason for hiding this comment

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

Since we can't install this using REQUIREMENTS, I would suggest we wrap this and print a proper warning to the user:

try:
    import libopenzwave
except ImportError:
    _LOGGER.error("You are missing required dependency Python Open Z-Wave. Please follow instructions at X")
    return False

@balloob
Copy link
Member

balloob commented Apr 24, 2016

Looks good 🐬 Added 1 comment that would improve the experience a bit more.

Change the zwave config default path to be valid in all but rare
edge cases. This will let that config value be truely optional.

Also check that libopenzwave is installed and print a warrning if
it cannot be found pointing at the site.
@danieljkemp danieljkemp force-pushed the zwave-config-defaults branch from a2aa5be to c04797a Compare April 24, 2016 04:57
@balloob
Copy link
Member

balloob commented Apr 26, 2016

💃 Looking good 🐬

@balloob balloob merged commit b4be508 into home-assistant:dev Apr 26, 2016
@home-assistant home-assistant locked and limited conversation to collaborators Mar 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants