Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
10 changes: 10 additions & 0 deletions source/_addons/lets_encrypt.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ Configuration variables:

- **email** (*Required*): Your email address for registration on Let's Encrypt.
- **domains** (*Required*): A list of domains to create/renew the certificate.

## {% linkable_title Home Assistant configuration %}

Use the following configuration in Home Assistant to use the generated certificate:

```yaml
http:
ssl_certificate: /ssl/fullchain.pem
ssl_key: /ssl/privkey.pem
```
5 changes: 2 additions & 3 deletions source/_components/device_tracker.unifi.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ Configuration variables:
- **port** (*Optional*): The port of your controller's web interface. Defaults to `8443`.
- **username** (*Required*: The username of an user with administrative privileges, usually `admin`.
- **password** (*Required*): The password for your given admin account.
- **verify_ssl** (*Optional*): Verify the controllers SSL certificate. Defaults to True however can also be False or "path/to/custom_cert.pem".
- **site_id** (*Optional*): Allows you to specify a `site_id` for device tracking. Defaults to `default`. Found in the URL of the controller (i.e. https://CONTROLLER:PORT/manage/site/SITE_ID/dashboard)
- **verify_ssl** (*Optional*): Controls if the SSL certificate running on your Unifi webserver must be trusted by a known Certificate Authority on the server running Home Assistant. Defaults to 'True'.
- **site_id** (*Optional*): Allows you to specify a `site_id` for device tracking. Defaults to `default`. Found in the URL of the controller (i.e. https://CONTROLLER:PORT/manage/site/SITE_ID/dashboard).
- **verify_ssl** (*Optional*): Controls if the SSL certificate running on your Unifi webserver must be trusted by a known Certificate Authority on the server running Home Assistant. Defaults to 'True' but can also be a value that points to your custom cert "path/to/custom_cert.pem".

See the [device tracker component page](/components/device_tracker/) for instructions how to configure the people to be tracked.
32 changes: 17 additions & 15 deletions source/_components/discovery.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Home Assistant can discover and automatically configure zeroconf/mDNS and uPnP d
* Linn / Openhome
* Denon Network Receivers
* Bose Soundtouch speakers
* IKEA Trådfri (Tradfri)

It will be able to add Google Chromecasts and Belkin WeMo switches automatically, for Philips Hue it will require some configuration from the user.

Expand All @@ -49,22 +50,23 @@ Configuration variables:
- **ignore** (*Optional*): A list of platforms that never will be automatically configured by `discovery`.

Valid values for ignore are:
* philips_hue: (Philips Hue)
* google_cast: (Google Chromecast)
* panasonic_viera: (Panasonic Viera)
* plex_mediaserver: (Plex media server)
* roku: (Roku media player)
* sonos: (Sonos Speakers)
* yamaha: (Yamaha media player)
* logitech_mediaserver: (Logitech media server - Squeezebox player)
* directv: (DirecTV)
* denonavr: (Denon Network Receivers)
* samsung_tv: (Samsung TV)
* yeelight: (Yeelight Sunflower Bulb)
* flux_led: (Flux Led/MagicLight)
* apple_tv: (Apple TV)
* openhome: (Linn / Openhome)

* `apple_tv`: Apple TV
* `denonavr`: Denon Network Receivers
* `directv`: DirecTV
* `flux_led`: Flux Led/MagicLight
* `google_cast`: Google Chromecast
* `ikea_tradfri`: IKEA Trådfri
* `logitech_mediaserver`: Logitech media server - Squeezebox player
* `openhome`: Linn / Openhome
* `panasonic_viera`: Panasonic Viera
* `philips_hue`: Philips Hue
* `plex_mediaserver`: Plex media server
* `roku`: Roku media player
* `samsung_tv`: (Samsung TV
* `sonos`: Sonos Speakers
* `yamaha`: Yamaha media player
* `yeelight`: Yeelight Sunflower Bulb

<p class='note'>
Home Assistant must be on the same network as the devices for uPnP discovery to work.
Expand Down
12 changes: 12 additions & 0 deletions source/_components/media_player.sonos.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,15 @@ Clear the sleep timer on a speaker, if one is set.
| ---------------------- | -------- | ----------- |
| `entity_id` | no | String or list of `entity_id`s that will have their timers cleared. Must be a coordinator speaker.

### {% linkable_title Service `sonos_update_alarm` %}

Update an existing sonos alarm.

| Service data attribute | Optional | Description |
| ---------------------- | -------- | ----------- |
| `entity_id` | no | String or list of `entity_id`s that will have their timers cleared. Must be a coordinator speaker.
| `alarm_id` | no | Integer that is used in Sonos to refer to your alarm.
| `time` | yes | Time to set the alarm.
| `volume` | yes | Float for volume level.
| `enabled` | yes | Boolean for whether or not to enable this alarm.
| `include_linked_zones` | yes | Boolean that defines if the alarm also plays on grouped players.
8 changes: 4 additions & 4 deletions source/_components/plant.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ plant:
name_of_your_plant:
sensors:
moisture: sensor.my_sensor_moisture
battery: sensor.my_sensor_moisture_battery
temperature: sensor.my_sensor_moisture_temperature
conductivity: sensor.my_sensor_moisture_conductivity
brightness: sensor.my_sensor_moisture_brightness
battery: sensor.my_sensor_battery
temperature: sensor.my_sensor_temperature
conductivity: sensor.my_sensor_conductivity
brightness: sensor.my_sensor_brightness
min_moisture: 20
```

Expand Down
1 change: 1 addition & 0 deletions source/_includes/asides/hassio_navigation.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ <h1 class="title delta">Topics</h1>
<li>
{% active_link /hassio/addon_development/ Add-on Development %}
<ul>
<li>{% active_link /hassio/addon_tutorial/ Tutorial: Making your first add-on %}</li>
<li>{% active_link /hassio/addon_config/ Configuration %}</li>
<li>{% active_link /hassio/addon_testing/ Local Testing %}</li>
<li>{% active_link /hassio/addon_publishing/ Publishing %}</li>
Expand Down
47 changes: 29 additions & 18 deletions source/developers/development_testing.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,28 @@ sharing: true
footer: true
---

As states in the [Style guidelines section](/developers/development_guidelines/) all code is checked as part of the linting process and unit test were run.

### {% linkable_title Local testing %}

**Important:** Run `tox` before you create your pull request to avoid annoying fixes. Local testing requires installing `tox`.
As states in the [Style guidelines section](/developers/development_guidelines/) all code is checked to verify all unit tests pass and that the code passes the linting tools. Local testing is done using Tox, which has been installed as part of running `script/setup`. To start the tests, simply run it:

```bash
$ pip3 install tox
$ tox
```
**Important:** Run `tox` before you create your pull request to avoid annoying fixes.

Start your code test with `tox`.
Running Tox will run unit tests against the locally available Pythons, as well as validate the code and document style using `pycodestyle`, `pydocstyle` and `pylint`. You can run tests on only one tox target -- just use `-e` to select an environment. For example, `tox -e lint` runs the linters only, and `tox -e py34` runs unit tests only on Python 3.4.

```bash
$ tox
```
Tox uses virtual environments under the hood to create isolated testing environments. The tox virtual environments will get out-of-date when requirements change, causing test errors. Run `tox -r` to tell Tox to recreate the virtual environments.

This will run unit tests against Python 3.4 and 3.5 (if both are available locally), as well as tests that validate `pep8` and `pylint` style.
If you are working on tests for a component or platform and you need the dependencies available inside the Tox environment, update the list inside `script/gen_requirements_all.py`. Then run the script and then run `tox -r` to recreate the virtual environments.

#### {% linkable_title Testing Tips %}
### {% linkable_title Testing single files %}

You can run tests on only one tox target -- just use `-e` to select an environment. For example, `tox -e lint` runs the linters only, and `tox -e py34` runs unit tests only on Python 3.4.
Running tox will invoke the full test suite. Even if you specify which tox target to run, you still run all tests inside that target. That's not very convenient to quickly iterate on your code! To be able to run the specific test suites without Tox, you'll need to install the test dependencies into your Python environment:

tox uses virtual environments under the hood to create isolated testing environments. The tox virtual environments will get out-of-date when requirements change, causing test errors. Run `tox -r` to create new tox virtual environments.
```bash
$ bash pip3 install -r requirements_test_all.txt
```

During development on a specific file, speed up your workflow by running tests and linting only for the file that you're working on. To run individual files:
Now that you have all test dependencies installed, you can run tests on individual files:

```bash
$ flake8 homeassistant/core.py
Expand All @@ -48,8 +45,23 @@ You can also run linting tests against all changed files, as reported by `git di
$ script/lint --changed
```

#### {% linkable_title Py.test tips %}

Py.test has some great command line parameters to help you with the write-test-fix cycle.

```bash
# Stop after the first test fails
$ py.test tests/test_core.py -x
# Run test with specified name
$ py.test tests/test_core.py -k test_split_entity_id
# Fail a test after it runs for 2 seconds
$ py.test tests/test_core.py --timeout 2
# Show the 10 slowest tests
$ py.test tests/test_core.py --duration=10
```

### {% linkable_title Preventing Linter Errors %}

Save yourself the hassle of extra commits just to fix style errors by enabling the Flake8 git commit hook. Flake8 will check your code when you try to commit to the repository and block the commit if there are any style errors, which gives you a chance to fix them!

```bash
Expand All @@ -61,5 +73,4 @@ The `flake8-docstrings` extension will check docstrings according to [PEP257](ht

### {% linkable_title Notes on PyLint and PEP8 validation %}

If you can't avoid a PyLint warning, add a comment to disable the PyLint check for that line with `# pylint: disable=YOUR-ERROR-NAME`. An example of an unavoidable PyLint warning is not using the passed-in datetime if you're listening for a time change.

If you can't avoid a PyLint warning, add a comment to disable the PyLint check for that line with `# pylint: disable=YOUR-ERROR-NAME`. Example of an unavoidable one is if PyLint incorrectly reports that a certain object doesn't have a certain member.
2 changes: 1 addition & 1 deletion source/hassio/addon_config.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ The config for an add-on is stored in `config.json`.
| url | no | Homepage of the addon. Here you can explain the add-ons and options.
| startup | yes | `before` homeassistant will start. `after` homeassistant will start or `once` for application they don't run as deamon.
| boot | yes | `auto` by system and manual or only `manual`
| ports | no | Network ports they will be expose in docker style
| ports | no | Network ports to expose from the container. Format is `"container-port/type": host-port`.
| map | no | List of maps for additional hass.io folders. Possible values: `config`, `ssl`, `addons`, `backup`
| options | yes | Default options value of the add-on
| schema | yes | Schema for options value of the add-on
Expand Down
187 changes: 187 additions & 0 deletions source/hassio/addon_tutorial.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
---
layout: page
title: "Tutorial: Making your first add-on"
description: "Easy tutorial to get started making your first add-on."
date: 2017-05-12 13:28
sidebar: true
comments: false
sharing: true
footer: true
---

So you've got Home Assistant going and you've been enjoying the built-in add-ons but you're missing this one application. Time to make your own add-on! In Hass.io 0.24 we introduced the option to have local add-ons be build on your device. This is great for developing new add-ons locally.

To get started with developing add-ons, we first need access to where Hass.io looks for local add-ons. You can choose to either enable the Samba add-on for this or use the SSH add-on. Once you have located your add-on directory, it's time to get started!

## {% linkable_title Step 1: The basics %}

- Create a new directory called `hello_world`
- Inside that directory create three files.

`Dockerfile`:
```
FROM %%BASE_IMAGE%%

ENV VERSION %%VERSION%%
ENV LANG C.UTF-8

# Copy data for add-on
COPY run.sh /
RUN chmod a+x /run.sh

CMD [ "/run.sh" ]
```

`config.json`:
```json
{
"name": "Hello world",
"version": "1",
"slug": "hello_world",
"description": "My first real add-on!",
"startup": "before",
"boot": "auto",
"options": {},
"schema": {}
}
```

`run.sh`:
```bash
echo Hello world!
```

## {% linkable_title Step 2: Installing and testing your add-on %}

Now comes the fun part, time to open the Hass.io UI and install and run your add-on.

- Open the Home Assistant frontend
- Go to the Hass.io panel
- On the top right click the shopping basket to go to the add-on store.

<p class='img'>
<img src='/images/hassio/tutorial/main_panel_store_icon.png' />
From the Hass.io main panel open the add-on store.
</p>

- On the top right click the refresh button
- You should now see a new card called "Local" that lists your add-on!

<p class='img'>
<img src='/images/hassio/tutorial/local_repository.png' />
The Hass.io add-on store will list all available local add-ons.
</p>

- Click on your add-on to go to the add-on details page.
- Install your add-on
- Start your add-on
- Refresh the logs of your add-on, you should now see "Hello world!" in your logs.

<p class='img'>
<img src='/images/hassio/tutorial/addon_hello_world_logs.png' />
The add-on will print Hello world to the logs and then quit.
</p>

### {% linkable_title I don't see my add-on?! %}

Oops! You clicked refresh in the store and your add-on didn't show up. Or maybe you just updated an option, clicked refresh and saw your add-on disappear.

When this happens, it means that your `config.json` is invalid. It's either invalid JSON or one of the specified options is incorrect. To see what went wrong, go to the Hass.io panel and in the supervisor card click on "View logs". This should bring you to a page with the logs of the supervisor. Scroll to the bottom and you should be able to find the validation error.

Once you fixed the error, go to the add-on store and click refresh again.

## {% linkable_title Step 3: Hosting a server %}

Until now we've been able to do some basic stuff, but it's not very useful yet. So let's take it one step further and host a server that we expose on a port. For this we're going to use the built-in HTTP server that comes with Python 3.

To do this, we will need to update our files as follows:

- `Dockerfile`: Install Python 3
- `config.json`: Make the port from the container available on the host
- `run.sh`: Run the Python 3 command to start the HTTP server

Add to your `Dockerfile` before `RUN`:

```
# Install requirements for add-on
RUN apk add --no-cache python3

# Python 3 HTTP Server serves the current working dir
# So let's set it to our add-on persistent data directory.
WORKDIR /data
```

Add "ports" to `config.json`. This will make TCP on port 8000 inside the container available on the host on port 8000.

```json
{
"name": "Hello world",
"version": "0.2",
"slug": "hello_world",
"description": "My first real add-on!",
"startup": "before",
"boot": "auto",
"options": {},
"schema": {},
"ports": {
"8000/tcp": 8000
}
}
```

Update `run.sh` to start the Python 3 server:

```
python3 -m http.server
```

## {% linkable_title Step 4: Installing the update %}

Since we updated the version number in our `config.json`, Home Assistant will show an update button when looking at the add-on details. You might have to refresh your browser or click the refresh button in the add-on store for it to show up. If you did not update the version number, you can also uninstall and install the add-on again. After installing the add-on again, make sure you start it.

Now navigate to [http://hassio.local:8000] to see our server in action!

<p class='img'>
<img src='/images/hassio/tutorial/python3-http-server.png' />
The Python 3 server will allow you to browse the /data folder.
</p>

## {% linkable_title Bonus: Working with add-on options %}

In the screenshot you've probably seen that our server only served up 1 file: `options.json`. This file contains the user configuration for this add-on. Because we specified an empty "config" and "schema" in our `config.json`, the file is currently empty.

Let's see if we can get some data into that file!

To do this, we need to specify the default options and a schema for the user to change the options.

Change the options and schema entries in your `config.json` with the following:

```json
{

"options": {
"beer": true,
"wine": true,
"liquor": false,
"name": "world",
"year": 2017
},
"schema": {
"beer": "bool",
"wine": "bool",
"liquor": "bool",
"name": "str",
"year": "int"
},

}
```

Refresh the add-on store and re-install your add-on. You will now see the options available in the add-on config screen. When you now go back to our Python 3 server and download `options.json`, you'll see the options you set.

- [Learn more about the available schema options.](/hassio/addon_config/#options--schema)
- [See how options.json can be used inside `run.sh`](https://github.com/home-assistant/hassio-addons/blob/master/mosquitto/run.sh#L4-L6)

### [Next step: Add-on config reference &raquo;](/hassio/addon_config/)
4 changes: 4 additions & 0 deletions source/hassio/installation.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ Hass.io images are available for all available Raspberry Pi and intel nuc platfo
- Insert SD card to Raspberry Pi and turn it on. On first boot, it downloads the latest version of Home Assistant which can take some time.
- You will be able to reach your installation at [http://hassio.local][local].

<p class='note'>
If you copy over your existing Home Assistant configuration, make sure to enable the Hass.io panel by adding either `discovery:` or `hassio:` to your configuration.
</p>

### {% linkable_title Alternative: install on generic Linux server %}

For advanced users, it is also possible to try Hass.io on your Linux server or inside a VM. To do so, [follow these instructions][linux].
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.