Skip to content

Re-organisation Documentation and Getting started #2055

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

Merged
merged 51 commits into from
Feb 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
4385785
Split MQTT documentation
fabaff Feb 12, 2017
416eecb
Add more details
fabaff Feb 13, 2017
78683e6
Move content to /docs
fabaff Feb 15, 2017
dfa0e8f
Enable sidebar
fabaff Feb 15, 2017
3d28d68
Move content to /docs
fabaff Feb 15, 2017
015a28c
Enable sidebar
fabaff Feb 15, 2017
9001808
Move content
fabaff Feb 15, 2017
81e1a8b
Update links
fabaff Feb 15, 2017
f854f43
Remove wizard stuff
fabaff Feb 15, 2017
a03037c
Enable sidebar
fabaff Feb 15, 2017
a6957e2
Minor changes
fabaff Feb 15, 2017
69fe8cb
Move MQTT parts to /docs
fabaff Feb 15, 2017
feac838
update links
fabaff Feb 15, 2017
ec4c091
Update links and sync content
fabaff Feb 15, 2017
e44111e
Fix link
fabaff Feb 15, 2017
895bacb
Enable sidebar
fabaff Feb 15, 2017
d8ab0a1
Remove navigation
fabaff Feb 15, 2017
ac8d46d
Remove navigation and other minor updates
fabaff Feb 15, 2017
f761fd5
Update links
fabaff Feb 15, 2017
de8c9a6
Add overview page
fabaff Feb 15, 2017
8bc90c7
Make title linkable
fabaff Feb 15, 2017
df63b06
Update
fabaff Feb 15, 2017
a61bf8f
Plit content
fabaff Feb 15, 2017
37a37d6
Update links
fabaff Feb 16, 2017
7e41189
Rearrange content
fabaff Feb 16, 2017
36d9d6f
New getting-started section
fabaff Feb 16, 2017
6e819e6
Add icons for docs
fabaff Feb 16, 2017
5d7bfea
Update for new structure
fabaff Feb 16, 2017
5e2360c
Update for new structure
fabaff Feb 16, 2017
623f129
Add docs navigation
fabaff Feb 16, 2017
70c819c
Add docs overview page
fabaff Feb 16, 2017
4226964
Remove ecosystem navigation
fabaff Feb 16, 2017
08fb15f
Add docs and remove other collections
fabaff Feb 16, 2017
2cb6712
Move ecosystem to docs
fabaff Feb 16, 2017
52576ec
Remove duplicate files
fabaff Feb 17, 2017
94adff3
Re-add ecosystem overview
fabaff Feb 17, 2017
38a515d
Move to ecosystem
fabaff Feb 17, 2017
d576761
Fix permission
fabaff Feb 17, 2017
0a1786f
Update navigation
fabaff Feb 17, 2017
e7a46c6
Remove collection
fabaff Feb 20, 2017
aea29ff
Move overview to right folder
fabaff Feb 20, 2017
4f5a6d9
Move mqtt to upper level
fabaff Feb 20, 2017
ea601a3
Move notebook to ecosystem
fabaff Feb 20, 2017
41ca677
Remove un-used files
fabaff Feb 21, 2017
dace65a
Add one more rectangle for iOS
fabaff Feb 21, 2017
2e3a676
Move two parts back from docs and rename Run step
fabaff Feb 21, 2017
d4f00d3
Remove colon
fabaff Feb 21, 2017
363052a
update getting-started section
fabaff Feb 21, 2017
736c529
Add redirect
fabaff Feb 21, 2017
10f4381
Update
fabaff Feb 21, 2017
d344122
Update navigation
fabaff Feb 21, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,6 @@ collections:
output: true
cookbook:
output: true
ecosystem:
output: true
details:
output: true
topics:
output: true

# ----------------------- #
# 3rd Party Settings #
Expand Down
289 changes: 12 additions & 277 deletions source/_components/mqtt.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -16,295 +16,30 @@ ha_iot_class: depends

MQTT (aka MQ Telemetry Transport) is a machine-to-machine or "Internet of Things" connectivity protocol on top of TCP/IP. It allows extremely lightweight publish/subscribe messaging transport.

To integrate MQTT into Home Assistant, add the following section to your `configuration.yaml` file:
Your first step to get MQTT and Home Assistant working is the choose a [broker](/docs/mqtt/broker).

```yaml
# Example configuration.yaml entry
mqtt:
broker: IP_ADDRESS_BROKER
port: 1883
client_id: home-assistant-1
keepalive: 60
username: USERNAME
password: PASSWORD
certificate: /home/paulus/dev/addtrustexternalcaroot.crt
protocol: 3.1
discovery: "discovery/#"
birth_message:
topic: 'hass/status'
payload: 'online'
qos: 1
retain: true
will_message:
topic: 'hass/status'
payload: 'offline'
qos: 1
retain: true
```

Configuration variables:

- **broker** (*Required*): The IP address or hostname of your MQTT broker, e.g. 192.168.1.32.
- **port** (*Optional*): The network port to connect to. Default is 1883.
- **client_id** (*Optional*): The client ID that Home Assistant will use. Has to be unique on the server. Default is a randomly generated one.
- **keepalive** (*Optional*): The time in seconds between sending keep alive messages for this client. Default is 60.
- **username** (*Optional*): The username to use with your MQTT broker.
- **password** (*Optional*): The corresponding password for the username to use with your MQTT broker.
- **certificate** (*Optional*): The certificate authority certificate file that is to be treated as trusted by this client. This file should contain the root certificate of the certificate authority that signed your broker's certificate, but may contain multiple certificates. Example: `/home/user/identrust-root.pem`
- **client_key** (*Optional*): Client key (example: `/home/user/owntracks/cookie.key`)
- **client_cert** (*Optional*): Client certificate (example: `/home/user/owntracks/cookie.crt`)
- **protocol** (*Optional*): Protocol to use: 3.1 or 3.1.1. By default it connects with 3.1.1 and falls back to 3.1 if server does not support 3.1.
- **discovery** (*Optional*): The MQTT topic subscribed to use for discovery of MQTT devices.
- **birth_message** (*Optional*):
- **topic** (*Required*): The MQTT topic to publish the message.
- **payload** (*Required*): The message content.
- **qos** (*Optional*): The maximum QoS level of the topic. Default is 0.
- **retain** (*Optional*): If the published message should have the retain flag on or not. Defaults to `True`.
- **will_message** (*Optional*):
- **topic** (*Required*): The MQTT topic to publish the message.
- **payload** (*Required*): The message content.
- **qos** (*Optional*): The maximum QoS level of the topic. Default is 0.
- **retain** (*Optional*): If the published message should have the retain flag on or not. Defaults to `True`.

## {% linkable_title Picking a broker %}

The MQTT component needs you to run an MQTT broker for Home Assistant to connect to. There are four options, each with various degrees of ease of setup and privacy.

### {% linkable_title Embedded broker %}

Home Assistant contains an embedded MQTT broker. If no broker configuration is given, the [HBMQTT broker](https://pypi.python.org/pypi/hbmqtt) is started and Home Assistant connects to it. Embedded broker default configuration:

| Setting | Value |
| ------- | ----- |
| Host | localhost
| Port | 1883
| Protocol | 3.1.1
| User | homeassistant
| Password | Your API [password](/components/http/)
| Websocket port | 8080
To integrate MQTT into Home Assistant, add the following section to your `configuration.yaml` file. Keep in mind that the minimal setup will run with [an embedded MQTT broker](/docs/mqtt/broker#embedded-broker):

```yaml
# Example configuration.yaml entry
mqtt:
```

<p class='note'>
This broker does not currently work with OwnTracks because of a protocol version issue.
</p>

If you want to customize the settings of the embedded broker, use `embedded:` and the values shown in the [HBMQTT Broker configuration](http://hbmqtt.readthedocs.org/en/latest/references/broker.html#broker-configuration). This will replace the default configuration.

```yaml
# Example configuration.yaml entry
mqtt:
embedded:
# Your HBMQTT config here. Example at:
# http://hbmqtt.readthedocs.org/en/latest/references/broker.html#broker-configuration
```

### {% linkable_title Run your own %}

This is the most private option but requires a bit more work. There are two free and open-source brokers to pick from: [Mosquitto](http://mosquitto.org/) and [Mosca](http://www.mosca.io/).
To connect to your [own MQTT broker](/docs/mqtt/broker#run-your-own):

```yaml
# Example configuration.yaml entry
mqtt:
broker: 192.168.1.100
port: 1883
client_id: home-assistant-1
keepalive: 60
username: USERNAME
password: PASSWORD
```

<p class='note warning'>
There is an issue with the Mosquitto package included in Ubuntu 14.04 LTS. Specify `protocol: 3.1` in your MQTT configuration to work around this issue.
</p>

<p class='note'>
If you are running a mosquitto instance on a different server with proper SSL encryption using a service like letsencrypt you may have to set the certificate to the operating systems own `.crt` certificates file. In the instance of ubuntu this would be `certificate: /etc/ssl/certs/ca-certificates.crt`
</p>

### {% linkable_title Public broker %}

The Mosquitto project runs a [public broker](http://test.mosquitto.org). This is the easiest to set up, but there is no privacy as all messages are public. Use this only for testing purposes and not for real tracking of your devices.

```yaml
mqtt:
broker: test.mosquitto.org
port: 1883

# Optional, replace port 1883 with following if you want encryption
# (doesn't really matter because broker is public)
port: 8883
# Download certificate from http://test.mosquitto.org/ssl/mosquitto.org.crt
certificate: /home/paulus/downloads/mosquitto.org.crt
```

### {% linkable_title CloudMQTT %}

[CloudMQTT](https://www.cloudmqtt.com) is a hosted private MQTT instance that is free for up to 10 connected devices. This is enough to get started with for example [OwnTracks](/components/device_tracker.owntracks/) and give you a taste of what is possible.

<p class='note'>
Home Assistant is not affiliated with CloudMQTT nor will receive any kickbacks.
</p>

1. [Create an account](https://customer.cloudmqtt.com/login) (no payment details needed)
2. [Create a new CloudMQTT instance](https://customer.cloudmqtt.com/subscription/create)
(Cute Cat is the free plan)
3. From the control panel, click on the _Details_ button.
4. Create unique users for Home Assistant and each phone to connect<br>(CloudMQTT does not allow two
connections from the same user)
1. Under manage users, fill in username, password and click add
2. Under ACLs, select user, topic `#`, check 'read access' and 'write access'
5. Copy the instance info to your configuration.yaml:

```yaml
mqtt:
broker: <Server>
port: <SSL Port>
username: <User>
password: <Password>
```

<p class='note'>
Home Assistant will automatically load the correct certificate if you connect to an encrypted channel of CloudMQTT (port range 20 000 - 30 000).
</p>

## {% linkable_title Building on top of MQTT %}

- [MQTT Alarm control panel](/components/alarm_control_panel.mqtt/)
- [MQTT Binary sensor](/components/binary_sensor.mqtt/)
- [MQTT Sensor](/components/sensor.mqtt/)
- [MQTT Switch](/components/switch.mqtt/)
- [MQTT Light](/components/light.mqtt/)
- [MQTT Lock](/components/lock.mqtt/)
- [MQTT Device Tracker](/components/device_tracker.mqtt/)
- [OwnTracks Device Tracker](/components/device_tracker.owntracks/)
- [MQTT automation rule](/getting-started/automation-trigger/#mqtt-trigger)

- Integrating it into own component. See the [MQTT example component](/cookbook/python_component_mqtt_basic/) how to do this.

## {% linkable_title Publish service %}

The MQTT component will register the service `publish` which allows publishing messages to MQTT topics. There are two ways of specifying your payload. You can either use `payload` to hard-code a payload or use `payload_template` to specify a [template](/topics/templating/) that will be rendered to generate the payload.

```json
{
"topic": "home-assistant/light/1/command",
"payload": "on"
}
```

```json
{
"topic": "home-assistant/light/1/state",
"payload_template": "{% raw %}{{ states('device_tracker.paulus') }}{% endraw %}"
}
```

## {% linkable_title Discovery %}

The discovery of MQTT devices will enable one to use MQTT devices with only minimal configuration effort on the side of Home Assistant. The configuration is done on the device itself and the topic used by the device. Similar to the [HTTP binary sensor](/components/binary_sensor.http/) and the [HTTP sensor](/components/sensor.http/). Only support for binary sensor is available at the moment.

To enable MQTT discovery, add the following to your `configuration.yaml` file:

```yaml
# Example configuration.yaml entry
mqtt:
discovery: true
# Optional
discovery_prefix: homeassistant
```

A motion detection device for your garden would sent its configuration as JSON payload `{"name": "garden", "sensor_class": "motion"}` to the topic `homeassistant/binary_sensor/garden/config`. After the first message to `config`, then the MQTT messages sent to `state`, eg. `homeassistant/binary_sensor/garden/state`, will update the state in Home Assistant.

## {% linkable_title Logging %}

The [logger](/components/logger/) component allow the logging of received MQTT messages.

```yaml
# Example configuration.yaml entry
logger:
default: warning
logs:
homeassistant.components.device_tracker.mqtt: debug
```

## {% linkable_title Testing your setup %}

The `mosquitto` broker package ships commandline tools to send and receive MQTT messages. As an alternative have a look at [hbmqtt_pub](http://hbmqtt.readthedocs.org/en/latest/references/hbmqtt_pub.html) and [hbmqtt_sub](http://hbmqtt.readthedocs.org/en/latest/references/hbmqtt_sub.html) which are provided by HBMQTT. For sending test messages to a broker running on localhost check the example below:

```bash
$ mosquitto_pub -h 127.0.0.1 -t home-assistant/switch/1/on -m "Switch is ON"
```

If you are using the embedded MQTT broker, the command looks a little different because you need to add the MQTT protocol version.

```bash
$ mosquitto_pub -V mqttv311 -t "hello" -m world
```

or if you are using a API password:

```bash
$ mosquitto_pub -V mqttv311 -u homeassistant -P <your api password> -t "hello" -m world
```

Another way to send MQTT messages by hand is to use the "Developer Tools" in the Frontend. Choose "Call Service" and then `mqtt/mqtt_send` under "Available Services". Enter something similar to the example below into the "Service Data" field.

```json
{
"topic":"home-assistant/switch/1/on",
"payload":"Switch is ON"
}
```

The message should appear on the bus:

```bash
... [homeassistant] Bus:Handling <Event MQTT_MESSAGE_RECEIVED[L]: topic=home-assistant/switch/1/on, qos=0, payload=Switch is ON>
```

For reading all messages sent on the topic `home-assistant` to a broker running on localhost:

```bash
$ mosquitto_sub -h 127.0.0.1 -v -t "home-assistant/#"
```

For the embedded MQTT broker the command looks like:

```bash
$ mosquitto_sub -v -V mqttv311 -t "#"
```

Add the username `homeassistant` and your API password if needed.

## {% linkable_title Processing JSON %}

The MQTT switch and sensor platforms support processing JSON over MQTT messages and parsing them using JSONPath. JSONPath allows you to specify where in the JSON the value resides that you want to use. The following examples will always return the value `100`.

| JSONPath query | JSON |
| -------------- | ---- |
| `somekey` | `{ 'somekey': 100 }`
| `somekey[0]` | `{ 'somekey': [100] }`
| `somekey[0].value` | `{ 'somekey': [ { value: 100 } ] }`

To use this, add the following key to your `configuration.yaml`:

```yaml
switch:
platform: mqtt
state_format: 'json:somekey[0].value'
broker: IP_ADDRESS_BROKER
```
It is also possible to extract JSON values by using a value template:

```yaml
switch:
platform: mqtt
value_template: '{% raw %}{{ value_json.somekey[0].value }}{% endraw %}'
```
## {% linkable_title Additional features %}

More information about the full JSONPath syntax can be found [here][JSONPath syntax].
- [Certificate](/docs/mqtt/certificate/)
- [Discovery](/docs/mqtt/discovery/)
- [Publish service](/docs/mqtt/service/)
- [Birth and last will messages](/docs/mqtt/birth_will/)
- [Testing your setup](/docs/mqtt/testing/)
- [Logging](/docs/mqtt/logging/)
- [Processing JSON](/docs/mqtt/processing_json/)

[JSONPath syntax]: https://github.com/kennknowles/python-jsonpath-rw#jsonpath-syntax
9 changes: 7 additions & 2 deletions source/_components/zwave.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ ha_category: Hub
featured: true
---

Please see the [getting started section] for in-depth documentation on how to use the Z-Wave component.
The [Z-Wave](http://www.z-wave.com/) integration for Home Assistant allows you to observe and control connected Z-Wave devices. Please see the [Z-Wave getting started section](/docs/z-wave/) for in-depth documentation on how to use and setup the Z-Wave component.

[getting started section]: /getting-started/z-wave/
If you have setup the requirements, then add the following entry `configuration.yaml` file:

```yaml
# Example configuration.yaml entry
zwave:
```
49 changes: 49 additions & 0 deletions source/_docs/automation.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
layout: page
title: "Automating Home Assistant"
description: "Steps to help you get automation setup in Home Assistant."
date: 2015-09-19 09:40
sidebar: true
comments: false
sharing: true
footer: true
---

Home Assistant offers a wide range of automation configurations. In this section, we'll try to guide you through all the different possibilities and options. Besides this documentation, there are also a couple of people who have made their automations [publicly available][/cookbook/#example-configurationyaml].

### {% linkable_title Automation basics %}

Before you can go ahead and create your own automations, it's important to learn the basics. To explore these, let's have a look at the following example home automation rule:

```text
(trigger) When Paulus arrives home
(condition) and it is after sunset:
(action) Turn the lights in the living room on
```

The example consists of three different parts: a [trigger](/docs/automation/trigger/), a [condition](/docs/automation/condition/) and an [action](/docs/automation/action/).

The first line is the **trigger** of the automation rule. Triggers describe events that should trigger the automation rule. In this case, it is a person arriving home, which can be observed in Home Assistant by observing the state of Paulus changing from 'not_home' to 'home'.

The second line is the **condition**. Conditions are optional tests that can limit an automation rule to only work in your specific use cases. A condition will test against the current state of the system. This includes the current time, devices, people and other things like the sun. In this case, we only want to act when the sun has set.

The third part is the **action**, which will be performed when a rule is triggered and all conditions are met. For example, it can turn a light on, set the temperature on your thermostat or activate a scene.

<p class='note'>
The difference between a condition and a trigger can be confusing as they are very similar. Triggers look at the actions, while conditions look at the results: turning a light on versus a light being on.
</p>

### {% linkable_title Exploring the internal state %}

Automation rules interact directly with the internal state of Home Assistant, so you'll need to familiarize yourself with it. Home Assistant exposes its current state via the developer tools. These are available at the bottom of the sidebar in the frontend. The <img src='/images/screenshots/developer-tool-states-icon.png' class='no-shadow' height='38' /> icon will show all currently available states. An entity can be anything. A light, a switch, a person and even the sun. A state consists of the following parts:

| Name | Description | Example |
| ---- | ----- | ---- |
| Entity ID | Unique identifier for the entity. | `light.kitchen`
| State | The current state of the device. | `home`
| Attributes | Extra data related to the device and/or current state. | `brightness`

State changes can be used as the source of triggers and the current state can be used in conditions.

Actions are all about calling services. To explore the available services open the <img src='/images/screenshots/developer-tool-services-icon.png' class='no-shadow' height='38' /> Services developer tool. Services allow to change anything. For example turn on a light, run a script or enable a scene. Each service has a domain and a name. For example the service `light.turn_on` is capable of turning on any light in your system. Services can be passed parameters to for example tell which device to turn on or what color to use.

Loading