diff --git a/docs/creating_component_deps_and_reqs.md b/docs/creating_component_deps_and_reqs.md index f7a8c0e3..821e360b 100644 --- a/docs/creating_component_deps_and_reqs.md +++ b/docs/creating_component_deps_and_reqs.md @@ -22,6 +22,23 @@ Requirements is a list of strings. Each entry is a `pip` compatible string. For REQUIREMENTS = ['pychromecast==0.6.12'] ``` +### Note + +Be aware that actual python imports of these dependencies should be done inside functions that use them. This is because Home Assistant installs requirements on demand and so the requirement won't be loaded the first time your component is loaded. + +Example: + +```python +REQUIREMENTS = ['pychromecast==0.6.12'] + +def setup(hass, config): + import pychromecast + + +``` + +### Custom requirements during development & testing + During development of a component, it can be useful to test against different versions of a requirement. This can be done in two steps, using pychromecast as an example: * `pip install pychromecast==0.6.13 --target ~/.homeassistant/deps`