Merge branch 'master' into next
This commit is contained in:
commit
0f14803a22
33 changed files with 294 additions and 123 deletions
|
@ -20,4 +20,24 @@ automation:
|
|||
|
||||
The available conditions for an automation are the same as for the script syntax. So see that page for a [full list of available conditions][script-condition].
|
||||
|
||||
Example of using condition:
|
||||
|
||||
```yaml
|
||||
- alias: 'Enciende Despacho'
|
||||
trigger:
|
||||
platform: state
|
||||
entity_id: sensor.mini_despacho
|
||||
to: 'ON'
|
||||
condition:
|
||||
condition: or
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: '{{ states.sun.sun.attributes.elevation < 4 }}'
|
||||
- condition: template
|
||||
value_template: '{{ states.sensor.sensorluz_7_0.state < 10 }}'
|
||||
action:
|
||||
- service: scene.turn_on
|
||||
entity_id: scene.DespiertaDespacho
|
||||
```
|
||||
|
||||
[script-condition]: /getting-started/scripts-conditions/
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
layout: page
|
||||
title: "Autostart using SystemD"
|
||||
description: "Instructions how to setup Home Assistant to launch on boot using SystemD."
|
||||
title: "Autostart using systemd"
|
||||
description: "Instructions how to setup Home Assistant to launch on boot using systemd."
|
||||
date: 2015-9-1 22:57
|
||||
sidebar: true
|
||||
comments: false
|
||||
|
@ -9,7 +9,7 @@ sharing: true
|
|||
footer: true
|
||||
---
|
||||
|
||||
Newer linux distributions are trending towards using systemd for managing daemons. Typically, systems based on Fedora or Debian 8 or later use systemd. This includes Ubuntu releases including and after 15.04, CentOS, and Red Hat. If you are unsure if your system is using `systemd`, you may check with the following command:
|
||||
Newer linux distributions are trending towards using `systemd` for managing daemons. Typically, systems based on Fedora, ArchLinux, or Debian (8 or later) use `systemd`. This includes Ubuntu releases including and after 15.04, CentOS, and Red Hat. If you are unsure if your system is using `systemd`, you may check with the following command:
|
||||
|
||||
```bash
|
||||
$ ps -p 1 -o comm=
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
---
|
||||
layout: page
|
||||
title: "Raspberry Pi All-In-One Installer"
|
||||
date: 2016-05-12 01:39
|
||||
comments: true
|
||||
sharing: true
|
||||
footer: true
|
||||
---
|
||||
|
||||
The "[Raspberry Pi All-In-One Installer](https://github.com/home-assistant/fabric-home-assistant)" deploys a complete Home Assistant server including support for MQTT with websocket support, Z-Wave, and the Open-Zwave-Control-Panel.
|
||||
|
||||
Requirements before installation:
|
||||
|
||||
* You have a Raspberry Pi with a fresh installation of [Raspbian Jessie/Jessie Lite](https://www.raspberrypi.org/downloads/raspbian/) connected to your network.
|
||||
* You are able to SSH into your Raspberry Pi.
|
||||
|
||||
|
||||
Installation instructions:
|
||||
|
||||
1. SSH into your Raspberry Pi
|
||||
2. Run `wget -Nnv https://raw.githubusercontent.com/home-assistant/fabric-home-assistant/master/hass_rpi_installer.sh && bash hass_rpi_installer.sh;`
|
||||
3. Installation will take approx 1-2 hour's depending on the model of Raspberry Pi the installer is being run against.
|
||||
|
||||
|
||||
Once rebooted, your Raspberry Pi will be up and running with Home Assistant. You can access it at **http://your_raspberry_pi_ip:8123**.
|
||||
|
||||
The Home Assistant configuration is located at `/home/hass`. The virtualenv with the Home Assistant installation is located at `/srv/hass/hass_venv`. As part of the secure installation, a new user is added to your Raspberry Pi to run Home Assistant as named, "hass". This is a system account and does not have login or other abilities by design. When editing your configuration.yaml files, you will need to run the commands as "Sudo" or switching users. Setting up WinSCP to allow this seemlessly is detailed below.
|
||||
|
||||
By default, installation makes use of a Python Virtualenv. If you wish to not follow this recommendation, you may add the flag `-n` to the end of the install command specified above.
|
||||
|
||||
The All-In-One installer script will do the following automatically:
|
||||
|
||||
* Create all needed directories
|
||||
* Create needed service accounts
|
||||
* Install OS and Python dependencies
|
||||
* Setup a python virtualenv to run Home Assistant and components inside.
|
||||
* Run as `hass` service account
|
||||
* Install Home Assistant in a virtualenv
|
||||
* Build and install Mosquitto from source with websocket support running on ports 1883 and 9001
|
||||
* Build and Install Python-openzwave in the Home Assistant virtualenv
|
||||
* Build openzwave-control-panel in `/srv/hass/src/open-zwave-control-panel`
|
||||
* Add both Home Assistant and Mosquitto to systemd services to start at boot
|
||||
|
||||
|
||||
|
||||
Windows Users - Please note that after running the installer, you will need to modify a couple settings allowing you to "switch users" to edit your configuration files. The needed change within WinSCP can be seen here: [Imgur](http://i.imgur.com/tlOljo6.jpg)
|
||||
|
|
@ -9,105 +9,104 @@ sharing: true
|
|||
footer: true
|
||||
---
|
||||
|
||||
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 won't interact with the rest of your system and vice-versa. It means a random upgrade for some other program on your computer won't break HA, and it means you don't need to install a bunch of Python packages as root.
|
||||
There are several reasons why it makes sense to run Home Assistant in a virtual environment. A [virtualenv](https://virtualenv.pypa.io/en/latest/) encapsulates all aspect of a Python environment within a single directory tree. That means the Python packages you install for Home Assistant won't interact with the rest of your system and vice-versa. It means a random upgrade for some other program on your computer won't break Home Assitant, and it means you don't need to install Python packages as root.
|
||||
|
||||
Virtualenvs are pretty easy to setup. This example will walk through one method of setting one up (there are certainly others). We'll 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.
|
||||
Virtualenvs are pretty easy to setup. This example will walk through one method of setting one up (there are certainly others). We'll 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.
|
||||
|
||||
## Step 0: Install some dependencies
|
||||
## {% linkable_title Step 0: Install some dependencies %}
|
||||
|
||||
```bash
|
||||
sudo apt-get update
|
||||
sudo apt-get upgrade
|
||||
sudo apt-get install python-pip
|
||||
sudo pip install --upgrade virtualenv
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get upgrade
|
||||
$ sudo apt-get install python-pip python3-dev
|
||||
$ sudo pip install --upgrade virtualenv
|
||||
```
|
||||
|
||||
## Step 1: Create a Home Assistant user
|
||||
## {% linkable_title Step 1: Create a Home Assistant user %}
|
||||
|
||||
This step is optional, but it's 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 OS's (or even other Linux distros).
|
||||
This step is optional, but it's 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).
|
||||
|
||||
```bash
|
||||
sudo adduser --system hass
|
||||
$ sudo adduser --system hass
|
||||
```
|
||||
|
||||
Home Assistant stores its config in `$HOME/.homeassistant` by default, so in this case, it would be in `/home/hass/.homeassistant`
|
||||
Home Assistant stores its configuration in `$HOME/.homeassistant` by default, so in this case, it would be in `/home/hass/.homeassistant`
|
||||
|
||||
If you plan to use a Z-Wave controller, you will need to add this user to the `dialout` group
|
||||
|
||||
```bash
|
||||
sudo usermod -G dialout -a hass
|
||||
$ sudo usermod -G dialout -a hass
|
||||
```
|
||||
|
||||
## Step 2: Create a directory for Home Assistant
|
||||
## {% linkable_title Step 2: Create a directory for Home Assistant %}
|
||||
|
||||
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)
|
||||
This can be anywhere you want. AS example we put it in `/srv`. You also need to change the ownership of the directory to the user you created above (if you created one).
|
||||
|
||||
```bash
|
||||
sudo mkdir /srv/hass
|
||||
sudo chown hass /srv/hass
|
||||
$ sudo mkdir /srv/hass
|
||||
$ sudo chown hass /srv/hass
|
||||
```
|
||||
## {% linkable_title Step 3: Become the new user %}
|
||||
|
||||
## Step 3: Become the new user
|
||||
|
||||
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 you'll end up with mucked up permissions.
|
||||
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 you'll end up with mucked up permissions.
|
||||
|
||||
```bash
|
||||
sudo su -s /bin/bash hass
|
||||
$ sudo su -s /bin/bash hass
|
||||
```
|
||||
|
||||
The 'su' command means 'switch' user. We use the '-s' flag because the hass user is a system user and doesn't have a default shell by default (to prevent attackers from being able to log in as that user).
|
||||
The `su` command means 'switch' user. We use the '-s' flag because the `hass` user is a system user and doesn't have a default shell by default (to prevent attackers from being able to log in as that user).
|
||||
|
||||
## Step 4: Set up the virtualenv
|
||||
## {% linkable_title Step 4: Set up the virtualenv %}
|
||||
|
||||
All this step does is stick a Python environment in the directory we're using. That's it. It's just a directory. There's nothing 'special' about it, and it is entirely self-contained.
|
||||
|
||||
It will include a 'bin' directory, which will contain all the executables used in the virtualenv (including hass itself). It also includes a script called 'activate' which we will use to activate the virtualenv.
|
||||
It will include a `bin` directory, which will contain all the executables used in the virtualenv (including hass itself). It also includes a script called `activate` which we will use to activate the virtualenv.
|
||||
|
||||
```bash
|
||||
virtualenv -p python3 /srv/hass
|
||||
$ virtualenv -p python3 /srv/hass
|
||||
```
|
||||
|
||||
## Step 5: Activate the virtualenv
|
||||
## {% linkable_title Step 5: Activate the virtualenv %}
|
||||
|
||||
```bash
|
||||
source /srv/hass/bin/activate
|
||||
$ source /srv/hass/bin/activate
|
||||
```
|
||||
|
||||
After that, your prompt should include '(hass)'.
|
||||
After that, your prompt should include `(hass)`.
|
||||
|
||||
## Step 6: Install Home Assistant
|
||||
## {% linkable_title Step 6: Install Home Assistant %}
|
||||
|
||||
Once your virtualenv has been activated, you don't need to 'sudo' any of your pip commands. Pip will be installing things in the virtualenv, which our 'hass' user has permission to modify.
|
||||
Once your virtualenv has been activated, you don't need to `sudo` any of your `pip` commands. `pip` will be installing things in the virtualenv, which the `hass` user has permission to modify.
|
||||
|
||||
```bash
|
||||
(hass)pip3 install --upgrade homeassistant
|
||||
(hass)$ pip3 install --upgrade homeassistant
|
||||
```
|
||||
|
||||
And that's it... you now have Home Assistant installed, and you can be sure that every bit of it is contained in /srv/hass
|
||||
And that's it... you now have Home Assistant installed, and you can be sure that every bit of it is contained in `/srv/hass`.
|
||||
|
||||
## Finally... Run Home Assistant
|
||||
## {% linkable_title Finally... Run Home Assistant %}
|
||||
|
||||
There are two ways to launch Home Assistant. If you are 'in' the virtualenv, you can just run `hass` 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 it's config in the user's home directory, we need to be the hass user.
|
||||
There are two ways to launch Home Assistant. If you are **in** the virtualenv, you can just run `hass` and it will work as normal. If the virtualenv is not activated, you just use the `hass` executable in the `bin` directory mentioned earlier. There is one caveat... Because Home Assistant stores it's configuration in the user's home directory, we need to be the user `hass` user or specify the configuration with `-c`.
|
||||
|
||||
```bash
|
||||
sudo -u hass -H /srv/hass/bin/hass
|
||||
$ sudo -u hass -H /srv/hass/bin/hass
|
||||
```
|
||||
|
||||
The '-H' flag is important. It sets the `$HOME` environment variable to `/home/hass` so hass can find its configs.
|
||||
The `-H` flag is important. It sets the `$HOME` environment variable to `/home/hass` so `hass` can find its configuration.
|
||||
|
||||
## Upgrading Home Assistant
|
||||
## {% linkable_title Upgrading Home Assistant %}
|
||||
|
||||
Upgrading HA is simple, just repeat steps 3, 5 and 6.
|
||||
Upgrading Home Assistant is simple, just repeat steps 3, 5 and 6.
|
||||
|
||||
## Starting Home Assistant on boot
|
||||
## {% linkable_title Starting Home Assistant on boot %}
|
||||
|
||||
The autostart instructions on home-assistant.io will work just fine, just be sure to replace `/usr/bin/hass` with `/srv/hass/bin/hass` and specify the 'hass' user where appropriate.
|
||||
The [autostart instructions](/getting-started/autostart/) will work just fine, just be sure to replace `/usr/bin/hass` with `/srv/hass/bin/hass` and specify the `hass` user where appropriate.
|
||||
|
||||
## Installing python-openzwave
|
||||
## {% linkable_title Installing python-openzwave %}
|
||||
|
||||
If you want to use Z Wave devices, you'll need to install python-openzwave in your virtualenv. This requires a small tweak to the instructions on home-assistant.io
|
||||
If you want to use Z-Wave devices, you will need to install `python-openzwave` in your virtualenv. This requires a small tweak to the instructions on home-assistant.io
|
||||
|
||||
Install the dependencies as normal (note: you'll need to do this as your normal user, since 'hass' isn't a sudoer).
|
||||
Install the dependencies as normal (Note: you will need to do this as your normal user, since `hass` isn't a sudoer).
|
||||
|
||||
```bash
|
||||
$ sudo apt-get install cython3 libudev-dev python3-sphinx python3-setuptools
|
||||
|
@ -119,7 +118,7 @@ Then, activate your virtualenv (steps 3 and 5 above) and upgrade cython.
|
|||
(hass)$ pip3 install --upgrade cython
|
||||
```
|
||||
|
||||
Finally, get and install python-openzwave
|
||||
Finally, get and install `python-openzwave`.
|
||||
|
||||
```bash
|
||||
(hass)$ mkdir /srv/hass/src
|
||||
|
|
|
@ -26,6 +26,42 @@ conditions:
|
|||
below: '20'
|
||||
```
|
||||
|
||||
#### {% linkable_title OR condition %}
|
||||
|
||||
Test multiple conditions in 1 condition statement. Passes if any embedded conditions is valid.
|
||||
|
||||
```yaml
|
||||
condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: 'device_tracker.paulus'
|
||||
state: 'home'
|
||||
- condition: numeric_state
|
||||
entity_id: 'sensor.temperature'
|
||||
below: '20'
|
||||
```
|
||||
|
||||
#### {% linkable_title MIXED AND and OR conditions %}
|
||||
|
||||
Test multiple AND and OR conditions in 1 condition statement. Passes if any embedded conditions is valid.
|
||||
This allows you to mix several AND and OR conditions together.
|
||||
|
||||
```yaml
|
||||
condition: and
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: 'device_tracker.paulus'
|
||||
state: 'home'
|
||||
- condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: sensor.weather_precip
|
||||
state: 'rain'
|
||||
- condition: numeric_state
|
||||
entity_id: 'sensor.temperature'
|
||||
below: '20'
|
||||
```
|
||||
|
||||
#### {% linkable_title Numeric state condition %}
|
||||
|
||||
This type of condition attempts to parse the state of specified entity as a number and triggers if the value matches all of the above or below thresholds.
|
||||
|
@ -43,21 +79,6 @@ below: 25
|
|||
value_template: {{ float(state.state) + 2 }}
|
||||
```
|
||||
|
||||
#### {% linkable_title OR condition %}
|
||||
|
||||
Test multiple conditions in 1 condition statement. Passes if any embedded conditions is valid.
|
||||
|
||||
```yaml
|
||||
condition: or
|
||||
conditions:
|
||||
- condition: state
|
||||
entity_id: 'device_tracker.paulus'
|
||||
state: 'home'
|
||||
- condition: numeric_state
|
||||
entity_id: 'sensor.temperature'
|
||||
below: '20'
|
||||
```
|
||||
|
||||
#### {% linkable_title State condition %}
|
||||
|
||||
Tests if an entity is a specified state.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue