From cf82b1bb9ce1cc0a899084368e570a0a88a689d0 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 8 Oct 2016 21:15:50 +0200 Subject: [PATCH 01/84] Details about the web server (#1149) --- source/_cookbook/webserver_details.markdown | 39 +++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 source/_cookbook/webserver_details.markdown diff --git a/source/_cookbook/webserver_details.markdown b/source/_cookbook/webserver_details.markdown new file mode 100644 index 00000000000..1a928f881f8 --- /dev/null +++ b/source/_cookbook/webserver_details.markdown @@ -0,0 +1,39 @@ +--- +layout: page +title: "Details about the web server" +description: "Use nmap to scan your Home Assistant instance" +date: 2016-10-06 08:00 +sidebar: true +comments: false +sharing: true +footer: true +ha_category: Infrastructure +--- + +It was only a matter of time till the first queries for tools like [https://www.shodan.io](https://www.shodan.io/search?query=Home+Assistant) to search for Home Assistant instances showed up. + +To get an idea about how your Home Assistant instance looks like for network scanner, you can use `nmap`. The `nmap` tool is already available if you are using the [nmap device tracker](/components/device_tracker/). + +```yaml +$ nmap -sV -p 8123 --script=http-title,http-headers 192.168.1.3 + +Starting Nmap 7.12 ( https://nmap.org ) at 2016-10-06 10:01 CEST +Nmap scan report for 192.168.1.3 (192.168.1.3) +Host is up (0.00011s latency). +PORT STATE SERVICE VERSION +8123/tcp open http CherryPy wsgiserver +| http-headers: +| Content-Type: text/html; charset=utf-8 +| Content-Length: 4309 +| Connection: close +| Date: Thu, 06 Oct 2016 08:01:31 GMT +| Server: Home Assistant +| +|_ (Request type: GET) +|_http-server-header: Home Assistant +|_http-title: Home Assistant + +Service detection performed. Please report any incorrect results at https://nmap.org/submit/ . +Nmap done: 1 IP address (1 host up) scanned in 6.70 seconds +``` + From 974ae8e03139d2600a16e7048e33190e4a84daab Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 8 Oct 2016 21:15:57 +0200 Subject: [PATCH 02/84] Add initial doc to work with a self-signed cert (#1150) --- .../tls_self_signed_certificate.markdown | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 source/_cookbook/tls_self_signed_certificate.markdown diff --git a/source/_cookbook/tls_self_signed_certificate.markdown b/source/_cookbook/tls_self_signed_certificate.markdown new file mode 100644 index 00000000000..cd2748a702d --- /dev/null +++ b/source/_cookbook/tls_self_signed_certificate.markdown @@ -0,0 +1,34 @@ +--- +layout: page +title: "Self-signed certificate for SSL/TLS" +description: "Configure a self-signed certificate to use with Home Assistant" +date: 2016-10-06 08:00 +sidebar: true +comments: false +sharing: true +footer: true +ha_category: Infrastructure +--- + +If your Home Assistant instance is only accessible from your local network you can still protect the communication between your browsers and the frontend with SSL/TLS. [Let's encrypt](blog/2015/12/13/setup-encryption-using-lets-encrypt/) will only work if you have a DNS entry and remote access is allowed. The solution is to use a self-signed certificate. As you most likely don't have a certification authority (CA) your browser will conplain about the security. If you have a CA then this will not be an issue. + +To create locally a certificate you need the [OpenSSL](https://www.openssl.org/) command-line tool. + +Change to your Home Assistant [configuration directory](/getting-started/configuration/) like `~/.homeassistant`. This will make it easier to backup your certificate and the key. Run the command shown below. + +```bash +$ openssl req -new -x509 -sha256 -newkey rsa:4096 -nodes -keyout privkey.pem -days 730 -out fullchain.pem +``` + +For details about the parameters, please check the OpenSSL documentation. Provide the requested information during the generation process. At the end you will have two files called `privkey.pem` and `fullchain.pem`. The key and the certificate. + +Update the `http:` entry in your `configuration.yaml` file and let it point to your created files. + +```yaml +http: + api_password: YOUR_SECRET_PASSWORD + ssl_certificate: /home/fab/.homeassistant/fullchain.pem + ssl_key: /home/fab/.homeassistant/privkey.pem +``` + +A tutorial "[Working with SSL Certificates, Private Keys and CSRs](https://www.digitalocean.com/community/tutorials/openssl-essentials-working-with-ssl-certificates-private-keys-and-csrs)" could give you some insight about special cases. From 59568972ab826db5c925f5a54e6acc53d9413ae0 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 8 Oct 2016 21:20:53 +0200 Subject: [PATCH 03/84] Check points for securing Home Assistant installations (#1151) * Add check points * Add check points * Fix link * Grammar and style fixes --- .../asides/getting_started_navigation.html | 1 + source/getting-started/securing.markdown | 28 +++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 source/getting-started/securing.markdown diff --git a/source/_includes/asides/getting_started_navigation.html b/source/_includes/asides/getting_started_navigation.html index dedfbe4d3ba..672f5816d56 100644 --- a/source/_includes/asides/getting_started_navigation.html +++ b/source/_includes/asides/getting_started_navigation.html @@ -27,6 +27,7 @@
  • {% active_link /getting-started/customizing-devices/ Customizing devices and services %}
  • {% active_link /getting-started/presence-detection/ Presence Detection %}
  • {% active_link /getting-started/troubleshooting-configuration/ Troubleshooting %}
  • +
  • {% active_link /getting-started/securing/ Security Check Points %}
  • diff --git a/source/getting-started/securing.markdown b/source/getting-started/securing.markdown new file mode 100644 index 00000000000..6ada6bca125 --- /dev/null +++ b/source/getting-started/securing.markdown @@ -0,0 +1,28 @@ +--- +layout: page +title: "Securing" +description: "Instructions how to secure your Home Assistant installation." +date: 2016-10-06 06:00 +sidebar: true +comments: false +sharing: true +footer: true +--- + +One of the reasons to use Home Assistant is that it's not depending on cloud services. Even if you are only using Home Assistant in your local network, you should consider to secure your instance. + +### {% linkable_title Checklist %} + +- [Protect your web interface with a password](https://home-assistant.io/getting-started/basic/#password-protecting-the-web-interface) +- Secure your host. Sources could be [Red Hat Enterprise Linux 7 Security Guide](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/pdf/Security_Guide/Red_Hat_Enterprise_Linux-7-Security_Guide-en-US.pdf), [CIS Red Hat Enterprise Linux 7 Benchmark](https://benchmarks.cisecurity.org/tools2/linux/CIS_Red_Hat_Enterprise_Linux_7_Benchmark_v1.0.0.pdf), or the [Securing Debian Manual](https://www.debian.org/doc/manuals/securing-debian-howto/index.en.html). +- Restrict network access to your device. Set `PermitRootLogin no` in your sshd config (usually `/etc/ssh/sshd_config`) and to use keys for authentication instead of passwords. +- Don't run Home Assistant as root. +- Keep your [secrets](/topics/secrets/) safe. + +Additional points if you want to allow remote access: + +- Protect your communication with [TLS](blog/2015/12/13/setup-encryption-using-lets-encrypt/) +- Protect your communication with [Tor](/cookbook/tor_configuration/) +- Use a [proxy](/cookbook/apache_configuration/) + + From 9cd416de0a619bcb6e720aa85069573fa2bd43c3 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 8 Oct 2016 21:54:40 +0200 Subject: [PATCH 04/84] Add name which is an optional variable --- source/_components/sensor.darksky.markdown | 57 ++++++++++--------- .../sensor.openweathermap.markdown | 1 + source/_components/sensor.yweather.markdown | 2 +- 3 files changed, 31 insertions(+), 29 deletions(-) diff --git a/source/_components/sensor.darksky.markdown b/source/_components/sensor.darksky.markdown index bfd2d19811b..e347c56df71 100644 --- a/source/_components/sensor.darksky.markdown +++ b/source/_components/sensor.darksky.markdown @@ -26,39 +26,40 @@ To add Dark Sky to your installation, add the following to your `configuration.y ```yaml # Example configuration.yaml entry sensor: - platform: darksky - api_key: YOUR_APP_KEY - monitored_conditions: - - summary - - icon - - nearest_storm_distance - - nearest_storm_bearing - - precip_type - - precip_intensity - - precip_probability - - temperature - - apparent_temperature - - dew_point - - wind_speed - - wind_bearing - - cloud_cover - - humidity - - pressure - - visibility - - ozone - - minutely_summary - - hourly_summary - - daily_summary - - temperature_max - - temperature_min - - apparent_temperature_max - - apparent_temperature_min - - precip_intensity_max + - platform: darksky + api_key: YOUR_APP_KEY + monitored_conditions: + - summary + - icon + - nearest_storm_distance + - nearest_storm_bearing + - precip_type + - precip_intensity + - precip_probability + - temperature + - apparent_temperature + - dew_point + - wind_speed + - wind_bearing + - cloud_cover + - humidity + - pressure + - visibility + - ozone + - minutely_summary + - hourly_summary + - daily_summary + - temperature_max + - temperature_min + - apparent_temperature_max + - apparent_temperature_min + - precip_intensity_max ``` Configuration variables: - **api_key** (*Required*): Your API key. +- **name** (*Optional*): Additional name for the sensors. Default to platform name. - **monitored_conditions** array (*Required*): Conditions to display in the frontend. - **summary**: A human-readable text summary of the current conditions. - **precip_type**: The type of precipitation occurring. diff --git a/source/_components/sensor.openweathermap.markdown b/source/_components/sensor.openweathermap.markdown index 32bf1871d84..fca55b2237c 100644 --- a/source/_components/sensor.openweathermap.markdown +++ b/source/_components/sensor.openweathermap.markdown @@ -38,6 +38,7 @@ sensor: Configuration variables: - **api_key** (*Required*): Your API key for http://openweathermap.org/. +- **name** (*Optional*): Additional name for the sensors. Default to platform name. - **forecast** (*Optional*): Enables the forecast. The default is to display the current conditions. - **monitored_conditions** array (*Required*): Conditions to display in the frontend. - **weather**: A human-readable text summary. diff --git a/source/_components/sensor.yweather.markdown b/source/_components/sensor.yweather.markdown index c78ac5d06f3..aaf6fd83bc8 100644 --- a/source/_components/sensor.yweather.markdown +++ b/source/_components/sensor.yweather.markdown @@ -43,7 +43,7 @@ Configuration variables: - **woeid** (*Optional*): See above. - **forecast** (*Optional*): Day of forecast. The default is the current day to display conditions. -- **name** (*Optional*): The name of the sensor. To easily recognize each sensor when adding more than one Yahoo weather sensor, it is recommended to use the name option. +- **name** (*Optional*): The name of the sensor. To easily recognize each sensor when adding more than one Yahoo weather sensor, it is recommended to use the name option. Defaults to `Yweather`. - **monitored_conditions** array (*Required*): Conditions to display in the frontend. - **weather**: A human-readable text summary with picture from yahoo. - **weather_current**: A human-readable text summary with picture from yahoo from current conditon. From 0d9177e4b5eb3b5274e950d53f4bccd61629e16c Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 8 Oct 2016 23:21:22 +0200 Subject: [PATCH 05/84] Add screenshot --- source/_components/sensor.statistics.markdown | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/_components/sensor.statistics.markdown b/source/_components/sensor.statistics.markdown index d2cc7e2a206..1a45e4d5777 100644 --- a/source/_components/sensor.statistics.markdown +++ b/source/_components/sensor.statistics.markdown @@ -33,3 +33,6 @@ Configuration variables: - **name** (*Optional*): Name of the sensor to use in the frontend. - **sampling_size** (*Optional*): Size of the sampling. If the limit is reached then the values are rotated. Defaults to `20`. +

    + +

    From 7ff6083afc7644807fd4fd69b49df3ea9cc4e5ec Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 8 Oct 2016 14:46:44 -0700 Subject: [PATCH 06/84] Version 0.30.1 --- .../2016-10-08-hassbian-rest-digital-ocean.markdown | 8 ++++++++ source/index.html | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/_posts/2016-10-08-hassbian-rest-digital-ocean.markdown b/source/_posts/2016-10-08-hassbian-rest-digital-ocean.markdown index fafabbf4401..3f6532079e6 100644 --- a/source/_posts/2016-10-08-hassbian-rest-digital-ocean.markdown +++ b/source/_posts/2016-10-08-hassbian-rest-digital-ocean.markdown @@ -97,6 +97,12 @@ sensor - Device Tracker: The `known_device.yaml` file is now validated ([@kellerza]) - Minor features and bug fixes by [@tchellomello], [@pavoni], [@fabaff], [@pvizeli], [@lwis], [@turbokongen], [@Danielhiversen], [@persandstrom], [@balloob], [@robbiet480], [@sam-io], [@bbangert], and you if you are missing here. +### {% linkable_title Release 0.30.1 - October 8 %} + + - Device Tracker `known_devices.yaml` validation is now more accepting ([@kellerza]) + - Handle X10 light numbers greater than 9 ([@mtl010957]) + - Fix command line covers without a template ([@roidayan]) + ### {% linkable_title Breaking changes %} - All deprecated condition options from `automation` have been removed (deprecated since May and have printed warnings to your console): @@ -136,6 +142,8 @@ sensor [@tchellomello]: https://github.com/tchellomello [@turbokongen]: https://github.com/turbokongen [@w1ll1am23]: https://github.com/w1ll1am23 +[@mtl010957]: https://github.com/mtl010957 +[@roidayan]: https://github.com/roidayan [arest]: https://arest.io/ [arest-sensor]: /components/sensor.arest/ diff --git a/source/index.html b/source/index.html index 52bd20bdb7d..f336c57690a 100644 --- a/source/index.html +++ b/source/index.html @@ -15,7 +15,7 @@ hide_github_edit: true
  • - Frontend Development + {% active_link /developers/asyncio/ Asynchronous Programming %} +
      +
    • {% active_link /developers/asyncio_categorizing_functions/ Categorizing Functions %}
    • +
    • {% active_link /developers/asyncio_working_with_async/ Working with Async %}
    • +
    • {% active_link /developers/asyncio_misc/ Miscellaneous %}
    • +
    +
  • +
  • + {% active_link /developers/frontend/ Frontend Development %}
      -
    • {% active_link /developers/frontend/ Setup Frontend Environment %}
    • {% active_link /developers/frontend_add_card/ Add State Card %}
    • {% active_link /developers/frontend_add_more_info/ Add More Info Dialog %}
    • {% active_link /developers/frontend_creating_custom_panels/ Add Custom Panels %}
    • diff --git a/source/developers/asyncio.markdown b/source/developers/asyncio.markdown new file mode 100644 index 00000000000..f663b8d36e9 --- /dev/null +++ b/source/developers/asyncio.markdown @@ -0,0 +1,27 @@ +--- +layout: page +title: "Asynchronous Programming" +description: "Introduction to the asynchronous core of Home Assistant." +date: 2016-10-17 21:49 +sidebar: true +comments: false +sharing: true +footer: true +--- + +On September 29, 2016 we released [Home Assistant 0.29][0.29] as part of our bi-weekly release schedule. This release introduced a complete overhaul of the core spearheaded by [Ben Bangert][ben]. + +The old core was set up like a “traditional” threaded application. Each resource that was not thread safe (ie. the state of entities) would be protected by a lock. This caused a lot of waiting and potential inconsistency because a task could now end up waiting halfway through it’s job until some resource got freed. + +Our new core is based on an Python’s built-in asyncio module. Instead of having all threads have access to the core API objects, access is now limited to a special thread called the event loop. All components will now schedule themselves as a task to be executed by the event loop. This gives us the guarantee that only one task is executed at once, meaning we no longer need any locks. + +The only problem with running everything inside the event loop is when a task is doing blocking I/O, what most third-party Python libraries are doing. For example while requesting new information from a device, the core will stop running until we get a response from the device. To handle this, a task is able to suspend itself until the response is available after which it will be enqueued for the event loop to process the result. + +For a task to be able to suspend itself, all code that it calls has to have this capability added. This means in practice that each device integration will need a full rewrite of the library that offers the integration! As this is not something that can be achieved, ever, a 100% backwards compatible API has been added so that no platform will require updating. + +The backwards compatible API works by scheduling a task from a different thread and blocking that thread until the task has been processed by the event loop. + +### [Next step: Categorizing Functions »](/developers/asyncio_categorizing_functions/) + +[0.29]: https://home-assistant.io/blog/2016/09/29/async-sleepiq-emoncms-stocks/ +[ben]: https://github.com/bbangert/ diff --git a/source/developers/asyncio_categorizing_functions.markdown b/source/developers/asyncio_categorizing_functions.markdown new file mode 100644 index 00000000000..bd3ff859b8b --- /dev/null +++ b/source/developers/asyncio_categorizing_functions.markdown @@ -0,0 +1,79 @@ +--- +layout: page +title: "Categorizing Functions" +description: "A categorization of functions to work with the asynchronous core of Home Assistant." +date: 2016-10-17 21:49 +sidebar: true +comments: false +sharing: true +footer: true +--- + +A piece of work within Home Assistant is represented by a function that will be invoked. It will either run inside our event loop or inside our thread pool, depending on if it is async safe. + +Home Assistant uses the convention that all functions that must be run from within the event loop are prefixed with `async_`. + +## {% linkable_title The coroutine function %} + +Coroutines are special functions based on Python’s generators syntax which allows them to suspend execution while waiting on a result. + +Invoking a coroutine function will return a Generator object back, but will not actually begin execution. This object will execute the task when it is either yielded from (from within another coroutine) or it is scheduled on the event loop. + +To declare a function a coroutine, import the coroutine annotation from the asyncio package and annotate your function. + +```python +import asyncio + +@asyncio.coroutine +def async_look_my_coroutine(target): + result = yield from entity.async_turn_on() + if result: + print("hello {}".format(target)) + +hass.loop.create_task(async_look_my_coroutine("world") +``` + +In this example, we schedule the coroutine by calling `hass.loop.create_task`. This will add the coroutine to the queue of tasks to be run. When the event loop is running `async_look_my_coroutine` it will suspend the task when `yield from entity.async_turn_on()` is called. At that point a new task will be scheduled to execute `entity.async_turn_on()`. When that job has been executed, `async_look_my_coroutine` will resume. + +## {% linkable_title The callback function %} + +This is a normal function that is considered safe to be run from within the event loop. A callback is unable to suspend itself and thus cannot do any I/O or call a coroutine. A callback is capable of scheduling a new task but it will not be able to wait for the results. + +To declare a function as a callback, import the callback annotation from the core package and annotate your function. + +A common use case for a callback in Home Assistant is as a listener for an event or a service call. It can process the incoming information and then schedule the right calls to be made. Example from the automation component. + +```python +from homeassistant.core import callback + +@callback +def async_trigger_service_handler(service_call): + """Handle automation trigger service calls.""" + vars = service_call.data.get(ATTR_VARIABLES) + for entity in component.async_extract_from_service(service_call): + hass.loop.create_task(entity.async_trigger(vars, True)) +``` + +In this example, `entity.async_trigger` is a coroutine function. Invoking the coroutine function will return a coroutine task. The passed in parameters will be used when the task gets executed. + +To execute the task we have to schedule it for execution on the event loop. This is done by calling `hass.loop.create_task`. + +### {% linkable_title Why even have callbacks? %} + +You might wonder, if a coroutine can do everything a callback can do, why even have a callback. The reason is performance and better state consistency of the core API objects. + +When coroutine A waits for coroutine B, it will suspend itself and schedule a new task to run B. This means that the event loop is now running A, B and then A again. If B is a callback, A will never have to suspend itself and thus the event loop is just running A. The consistency implication is that other events queued to run on the event loop continue to wait until callbacks complete, but will be interleaved when yielding to another coroutine. + +## {% linkable_title Event loop and thread safe %} + +These are functions that are safe to run both in a thread and inside the event loop. These functions are usually performing a computation or transform data in memory. Anything that does I/O does not fall under this category. Many standard library functions fall in this category. For example generating the sum of a set of numbers using sum or merging two dictionaries. + +There is no special annotation to mark functions as part of this category and care should be taken when using these functions from inside the event loop. When in doubt, look at their implementation. + +## {% linkable_title Other functions %} + +These are all the functions that did not fit in the previous categories. These functions are either thread-safe or not considered safe to be run within the event loop. These are functions that use sleep, or perform I/O. + +There is no special annotation necessary to be considered part of this category. + +### [Next step: Working with Async »](/developers/asyncio_working_with_async/) diff --git a/source/developers/asyncio_misc.markdown b/source/developers/asyncio_misc.markdown new file mode 100644 index 00000000000..695b26e3e0b --- /dev/null +++ b/source/developers/asyncio_misc.markdown @@ -0,0 +1,22 @@ +--- +layout: page +title: "Miscellaneous Async" +description: "A collection of miscellaneous topics about async that didn't fit on the other pages." +date: 2016-10-17 21:49 +sidebar: true +comments: false +sharing: true +footer: true +--- + +## {% linkable_title What about ‘async’ and ‘await’ syntax? %} +Python 3.5 introduced new syntax to formalize the asynchronous pattern. This is however not compatible with Python 3.4. The minimum required Python version for Home Assistant is based on the Python version shipped with Debian stable, which is currently 3.4.2. + +For more information, Brett Cannon wrote [an excellent breakdown][brett] on 'async' and 'await' syntax and how asynchronous programming works. + +## {% linkable_title Acknowledgements %} + +Huge thanks to [Ben Bangert][ben] for starting the conversion of the core to async, guiding other contributors while taking their first steps with async programming and peer reviewing this documentation. + +[brett]: http://www.snarky.ca/how-the-heck-does-async-await-work-in-python-3-5 +[ben]: https://github.com/bbangert/ diff --git a/source/developers/asyncio_working_with_async.markdown b/source/developers/asyncio_working_with_async.markdown new file mode 100644 index 00000000000..48839b4648e --- /dev/null +++ b/source/developers/asyncio_working_with_async.markdown @@ -0,0 +1,113 @@ +--- +layout: page +title: "Working with Async" +description: "A breakdown of all the different ways to work with the asynchronous core of Home Assistant." +date: 2016-10-17 21:49 +sidebar: true +comments: false +sharing: true +footer: true +--- + +Although we have a backwards compatible API, using the async core directly will be a lot faster. Most core components have already been rewritten to leverage the async core. This includes the EntityComponent helper (foundation of light, switch, etc), scripts, groups and automation. + +## {% linkable_title Interacting with the core %} + +[All methods in the Home Assistant core][dev-docs] are implemented in two flavors: an async version and a version to be called from other threads. The versions for other are merely wrappers that call the async version in a threadsafe manner using [the available async utilities][dev-docs-async]. + +So if you are making calls to the core (the hass object) from within a callback or coroutine, use the methods that start with async_. If you need to call an async_ function that is a coroutine, your task must also be a coroutine. + +## {% linkable_title Implementing an async component %} + +We currently do not support async setup for components. We do however support using async functions as service handlers. Just define your handlers as a callback or coroutine and register them as usual. + +## {% linkable_title Implementing an async platform %} + +For platforms we support async setup. Instead of setup_platform you need to have a coroutine async_setup_platform. + +```python +setup_platform(hass, config, add_entities, discovery_info=None): + # Setup your platform outside of the event loop. +``` + +Will turn into: + +```python +import asyncio + +@asyncio.coroutine +def async_setup_platform(hass, config, async_add_entities, + discovery_info=None): + # Setup your platform inside of the event loop +``` + +The only difference with the original parameters is that the add_entities function has been replaced by the coroutine `async_add_entities`. + +## {% linkable_title Implementing an async entity %} + +You can make your entity async friendly by converting your update method to be async. This requires the dependency of your entities to also be async friendly! + +```python +class MyEntity(Entity): + def update(self): + """Retrieve latest state.""" + self._state = fetch_state() +``` + +Will turn into: + +```python +import asyncio + +class MyEntity(Entity): + @asyncio.coroutine + def async_update(self): + """Retrieve latest state.""" + self._state = yield from async_fetch_state() +``` + +Make sure that all properties defined on your entity do not result in I/O being done. All data has to be fetched inside the update method and cached on the entity. This is because these properties are read from within the event loop and thus doing I/O will result in the core of Home Assistant waiting until your I/O is done. + +## {% linkable_title Calling async functions from threads %} + +Sometimes it will happen that you’re in a thread and you want to call a function that is only available as async. Home Assistant includes a few async helper utilities to help with this. + +In the following example, `say_hello` will schedule `async_say_hello` and block till the function has run and get the result back. + +```python +from homeassistant.util.async import run_callback_threadsafe + +def say_hello(hass, target): + return run_callback_threadsafe( + hass.loop, async_say_hello, target).result() + +def async_say_hello(hass, target): + return "Hello {}!".format(target) +``` + +## {% linkable_title Dealing with passed in functions %} + +If your code takes in functions from other code, you will not know which category the function belongs to and how they should be invoked. This usually only occurs if your code supplies an event helper like `mqtt.async_subscribe` or `track_state_change_listener`. + +To help with this, there are two helper methods on the hass object that you can call from inside the event loop: + +#### {% linkable_title hass.async_run_job %} + +Use this method if the function should be called as soon as possible. This will call callbacks immediately, schedule coroutines for execution on the event loop and schedule other functions to be run inside the thread pool. + +| Callback | Call immediately. +| Coroutine | Schedule for execution on the event loop. +| Other functions | Schedule for execution in the thread pool. + +#### {% linkable_title hass.async_add_job %} + +Use this method if the function should be called but not get priority over already scheduled calls. + +| Callback | Schedule for execution on the event loop. +| Coroutine | Schedule for execution on the event loop. +| Other functions | Schedule for execution in the thread pool. + +### [Next step: Miscellaneous »](/developers/asyncio_misc/) + +[dev-docs]: https://dev-docs.home-assistant.io/en/master/api/core.html +[dev-docs-async]: https://dev-docs.home-assistant.io/en/dev/api/util.html#module-homeassistant.util.async From 5b773cede86e64455ba5d3c76f32c67da787ae27 Mon Sep 17 00:00:00 2001 From: hexa- Date: Tue, 18 Oct 2016 08:56:02 +0200 Subject: [PATCH 67/84] switch.anel_pwrctrl: correct ha_release type (#1259) --- source/_components/switch.anel_pwrctrl.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/switch.anel_pwrctrl.markdown b/source/_components/switch.anel_pwrctrl.markdown index de4c47d7f6f..5e2801fb137 100644 --- a/source/_components/switch.anel_pwrctrl.markdown +++ b/source/_components/switch.anel_pwrctrl.markdown @@ -10,7 +10,7 @@ footer: true logo: anel.png ha_category: Switch ha_iot_class: "Local Polling" -ha_release: 0.30 +ha_release: "0.30" --- The `anel_pwrctrl` switch platform allows you to control [ANEL PwrCtrl](http://anel-elektronik.de/SITE/produkte/produkte.htm) devices. From 4b09c4bbc18f0f555f8fcbe263cab5cd93ebaf79 Mon Sep 17 00:00:00 2001 From: Marc Plano-Lesay Date: Tue, 18 Oct 2016 08:56:33 +0200 Subject: [PATCH 68/84] Fix missing parenthesis to device_tracker.netgear (#1260) --- source/_components/device_tracker.netgear.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/device_tracker.netgear.markdown b/source/_components/device_tracker.netgear.markdown index 780fc170d11..4a5a94f638a 100644 --- a/source/_components/device_tracker.netgear.markdown +++ b/source/_components/device_tracker.netgear.markdown @@ -30,7 +30,7 @@ device_tracker: Configuration variables: - **host** (*Required*): The IP address of your router, e.g. `192.168.1.1`. -- **username** (*Required*: The username of an user with administrative privileges, usually `admin`. +- **username** (*Required*): The username of an user with administrative privileges, usually `admin`. - **password** (*Required*): The password for your given admin account. - **port** (*Optional*): The port your router communicates with (defaults to 5000, but 80 is also known to be used on some models) From 6b7ad4e20f8169ef8495e298aeb547d88681b5fa Mon Sep 17 00:00:00 2001 From: AlucardZero Date: Wed, 19 Oct 2016 01:18:16 -0400 Subject: [PATCH 69/84] Fix incorrect word in thermostat.markdown (#1264) --- source/_components/thermostat.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/thermostat.markdown b/source/_components/thermostat.markdown index 38199bb965a..5a2e618b00f 100644 --- a/source/_components/thermostat.markdown +++ b/source/_components/thermostat.markdown @@ -10,7 +10,7 @@ footer: true ---

      -**This component has been deprecated in favor of the "[climate](/components/climate/)" component and will be removed in the future. Please use cover.** +**This component has been deprecated in favor of the "[climate](/components/climate/)" component and will be removed in the future. Please use climate.**

      Thermostats offer Home Assistant a peek into the current and target temperature in a house. Some thermostats will also offer an away mode that will lower use of heating/cooling. From 602ca9f214f5543a8a36cc676eb24882fd640b21 Mon Sep 17 00:00:00 2001 From: Madhan Sundaram Date: Wed, 19 Oct 2016 01:22:31 -0400 Subject: [PATCH 70/84] Update cover.mqtt.markdown (#1267) Retain flag was used twice. --- source/_components/cover.mqtt.markdown | 1 - 1 file changed, 1 deletion(-) diff --git a/source/_components/cover.mqtt.markdown b/source/_components/cover.mqtt.markdown index 62d55d7d8a3..d70dc6ed88e 100644 --- a/source/_components/cover.mqtt.markdown +++ b/source/_components/cover.mqtt.markdown @@ -70,7 +70,6 @@ cover: state_open: "OPEN" state_closed: "STATE" optimistic: false - retain: false value_template: '{% raw %}{{ value.x }}{% endraw %}' ``` From 51d7e21661440091ba9bad32ac0a74ab1becbf56 Mon Sep 17 00:00:00 2001 From: hexa- Date: Wed, 19 Oct 2016 17:39:46 +0200 Subject: [PATCH 71/84] switch.tplink: add iot_class and release version (#1269) --- source/_components/switch.tplink.markdown | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/_components/switch.tplink.markdown b/source/_components/switch.tplink.markdown index 750c0cc8689..cf2cab03b8c 100644 --- a/source/_components/switch.tplink.markdown +++ b/source/_components/switch.tplink.markdown @@ -9,6 +9,8 @@ sharing: true footer: true logo: tp-link.png ha_category: Switch +ha_iot_class: "Local Polling" +ha_release: "0.24" --- From 27c8cf3e78dfb1c8f313636f7d03b6cb19b5ebff Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Thu, 20 Oct 2016 22:57:06 +0200 Subject: [PATCH 72/84] Minor changes --- source/_components/sensor.emoncms.markdown | 68 +++++++++------------- 1 file changed, 29 insertions(+), 39 deletions(-) diff --git a/source/_components/sensor.emoncms.markdown b/source/_components/sensor.emoncms.markdown index 35a8bb7b01d..ed60592a2c5 100644 --- a/source/_components/sensor.emoncms.markdown +++ b/source/_components/sensor.emoncms.markdown @@ -1,7 +1,7 @@ --- layout: page title: "Emoncms Sensor" -description: "Instructions on how to integrate emoncms feeds as sensors into Home Assistant." +description: "Instructions on how to integrate Emoncms feeds as sensors into Home Assistant." date: 2016-09-08 00:15 logo: emoncms.png sidebar: true @@ -14,102 +14,96 @@ ha_iot_class: "Local Polling" --- -The `emoncms` sensor platform creates sensors for the feeds available in your local or cloud based version of [emoncms](https://emoncms.org). +The `emoncms` sensor platform creates sensors for the feeds available in your local or cloud based version of [Emoncms](https://emoncms.org). To enable this sensor, add the following lines to your `configuration.yaml`, it will list all feeds as a sensor: ```yaml -# Example configuration.yaml entry using cloud based emoncms +# Example configuration.yaml entry using cloud based Emoncms sensor: platform: emoncms - api_key: put your emoncms read api key here + api_key: API_KEY url: https://emoncms.org id: 1 ``` ## {% linkable_title Configuration variables %} -- **api_key** (*Required*): The read api key for your emoncms user. -- **url** (*Required*): The base url of emoncms, use "https://emoncms.org" for the cloud based version. -- **id** (*Required*): Positive Integer identifier for the sensor. Must be unique if you specify multiple emoncms sensors. -- **include_only_feed_id** (*optional*): Positive integer list of emoncms feed id's. Only the feeds with feed id's specified here will be displayed. Can not be specified if `exclude_feed_id` is specified. -- **exclude_feed_id** (*optional*): Positive integer list of emoncms feed id's. All the feeds will be displayed as sensors except the ones listed here. Can not be specified if `include_only_feed_id` is specified. -- **sensor_names** (*optional*): Dictionary of names for the sensors created that are created based on feedid. The dictionary consists of feedid:name pairs. Sensors for feeds with their feedid mentioned here will get the chosen name instead of the default name +- **api_key** (*Required*): The read API key for your Emoncms user. +- **url** (*Required*): The base URL of Emoncms, use "https://emoncms.org" for the cloud based version. +- **id** (*Required*): Positive integer identifier for the sensor. Must be unique if you specify multiple Emoncms sensors. +- **include_only_feed_id** (*Optional*): Positive integer list of Emoncms feed IDs. Only the feeds with feed IDs specified here will be displayed. Can not be specified if `exclude_feed_id` is specified. +- **exclude_feed_id** (*Optional*): Positive integer list of Emoncms feed IDs. All the feeds will be displayed as sensors except the ones listed here. Can not be specified if `include_only_feed_id` is specified. +- **sensor_names** (*Optional*): Dictionary of names for the sensors created that are created based on feed ID. The dictionary consists of `feedid: name` pairs. Sensors for feeds with their feed ID mentioned here will get the chosen name instead of the default name - **value_template** (*Optional*): Defines a [template](/topics/templating/) to alter the feed value. - **scan_interval** (*Optional*): Defines the update interval of the sensor in seconds. - **unit_of_measurement** (*Optional*): Defines the unit of measurement of for all the sensors. default is "W". ## {% linkable_title Default naming scheme %} -The names of the sensors created by this component, will be a combination of static text, `id` from the config and `feedid` from the emoncms feed, unless `sensor_names` is used. -An example name would be "emoncms1_feedid_10" +The names of the sensors created by this component, will be a combination of static text, `id` from the config and `feedid` from the Emoncms feed, unless `sensor_names` is used. An example name would be `emoncms1_feedid_10`. -## {% linkable_title Examples %} +### {% linkable_title Examples %} In this section you find some more examples of how this sensor can be used. +Display only feeds with their feed IDs specified in `include_only_feed_id`. + ```yaml -# Display only feeds with their feed id's specified in "include_only_feed_id" +# Example configuration.yaml entry sensor: - platform: emoncms - api_key: put your emoncms read api key here + api_key: API_KEY url: https://emoncms.org id: 1 unit_of_measurement: "W" include_only_feed_id: - 107 - - 106 - 105 ``` +Display all feeds except feeds with their feed id specified in `exclude_feed_id`. ```yaml -# Display all feeds except feeds with their feed id specified in "exclude_feed_id" +# Example configuration.yaml entry sensor: - platform: emoncms - api_key: put your emoncms read api key here + api_key: API_KEY url: https://emoncms.org id: 1 unit_of_measurement: "KWH" exclude_feed_id: - 107 - - 106 - 105 ``` +Display only feeds with their feed id's specified in `include_only_feed_id` and give the feed sensors a name using "sensor_names". You don't have to specify all feeds names in "sensor_names", the remaining sensor names will be chosen based on "id" and the Emoncms `feedid`. ```yaml -# Display only feeds with their feed id's specified in "include_only_feed_id" and give the feed sensors a name using "sensor_names". You don't have to specify all feeds names in "sensor_names", the remaining sensor names will be chosen based on "id" and the emoncms feedid +# Example configuration.yaml entry sensor: - platform: emoncms - api_key: put your emoncms read api key here - url: https://emoncms.org + api_key: API_KEY + url: https://emoncms.org id: 1 unit_of_measurement: "KW" include_only_feed_id: - 5 - - 18 - - 29 - - 48 - - 61 - - 110 - - 116 - 120 sensor_names: 5: "feed 1" - 18: "feed 2" - 29: "feed 3" 48: "kwh feed" 61: "amp feed" 110: "watt feed" ``` +Use a `value_template` to add 1500 to the feed value for all specified feed IDs in `include_feed_id`. ```yaml -# Use a "value_template" to add 1500 to the feed value for all specified feed id's in "include_feed_id" +# Example configuration.yaml entry sensor: - platform: emoncms - api_key: put your emoncms read api key here + api_key: API_KEY url: https://emoncms.org scan_interval: 15 id: 1 @@ -117,16 +111,15 @@ sensor: include_only_feed_id: - 107 - 106 - - 105 - - 61 ``` +Display feeds from the same Emoncms instance with 2 groups of feeds, diffrent `scan_interval` and a diffrent `unit_of_measurement`. ```yaml -# Display feeds from the same emoncms instance with 2 groups of feeds, diffrent scan_interval and a diffrent unit_of_measurement +# Example configuration.yaml entry sensor: - platform: emoncms - api_key: put your emoncms read api key here + api_key: API_KEY url: https://emoncms.org scan_interval: 30 id: 1 @@ -134,7 +127,6 @@ sensor: include_only_feed_id: - 107 - 106 - - 105 - platform: emoncms api_key: put your emoncms read api key here url: https://emoncms.org @@ -143,7 +135,5 @@ sensor: unit_of_measurement: "A" include_only_feed_id: - 108 - - 109 - - 110 - 61 ``` From d9e6b061d627c68e00eedc113066b40708a4c0d0 Mon Sep 17 00:00:00 2001 From: ianj001 Date: Thu, 20 Oct 2016 17:34:33 -0400 Subject: [PATCH 73/84] Update light.enocean.markdown (#1279) --- source/_components/light.enocean.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.enocean.markdown b/source/_components/light.enocean.markdown index 30ecc16614f..ba8e54cfe54 100644 --- a/source/_components/light.enocean.markdown +++ b/source/_components/light.enocean.markdown @@ -12,7 +12,7 @@ ha_category: Light ha_release: 0.21 --- -An EnOcean light can take many formes. Currently only one type has been tested: Eltako FUD61 dimmer. +An EnOcean light can take many forms. Currently only one type has been tested: Eltako FUD61 dimmer. To use your EnOcean device, you first have to set up your [EnOcean hub](/components/enocean/) and then add the following to your `configuration.yaml` file: From cf46d83ddbd7d64e5969d9a0d2ba938b0739fea1 Mon Sep 17 00:00:00 2001 From: ianj001 Date: Thu, 20 Oct 2016 17:35:04 -0400 Subject: [PATCH 74/84] Update light.flux_led.markdown (#1281) --- source/_components/light.flux_led.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.flux_led.markdown b/source/_components/light.flux_led.markdown index d9f5b2c8db0..44300a716f1 100644 --- a/source/_components/light.flux_led.markdown +++ b/source/_components/light.flux_led.markdown @@ -23,7 +23,7 @@ Example of bulbs: - [Flux WiFi Smart LED Light Bulb4](http://smile.amazon.com/Flux-WiFi-Smart-Light-Bulb/dp/B01A6GHHTE) - [WIFI smart LED light Bulb1](http://smile.amazon.com/gp/product/B01CS1EZYK) -The chances are high that you bulb or controller (eg. WiFi LED CONTROLLER) will work if you can control the device with the MagicHome app. +The chances are high that your bulb or controller (eg. WiFi LED CONTROLLER) will work if you can control the device with the MagicHome app. To enable those lights, add the following lines to your `configuration.yaml` file: From 8ad4d0b5e7f25568920c658c878c9df078a880bc Mon Sep 17 00:00:00 2001 From: ianj001 Date: Thu, 20 Oct 2016 17:35:34 -0400 Subject: [PATCH 75/84] Update light.blinksticklight.markdown (#1280) --- source/_components/light.blinksticklight.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.blinksticklight.markdown b/source/_components/light.blinksticklight.markdown index 5040ee6fe99..2225a7cf469 100644 --- a/source/_components/light.blinksticklight.markdown +++ b/source/_components/light.blinksticklight.markdown @@ -13,7 +13,7 @@ ha_release: 0.7.5 --- -The `blinkstick` platform let you can control your [Blinkstick](https://www.blinkstick.com/) lights from within Home Assistant. +The `blinkstick` platform lets you control your [Blinkstick](https://www.blinkstick.com/) lights from within Home Assistant. To add blinkstick to your installation, add the following to your `configuration.yaml` file: From 7a4ed88ab1daa34119a69f43a7d8f5c3dcfd9ccf Mon Sep 17 00:00:00 2001 From: Spencer Owen Date: Fri, 21 Oct 2016 00:55:35 -0600 Subject: [PATCH 76/84] fix missing space (#1287) --- source/getting-started/automation.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/getting-started/automation.markdown b/source/getting-started/automation.markdown index 27d026a43f8..dea2435fd7e 100644 --- a/source/getting-started/automation.markdown +++ b/source/getting-started/automation.markdown @@ -31,7 +31,7 @@ The first line is the trigger of the automation rule. Triggers describe events t The second line is the condition part of the automation rule. 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. +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.

      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 vs a light being on. From 5a46258eaf9895e7cb1b2e0304e42b5394e1bc9b Mon Sep 17 00:00:00 2001 From: ianj001 Date: Fri, 21 Oct 2016 02:56:20 -0400 Subject: [PATCH 77/84] Update light.mqtt_json.markdown (#1282) --- source/_components/light.mqtt_json.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/_components/light.mqtt_json.markdown b/source/_components/light.mqtt_json.markdown index 3f722ff64bc..c2eed64ddb7 100644 --- a/source/_components/light.mqtt_json.markdown +++ b/source/_components/light.mqtt_json.markdown @@ -14,7 +14,7 @@ ha_release: 0.26 --- -The `mqtt_json` light platform let you control a MQTT-enabled light that can receive [JSON](https://en.wikipedia.org/wiki/JSON) messages. +The `mqtt_json` light platform lets you control a MQTT-enabled light that can receive [JSON](https://en.wikipedia.org/wiki/JSON) messages. This platform supports on/off, brightness, RGB colors, transitions, and short/long flashing. The messages sent to/from the lights look similar to this, omitting fields when they aren't needed: @@ -32,9 +32,9 @@ This platform supports on/off, brightness, RGB colors, transitions, and short/lo ``` -In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with the RETAIN flag, the MQTT light will receive an instant state update after subscription and will start with correct state. Otherwise, the initial state of the light will be off. +In an ideal scenario, the MQTT device will have a state topic to publish state changes. If these messages are published with the RETAIN flag, the MQTT light will receive an instant state update after subscription and will start with the correct state. Otherwise, the initial state of the light will be off. -When a state topic is not available, the light will work in optimistic mode. In this mode, the light will immediately change state after every command. Otherwise, the light will wait for state confirmation from device (message from `state_topic`). +When a state topic is not available, the light will work in optimistic mode. In this mode, the light will immediately change state after every command. Otherwise, the light will wait for state confirmation from the device (message from `state_topic`). Optimistic mode can be forced, even if state topic is available. Try enabling it if the light is operating incorrectly. From 1ebcbefbc34055b108adcf61e05117677da906f9 Mon Sep 17 00:00:00 2001 From: ianj001 Date: Fri, 21 Oct 2016 02:57:03 -0400 Subject: [PATCH 78/84] Update light.zigbee.markdown (#1283) --- source/_components/light.zigbee.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/light.zigbee.markdown b/source/_components/light.zigbee.markdown index 8ce3a9c4e33..b0462064724 100644 --- a/source/_components/light.zigbee.markdown +++ b/source/_components/light.zigbee.markdown @@ -26,7 +26,7 @@ light: Configuration variables: -- **name** (*Required*): The name you' would like to give the light in Home Assistant. +- **name** (*Required*): The name you would like to give the light in Home Assistant. - **pin** (*Required*): The number identifying which pin to use. - **address** (*Optional*): The long 64 bit address of the remote ZigBee device whose digital output pin you wouldd like to switch. Do not include this variable if you want to switch the local ZigBee device's pins. - **on_state** (*Optional*): Either `high` (default) or `low`, depicting whether the digital output pin is pulled `high` or `low` when the light is turned on. From 867f734d89297474e4db66a55f8cf0acab46dff9 Mon Sep 17 00:00:00 2001 From: ianj001 Date: Fri, 21 Oct 2016 02:57:32 -0400 Subject: [PATCH 79/84] Update automation_sun.markdown (#1284) --- source/_cookbook/automation_sun.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_cookbook/automation_sun.markdown b/source/_cookbook/automation_sun.markdown index 25edee45576..fff78fb29ab 100644 --- a/source/_cookbook/automation_sun.markdown +++ b/source/_cookbook/automation_sun.markdown @@ -10,7 +10,7 @@ footer: true ha_category: Automation Examples --- -#### {% linkable_title Turn on the living room lights 45 minutes before sunset if anyone home %} +#### {% linkable_title Turn on the living room lights 45 minutes before sunset if anyone is at home %} ```yaml automation: From fb50a2c50f2706f2837ae52596b6dfcd0339dbcc Mon Sep 17 00:00:00 2001 From: ianj001 Date: Fri, 21 Oct 2016 02:58:01 -0400 Subject: [PATCH 80/84] Update apache_configuration.markdown (#1285) --- source/_cookbook/apache_configuration.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_cookbook/apache_configuration.markdown b/source/_cookbook/apache_configuration.markdown index 626538d33c5..2855837a3b5 100644 --- a/source/_cookbook/apache_configuration.markdown +++ b/source/_cookbook/apache_configuration.markdown @@ -10,7 +10,7 @@ footer: true ha_category: Infrastructure --- -This is an example about how you can configure Apache to act as a proxy for home assistant. +This example demonstrates how you can configure Apache to act as a proxy for home assistant. This is useful if you want to have: From 485cc65c634a2ed16f822d033240536cd940b831 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Fri, 21 Oct 2016 10:15:38 +0200 Subject: [PATCH 81/84] No sidebar --- source/help/talking-points.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/help/talking-points.markdown b/source/help/talking-points.markdown index 4c22a225cd1..51ee75e564e 100644 --- a/source/help/talking-points.markdown +++ b/source/help/talking-points.markdown @@ -3,7 +3,7 @@ layout: page title: "Talking points" description: "Talking points for your Home Assistant talk or presentation." date: 2016-10-06 06:00 -sidebar: true +sidebar: false comments: false sharing: true footer: true From 5a09bd504d97058924044760d851b50ba1127409 Mon Sep 17 00:00:00 2001 From: MaKin211 Date: Fri, 21 Oct 2016 23:00:09 +0200 Subject: [PATCH 82/84] Setting proper variables for specific protocols. (#1290) For some PiLight protocols there are different parameters used and therefore the variables have to be replaced in order to have the pilight_switch component working with HASS. --- source/_components/switch.pilight.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_components/switch.pilight.markdown b/source/_components/switch.pilight.markdown index c8a28e1e9c6..db1e8bd5845 100644 --- a/source/_components/switch.pilight.markdown +++ b/source/_components/switch.pilight.markdown @@ -55,7 +55,7 @@ Variables for the different codes: - **'off'** (*Optional*): `1` or `0` - **'on'** (*Optional*): `1` or `0` -For possible code entries look at the [pilight API](https://www.pilight.org/development/api/). All commands allowed by [pilight-send](https://wiki.pilight.org/doku.php/psend) can be used. +For possible code entries look at the [pilight API](https://www.pilight.org/development/api/). All commands allowed by [pilight-send](https://wiki.pilight.org/doku.php/psend) can be used. Which means that if for a certain protocol there are different parameters used, you should be able to replace the variables above by the proper ones required by the specific protocol. When using the `elro_800_switch` or `mumbi` protocol for example, you will have to replace the variable `unit` with `unitcode` or there will be errors occuring. ## {% linkable_title Examples %} From 600942982a3feac0667b106afd3e6598fcabd4c3 Mon Sep 17 00:00:00 2001 From: ricmik Date: Fri, 21 Oct 2016 23:09:15 +0200 Subject: [PATCH 83/84] Update media_player.yamaha.markdown (#1288) Fixed source_names example --- source/_components/media_player.yamaha.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/_components/media_player.yamaha.markdown b/source/_components/media_player.yamaha.markdown index d9eb6138fa1..8ee77c42dc7 100644 --- a/source/_components/media_player.yamaha.markdown +++ b/source/_components/media_player.yamaha.markdown @@ -54,6 +54,6 @@ media_player: - "AUX" - "HDMI6" source_names: - - HDMI1: "ChromeCast" - - AV4: "Vinyl" + HDMI1: "ChromeCast" + AV4: "Vinyl" ``` From f7255cad8679e4546035e1ddb902bb7ce421b326 Mon Sep 17 00:00:00 2001 From: Fredrik Lindqvist Date: Sat, 22 Oct 2016 06:06:03 +0200 Subject: [PATCH 84/84] Add more instructions to HASSbian docs. (#1262) * Add more instructions to HASSbian docs. * Update installation-raspberry-pi-image.markdown - Add viewing of log trough journalctl - Add information about status command for Home Assistant service - Fix formatting --- .../installation-raspberry-pi-image.markdown | 114 +++++++++++++++--- source/getting-started/updating.markdown | 2 +- 2 files changed, 101 insertions(+), 15 deletions(-) diff --git a/source/getting-started/installation-raspberry-pi-image.markdown b/source/getting-started/installation-raspberry-pi-image.markdown index bddb055e69d..7ba140cec80 100644 --- a/source/getting-started/installation-raspberry-pi-image.markdown +++ b/source/getting-started/installation-raspberry-pi-image.markdown @@ -1,7 +1,7 @@ --- layout: page -title: "Hassbian image for Raspberry Pi" -description: "Instructions to flash the Home Assistant Hassbian image on a Raspberry Pi." +title: "HASSbian image for Raspberry Pi" +description: "Instructions to flash the Home Assistant HASSbian image on a Raspberry Pi." date: 2016-09-26 21:00 sidebar: true comments: false @@ -9,15 +9,15 @@ sharing: true footer: true --- -The easiest way to install Home Assistant on your Raspberry Pi is by using Hassbian: a Raspberry Pi image with Home Assistant built-in. The image will install the latest version of Home Assistant on initial boot (~5 minutes). +The easiest way to install Home Assistant on your Raspberry Pi is by using HASSbian: a Raspberry Pi image with Home Assistant built-in. The image will install the latest version of Home Assistant on initial boot (~5 minutes). 1. [Download the latest image][image-download] 2. Flash the image to an SD card: - [Windows][flash-windows] - [Linux][flash-linux] - - [Mac][flash-macos] + - [Mac OS][flash-macos] 3. Ensure your Raspberry Pi has access to the internet. - 4. Insert SD card to Raspberry Pi and turn it on. Initial installation of Home Assistant will take 5 minutes. + 4. Insert SD card to Raspberry Pi and turn it on. Initial installation of Home Assistant will take about 5 minutes. These instructions are also available as a [video](https://www.youtube.com/watch?v=iIz6XqDwHEk). @@ -36,21 +36,104 @@ Some extra tips: ### {% linkable_title Technical Details %} - - Home Assistant is installed in a virtual Python environment at `src/homeassistant` + - Home Assistant is installed in a virtual Python environment at `/src/homeassistant/` - Home Assistant will be started as a service run by the user `homeassistant` + - The configuration is located at `/home/homeassistant/.homeassistant` -{% comment %} +### {% linkable_title Managing your HASSbian installation %} +#### {% linkable_title Login to HASSbian on the Raspberry Pi %} +To login to your Raspberry Pi running HASSbian your going to be using a ssh client. Depending on your platform there are several alternatives for doing this. Linux and Max OS generally have a ssh client installed. Windows users are recommended to download and install the ssh client [Putty][ssh-putty]. - TODO: +Connect to the Raspberry Pi over ssh. Default user name is `pi` and password is `raspberry`. +Linux and Mac OS users execute the following command in a terminal. +```bash +$ ssh pi@ip-address-of-pi +``` +Windows users start [Putty][ssh-putty], enter the IP address of the Raspberry Pi in the *Host name* field and port 22 in the *Port* field. Then click *Open* and a terminal window will open. Enter the credentials. Default user name is `pi` and password is `raspberry`. - Add instructions: +#### {% linkable_title Start/Stop/Restart Home Assistant on HaSSbian %} +Log in as the `pi` account account and execute the following commands: +```bash +sudo systemctl stop home-assistant@homeassistant.service +``` +Replace `stop` with `start` or `restart` to get the desired functionality. +To get the current state of the `homeassistant.service` replace `stop` with `status`. - - How to login via shell (?) or at least mention how to work with a Pi - - How to restart HASS - - How to see the logs for config validation - - How to update the config +#### {% linkable_title Update Home Assistant on HASSbian %} +Log in as the `pi` account and execute the following commands: +```bash +sudo systemctl stop home-assistant@homeassistant.service +sudo su -s /bin/bash homeassistant +source /srv/homeassistant/bin/activate +pip3 install --upgrade homeassistant +exit +sudo systemctl start home-assistant@homeassistant.service +``` +This will in order do the following: +- Stop the Home Assistant service running on HASSbian +- Open a shell as the `homeassistant` user running the Homeassistant service and that has ownership over the Home Assistant installation. +- Change into the virtual Python environment at `/src/homeassistant/` containing the Home Assistant installation. +- Upgrade the Home Assistant installation to the latest release. +- Exit the shell and return to the `pi` user. +- Restart the Home Assistant service. -{% endcomment %} +#### {% linkable_title Manually launch Home Assistant on HASSbian %} +Log in as the `pi` account and execute the following commands: +```bash +sudo su -s /bin/bash homeassistant +source /srv/homeassistant/bin/activate +hass +``` +This will start Home Assistant in your shell and output anything that ends up in the log and more into the console. This will fail if the Home Assistant service is already running so don't forget to [stop][stop-homeassistant] it first. + +#### {% linkable_title Check your configuration on HASSbian %} +Log in as the `pi` account and execute the following commands: +```bash +sudo su -s /bin/bash homeassistant +source /srv/homeassistant/bin/activate +hass --script check_config +``` +This will output any errors in your configuration files to console. + +#### {% linkable_title Read the Home Assistant log file on HASSbian %} +Log in as the `pi` account and execute the following commands: +```bash +sudo su -s /bin/bash homeassistant +cd /home/homeassistant/.homeassistant +nano homeassistant.log +``` +This will in order do the following: +- Open a shell as the `homeassistant` user. +- Change directory to the Home Assistant configuration directory. +- Open the log file in the nano editor. + +Optionaly, you can also view the log with `journalctl`. +Log in as the `pi` account and execute the following commands: +```bash +sudo journalctl -fu home-assistant@homeassistant.service +``` + +#### {% linkable_title Edit the Home Assistant configuration on HASSbian %} +Log in as the `pi` account and execute the following commands: +```bash +sudo su -s /bin/bash homeassistant +cd /home/homeassistant/.homeassistant +nano configuration.yaml +``` +This will in order do the following: +- Open a shell as the `homeassistant` user. +- Change directory to the Home Assistant configuration directory. +- Open the configuration file in the nano editor. +It's generally recommended that you read the [Getting started][configuring-homeassistant] guide for how to configure Home Assistant. + +#### {% linkable_title Upgrade and update HASSbian %} +HASSbian is based on Raspbian and uses the same repositories. Any changes to Raspbian will be reflected in HASSbian. To update and upgrade system packages and installed software (excluding Home Assistant) do the following. +Log in as the `pi` account and execute the following commands: +```bash +sudo apt-get update +sudo apt-get upgrade +``` +Press `Y` to confirm that you would like to continue. ### {% linkable_title Troubleshooting %} @@ -69,3 +152,6 @@ In addition to this site, check out these sources for additional help: [flash-macos]: https://www.raspberrypi.org/documentation/installation/installing-images/mac.md [flash-windows]: https://www.raspberrypi.org/documentation/installation/installing-images/windows.md [pi-components]: /getting-started/installation-raspberry-pi/#raspberry-pi-hardware-specific-components +[ssh-putty]: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html +[stop-homeassistant]: /getting-started/installation-raspberry-pi-image/#startstoprestart-home-assistant-on-hassbian +[configuring-homeassistant]: /getting-started/configuration/ diff --git a/source/getting-started/updating.markdown b/source/getting-started/updating.markdown index 56e1a52f032..0da8ad75536 100644 --- a/source/getting-started/updating.markdown +++ b/source/getting-started/updating.markdown @@ -16,7 +16,7 @@ The default way to update Home Assistant to the latest release, when available, $ pip3 install --upgrade homeassistant ``` -Different installation methods as [Raspberry Pi All-In-One Installer](/getting-started/installation-raspberry-pi-all-in-one/#upgrading), [Vagrant](/getting-started/installation-vagrant/), or [Virtualenv](/getting-started/installation-virtualenv/#upgrading-home-assistant) may have an alternative way for updating Home Assistant. +Different installation methods as [HASSbian](/getting-started/installation-raspberry-pi-image/#update-home-assistant-on-hassbian), [Raspberry Pi All-In-One Installer](/getting-started/installation-raspberry-pi-all-in-one/#upgrading), [Vagrant](/getting-started/installation-vagrant/), or [Virtualenv](/getting-started/installation-virtualenv/#upgrading-home-assistant) may have an alternative way for updating Home Assistant. After updating, restart Home Assistant for the changes to take effect. This means that you have to restart `hass` itself or the [autostarting](/getting-started/autostart/) daemon if you use any.