diff --git a/_config.yml b/_config.yml index 873dbd5302b..351647d8582 100644 --- a/_config.yml +++ b/_config.yml @@ -41,6 +41,7 @@ kramdown: entity_output: as_char toc_levels: 1..6 smart_quotes: lsquo,rsquo,ldquo,rdquo + parse_block_html: true enable_coderay: true coderay: @@ -56,7 +57,6 @@ highlighter: rouge gems: - jekyll-time-to-read - octopress-filters - # - octopress-solarized - octopress-codefence - octopress-include-tag diff --git a/source/developers/add_new_platform.markdown b/source/developers/add_new_platform.markdown index fe2c2414f02..d1d3c540046 100644 --- a/source/developers/add_new_platform.markdown +++ b/source/developers/add_new_platform.markdown @@ -23,35 +23,21 @@ If you are planning to add support for a new type of device to an existing compo ### {% linkable_title Interfacing with devices %} -One of the rules for Home Assistant is that platform logic should never interface directly with -devices but use a third-party Python 3 library to do so. This way Home Assistant is able to share -code with the Python community and we can keep the project maintainable. +One of the rules for Home Assistant is that platform logic should never interface directly with devices but use a third-party Python 3 library to do so. This way Home Assistant is able to share code with the Python community and we can keep the project maintainable. -Platforms can specify dependencies and requirements the same way as a component does. Please see -[the component page](/developers/creating_components/#dependencies) for more information. +Platforms can specify dependencies and requirements the same way as a component does. Please see [the component page](/developers/creating_components/#dependencies) for more information. ### {% linkable_title Creating Entities %} -Home Assistant will call a function with the following signature to initialize -your new platform. This function must exist in the platform module you create. +Home Assistant will call a function with the following signature to initialize your new platform. This function must exist in the platform module you create. ```python def setup_platform(hass, config, add_devices, discovery_info=None) ``` -In this function, your platform should create the appropriate entities and -register them with the Home Assistant core. Entities are Home Assistant's -representation of lights, switches, sensors, etc. and are derived from the -[Entity Abstract Class](https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py). -This abstract class contains logic for integrating most standard features into -your entities, such as visibility, entity IDs, updates, and many more. +In this function, your platform should create the appropriate entities and register them with the Home Assistant core. Entities are Home Assistant's representation of lights, switches, sensors, etc. and are derived from the [Entity Abstract Class](https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py). This abstract class contains logic for integrating most standard features into your entities, such as visibility, entity IDs, updates, and many more. -A list of entities can be registered with Home Assistant using the *add_devices* -function that is provided as an input to *setup_platform*. Once entities are -registered with with Home Assistant their updates will be provided to the core -and the core will have control over them. For more information on how Entities -can be customized, take a look at the [Entity Abstract -Class](https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py#L18). +A list of entities can be registered with Home Assistant using the *add_devices* function that is provided as an input to *setup_platform*. Once entities are registered with with Home Assistant their updates will be provided to the core and the core will have control over them. For more information on how Entities can be customized, take a look at the [Entity Abstract Class](https://github.com/balloob/home-assistant/blob/master/homeassistant/helpers/entity.py#L18). ## {% linkable_title Allowing your platform to be discovered %} diff --git a/source/developers/architecture.markdown b/source/developers/architecture.markdown index 99ca5a1f297..974cc312990 100644 --- a/source/developers/architecture.markdown +++ b/source/developers/architecture.markdown @@ -9,7 +9,7 @@ sharing: true footer: true --- -Before we dive into the Home Assistant architecture, it is important to get a clear overview of the home automation landscape as a whole. This will allow us to show how the different parts of Home Assistant fit in the picture. For a more lengthy discussion about what each part in this overview is responsible for, check out our blog. A tl;dr version of the blog: +Before we dive into the Home Assistant architecture, it is important to get a clear overview of the home automation landscape as a whole. This will allow us to show how the different parts of Home Assistant fit in the picture. For a more lengthy discussion about what each part in this overview is responsible for, check out our blog. A tl;dr version of the blog: * Home Control is responsible for collecting information on- and controlling devices. * Home Automation triggers commands based on user configurations. @@ -31,18 +31,18 @@ The Home Assistant core is responsible for Home Control. It has four parts to ma * The **Timer** will send every 1 second a `time_changed` event on the event bus.
-
-
+
+
Overview of the Home Assistant core architecture
-
-
+
+
Overview of the full Home Assistant architecture with a couple of loaded components and platforms.
-
-
+
+
Overview of the Home Assistant architecture for multiple devices.
<config directory>/custom_components/<component name>
- * homeassistant/components/<component name>
(built-in components)
+ * `hass
| The Home Assistant object. Call its methods to track time, register services, listen for events or track states: [Overview of available methods.](https://github.com/balloob/home-assistant/blob/dev/homeassistant/core.py#L55) |
-| config
| A dict containing the configuration. The keys of the config-dict are component names and the value is another dict with the component configuration.: [Details](https://github.com/balloob/home-assistant/blob/dev/homeassistant/core.py#L687) |
+### {% linkable_title `hass`: the Home Assistant instance %}
-### {% linkable_title Guidance on using the Home Assistant object %}
-The Home Assistant object contains three objects to help you interact with the system.
+The Home Assistant instace contains three objects to help you interact with the system.
| Object | Description |
| ------ | ----------- |
-| hass.states
| This is the StateMachine. It allows you to set states and track when they are changed. [See available methods](https://github.com/balloob/home-assistant/blob/dev/homeassistant/core.py#L434). |
-| hass.bus
| This is the EventBus. It allows you to trigger and listen for events.hass.services
| This is the ServiceRegistry. It allows you to register services.@@ -28,39 +28,29 @@ http: development: 1 ``` -Next step is to get the frontend code. When you clone the Home Assistant repository, the frontend -repository is not cloned by default. You will have to trigger this manually by running from the -command line: +Next step is to get the frontend code. When you clone the Home Assistant repository, the frontend repository is not cloned by default. You will have to do this by running from the command line: ```bash -git submodule update --init +$ git submodule update --init ``` -After checking out the frontend code, you will have to install the frontend dependencies. Firing off -a build of the frontend by running `script/build_frontend` will ensure they get installed. +After checking out the frontend code, you will have to install the frontend dependencies. Firing off a build of the frontend by running `script/build_frontend` will ensure they get installed. -Once this is done, you can start editting the webcomponents in the folder -`homeassistant/components/frontend/www_static/home-assistant-polymer/src`. To see the changes you've -made, simply refresh your browser. +Once this is done, you can start editting the webcomponents in the folder `homeassistant/components/frontend/www_static/home-assistant-polymer/src`. To see the changes you've made, simply refresh your browser. ## {% linkable_title Enabling JavaScript backend development %} -Polymer is only providing a UI toolkit for Home Assistant. All data management and interaction with -the server is done by `home-assistant-js` leveraging NuclearJS. To enable JavaScript development: +Polymer is only providing a UI toolkit for Home Assistant. All data management and interaction with the server is done by `home-assistant-js` leveraging NuclearJS. To enable JavaScript development: ```bash -cd homeassistant/components/frontend/www_static/home-assistant-polymer/ -npm run setup_js_dev -npm run js_dev +$ cd homeassistant/components/frontend/www_static/home-assistant-polymer/ +$ npm run setup_js_dev +$ npm run js_dev ``` -`npm run js_dev` will start the process that will ensure that your latest changes to the JavaScript -files will be loaded when you refresh the page. This command has to be always running while working -on home-assistant-js. +`npm run js_dev` will start the process that will ensure that your latest changes to the JavaScript files will be loaded when you refresh the page. This command has to be always running while working on home-assistant-js. -After your changes have been accepted into the `home-assistant-js` repository, we'll have to update -Home Assistant Polymer to use the latest version. This can be done by updating `package.json`. Look -for the line that contains `home-assistant-js` and update the SHA to the SHA of your commit. +After your changes have been accepted into the `home-assistant-js` repository, we'll have to update Home Assistant Polymer to use the latest version. This can be done by updating `package.json`. Look for the line that contains `home-assistant-js` and update the SHA to the SHA of your commit. # {% linkable_title Building the Polymer frontend %} @@ -78,21 +68,18 @@ Building a new version of the frontend is as simple as running `script/build_fro
+Polymer build architecture diagram
Many linux distributions use the Upstart system (or similar) for managing daemons. Typically, systems based on Debian 7 or previous use Upstart. This includes Ubuntu releases before 15.04 and all current Raspian releases. If you are unsure if your system is using Upstart, you may check with the following command:
- -$ ps -p 1 -o comm=- -
If the preceding command returns the string init
, you are likely using Upstart.
Upstart will launch init scripts that are located in the directory /etc/init.d/
. A sample init script for systems using Upstart is maintained by this project.
To install this script, download it, tweak it to you liking, and install it by following the directions in the header. This script will setup Home Assistant to run when the system boots. To start/stop Home Assistant manually, issue the following commands:
- -$ sudo service hass-daemon start -$ sudo service hass-daemon stop -- -
When running Home Assistant with this script, the configuration directory will be located at /var/opt/homeassistant
. This directory will contain a verbose log rather than simply an error log.
When running daemons, it is good practice to have the daemon run under its own user name rather than the default user's name. Instructions for setting this up are outside the scope of this document.
-Newer linux distributions are trending towards using systemd for managing daemons. Typically, systems based on Fedora or Debian 8 or later use systemd. This includes Ubuntu releases including and after 15.04, CentOS, and Red Hat. If you are unsure if your system is using systemd, you may check with the following command:
- -$ ps -p 1 -o comm=- -
If the preceding command returns the string systemd
, you are likely using systemd.
If you want Home Assistant to be launched automatically, an extra step is needed to setup systemd. You need a service file to control Home Assistant with systemd.
- -$ su -c 'cat <<EOF >> /lib/systemd/system/home-assistant.service -[Unit] -Description=Home Assistant -After=network.target - -[Service] -Type=simple -ExecStart=/usr/local/bin/hass -# Next line is to run as a specific user -# for Raspberry Pi users, keep it at 'pi' -User=pi - -[Install] -WantedBy=multi-user.target -EOF' -- -
You need to reload systemd to make the daemon aware of the new configuration. Enable and launch Home Assistant after that.
- -$ sudo systemctl --system daemon-reload -$ sudo systemctl enable home-assistant -$ sudo systemctl start home-assistant -- -
If everything went well, sudo systemctl start home-assistant
should give you a positive feedback.
$ sudo systemctl status home-assistant -l -● home-assistant.service - Home Assistant - Loaded: loaded (/usr/lib/systemd/system/home-assistant.service; disabled; vendor preset: disabled) - Active: active (running) since Thu 2015-06-25 23:38:37 CEST; 3min 13s ago - Main PID: 8557 (python3.4) - CGroup: /system.slice/home-assistant.service - └─8557 /usr/bin/python3.4 -m homeassistant -[...] -- -
To get Home Assistant's logging output, simple use journalctl
.
$ sudo journalctl -f -u home-assistant- -
Setting up Home Assistant to run as a background service is simple. OS X will -start it on boot and make sure it's always running.
- -To get Home Assistant installed as a background service, run:
- -$ hass --install-osx - -Home Assistant has been installed. Open it here: http://localhost:8123 -- -
Home Assistant will log to ~/Library/Logs/homeassistant.log
To uninstall the service, run:
- -$ hass --uninstall-osx - -Home Assistant has been uninstalled. -- -
Installing and running Home Assistant on your local machine is easy. Make sure you have Python 3.4 installed and execute the following code in a console:
- -$ pip3 install homeassistant -$ hass --open-ui -- -
Running these commands will:
-Installation with Docker is straightforward. Adjust the following command so that /path/to/your/config/
points at the folder where you want to store your config and run it:
$ docker run -d --name="home-assistant" -v /path/to/your/config:/config -v /etc/localtime:/etc/localtime:ro --net=host balloob/home-assistant
-
-
-This will launch Home Assistant and serve its web interface from port 8123 on your Docker host.
- -
-When using boot2docker on OS X you are unable to map the local time to your Docker container. Replace -v /etc/localtime:/etc/localtime:ro
with -e "TZ=America/Los_Angeles"
(replacing America/Los_Angeles with your timezone)
-
Home Assistant requires the Raspberry Pi to run Raspbian Jessie. This version has been released on September 24, 2015 and comes by default with Python 3.4 which is required for Home Assistant.
- -Execute the following code in a console:
- -$ pip3 install homeassistant
-$ hass --open-ui
-
-
-Running these commands will:
-If you run into any issues, please see the troubleshooting page. It contains solutions to many of the more commonly encountered issues.
- -For additional help, in addition to this site, there are three sources:
-If you want to have Home Assistant start on boot, autostart instructions can be found here.
- -To see what Home Assistant can do, launch demo mode: hass --demo-mode
To update Home Assistant to the latest release: pip3 install --upgrade homeassistant
+When using boot2docker on OS X you are unable to map the local time to your Docker container. Replace `-v /etc/localtime:/etc/localtime:ro` with `-e "TZ=America/Los_Angeles"` (replacing America/Los_Angeles with [your timezone](http://en.wikipedia.org/wiki/List_of_tz_database_time_zones)) +
+ +-Whenever you report an issue, be aware that we are a group of volunteers that do not have access to -every single device in the world nor unlimited time to fix every problem out there. +Whenever you report an issue, be aware that we are a group of volunteers that do not have access to every single device in the world nor unlimited time to fix every problem out there.