Site updated at 2016-05-13 20:25:49 UTC

This commit is contained in:
Travis CI 2016-05-13 20:25:49 +00:00
parent 9918d86370
commit ebea4ecf27
19 changed files with 46 additions and 47 deletions

View file

@ -89,11 +89,11 @@
<hr class="divider">
<p>There are several reasons why it makes sense to run Home Assistant in a virtualenv. A virtualenv encapsulates all aspect of a Python environment within a single directory tree. That means the Python packages you install for Home Assistant wont interact with the rest of your system and vice-versa. It means a random upgrade for some other program on your computer wont break HA, and it means you dont need to install a bunch of Python packages as root.</p>
<p>There are several reasons why it makes sense to run Home Assistant in a virtual environment. A virtualenv encapsulates all aspect of a Python environment within a single directory tree. That means the Python packages you install for Home Assistant wont interact with the rest of your system and vice-versa. It means a random upgrade for some other program on your computer wont break Home Assitant, and it means you dont need to install Python packages as root.</p>
<p>Virtualenvs are pretty easy to setup. This example will walk through one method of setting one up (there are certainly others). Well be using Debian in this example (as many HA users are running Raspbian on a Raspberry Pi), but all of the Python related steps should be the same on just about any platform.</p>
<p>Virtualenvs are pretty easy to setup. This example will walk through one method of setting one up (there are certainly others). Well be using Debian in this example (as many Home Assistant users are running Raspbian on a Raspberry Pi), but all of the Python related steps should be the same on just about any platform.</p>
<h2>Step 0: Install some dependencies</h2>
<h2><a class="title-link" name="step-0-install-some-dependencies" href="#step-0-install-some-dependencies"></a> Step 0: Install some dependencies</h2>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>sudo apt-get update
@ -104,9 +104,9 @@ sudo pip install --upgrade virtualenv
</div>
</div>
<h2>Step 1: Create a Home Assistant user</h2>
<h2><a class="title-link" name="step-1-create-a-home-assistant-user" href="#step-1-create-a-home-assistant-user"></a> Step 1: Create a Home Assistant user</h2>
<p>This step is optional, but its a good idea to give services like Home Assistant their own user. It gives you more granular control over permissions, and reduces the exposure to the rest of your system in the event there is a security related bug in HA. This is a reasonably Linux oriented step, and will look different on other OSs (or even other Linux distros).</p>
<p>This step is optional, but its a good idea to give services like Home Assistant their own user. It gives you more granular control over permissions, and reduces the exposure to the rest of your system in the event there is a security related bug in Home Assistant. This is a reasonably Linux oriented step, and will look different on other operating systems (or even other Linux distributions).</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>sudo adduser --system hass
@ -114,7 +114,7 @@ sudo pip install --upgrade virtualenv
</div>
</div>
<p>Home Assistant stores its config in <code>$HOME/.homeassistant</code> by default, so in this case, it would be in <code>/home/hass/.homeassistant</code></p>
<p>Home Assistant stores its configuration in <code>$HOME/.homeassistant</code> by default, so in this case, it would be in <code>/home/hass/.homeassistant</code></p>
<p>If you plan to use a Z-Wave controller, you will need to add this user to the <code>dialout</code> group</p>
@ -124,9 +124,9 @@ sudo pip install --upgrade virtualenv
</div>
</div>
<h2>Step 2: Create a directory for Home Assistant</h2>
<h2><a class="title-link" name="step-2-create-a-directory-for-home-assistant" href="#step-2-create-a-directory-for-home-assistant"></a> Step 2: Create a directory for Home Assistant</h2>
<p>This can be anywhere you want, but I generally put stuff related to servers in /srv. You also need to change the ownership of the directory to the user you created above (if you created one)</p>
<p>This can be anywhere you want, but I generally put stuff related to servers in <code>/srv</code>. You also need to change the ownership of the directory to the user you created above (if you created one)</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>sudo mkdir /srv/hass
@ -134,8 +134,7 @@ sudo chown hass /srv/hass
</pre></div>
</div>
</div>
<h2>Step 3: Become the new user</h2>
<p>## <a class="title-link" name="step-3-become-the-new-user" href="#step-3-become-the-new-user"></a> Step 3: Become the new user</p>
<p>This is obviously only necessary if you created a hass user, but if you did, be sure to switch to that user whenever you install things in your virtualenv, otherwise youll end up with mucked up permissions.</p>
@ -147,7 +146,7 @@ sudo chown hass /srv/hass
<p>The su command means switch user. We use the -s flag because the hass user is a system user and doesnt have a default shell by default (to prevent attackers from being able to log in as that user).</p>
<h2>Step 4: Set up the virtualenv</h2>
<h2><a class="title-link" name="step-4-set-up-the-virtualenv" href="#step-4-set-up-the-virtualenv"></a> Step 4: Set up the virtualenv</h2>
<p>All this step does is stick a Python environment in the directory were using. Thats it. Its just a directory. Theres nothing special about it, and it is entirely self-contained.</p>
@ -159,7 +158,7 @@ sudo chown hass /srv/hass
</div>
</div>
<h2>Step 5: Activate the virtualenv</h2>
<h2><a class="title-link" name="step-5-activate-the-virtualenv" href="#step-5-activate-the-virtualenv"></a> Step 5: Activate the virtualenv</h2>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>source /srv/hass/bin/activate
@ -169,9 +168,9 @@ sudo chown hass /srv/hass
<p>After that, your prompt should include (hass).</p>
<h2>Step 6: Install Home Assistant</h2>
<h2><a class="title-link" name="step-6-install-home-assistant" href="#step-6-install-home-assistant"></a> Step 6: Install Home Assistant</h2>
<p>Once your virtualenv has been activated, you dont need to sudo any of your pip commands. Pip will be installing things in the virtualenv, which our hass user has permission to modify.</p>
<p>Once your virtualenv has been activated, you dont need to <code>sudo</code> any of your pip commands. Pip will be installing things in the virtualenv, which our hass user has permission to modify.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>(hass)pip3 install --upgrade homeassistant
@ -181,9 +180,9 @@ sudo chown hass /srv/hass
<p>And thats it… you now have Home Assistant installed, and you can be sure that every bit of it is contained in /srv/hass</p>
<h2>Finally… Run Home Assistant</h2>
<h2><a class="title-link" name="finally-run-home-assistant" href="#finally-run-home-assistant"></a> Finally… Run Home Assistant</h2>
<p>There are two ways to launch Home Assistant. If you are in the virtualenv, you can just run <code>hass</code> and it will work as normal. If the virtualenv is not activated, you just use the hass executable in that bin directory I mentioned earlier. There is one caveat… Because Home Assistant stores its config in the users home directory, we need to be the hass user.</p>
<p>There are two ways to launch Home Assistant. If you are in the virtualenv, you can just run <code>hass</code> and it will work as normal. If the virtualenv is not activated, you just use the <code>hass</code> executable in the <code>bin</code> directory mentioned earlier. There is one caveat… Because Home Assistant stores its configuration in the users home directory, we need to be the user <code>hass</code> user or specify the configuration with <code>-c</code>.</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>sudo -u hass -H /srv/hass/bin/hass
@ -191,21 +190,21 @@ sudo chown hass /srv/hass
</div>
</div>
<p>The -H flag is important. It sets the <code>$HOME</code> environment variable to <code>/home/hass</code> so hass can find its configs.</p>
<p>The -H flag is important. It sets the <code>$HOME</code> environment variable to <code>/home/hass</code> so <code>hass</code> can find its configuration.</p>
<h2>Upgrading Home Assistant</h2>
<h2><a class="title-link" name="upgrading-home-assistant" href="#upgrading-home-assistant"></a> Upgrading Home Assistant</h2>
<p>Upgrading HA is simple, just repeat steps 3, 5 and 6.</p>
<p>Upgrading Home Assistant is simple, just repeat steps 3, 5 and 6.</p>
<h2>Starting Home Assistant on boot</h2>
<h2><a class="title-link" name="starting-home-assistant-on-boot" href="#starting-home-assistant-on-boot"></a> Starting Home Assistant on boot</h2>
<p>The autostart instructions on home-assistant.io will work just fine, just be sure to replace <code>/usr/bin/hass</code> with <code>/srv/hass/bin/hass</code> and specify the hass user where appropriate.</p>
<p>The <a href="/getting-started/autostart/">autostart instructions</a> will work just fine, just be sure to replace <code>/usr/bin/hass</code> with <code>/srv/hass/bin/hass</code> and specify the <code>hass</code> user where appropriate.</p>
<h2>Installing python-openzwave</h2>
<h2><a class="title-link" name="installing-python-openzwave" href="#installing-python-openzwave"></a> Installing python-openzwave</h2>
<p>If you want to use Z Wave devices, youll need to install python-openzwave in your virtualenv. This requires a small tweak to the instructions on home-assistant.io</p>
<p>If you want to use Z-Wave devices, you will need to install <code>python-openzwave</code> in your virtualenv. This requires a small tweak to the instructions on home-assistant.io</p>
<p>Install the dependencies as normal (note: youll need to do this as your normal user, since hass isnt a sudoer).</p>
<p>Install the dependencies as normal (Note: youll need to do this as your normal user, since hass isnt a sudoer).</p>
<div class="highlighter-coderay"><div class="CodeRay">
<div class="code"><pre>$ sudo apt-get install cython3 libudev-dev python3-sphinx python3-setuptools