From 04390b9357d5a7b6ca88f57c81ea3c036dc73f8d Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 20 Feb 2016 09:45:42 +0100 Subject: [PATCH 1/2] Add first section of devel tutorial --- source/developers/tutorial.markdown | 117 ++++++++++++++++++ .../images/screenshots/create-component01.png | Bin 0 -> 11155 bytes 2 files changed, 117 insertions(+) create mode 100644 source/developers/tutorial.markdown create mode 100644 source/images/screenshots/create-component01.png diff --git a/source/developers/tutorial.markdown b/source/developers/tutorial.markdown new file mode 100644 index 00000000000..fb149a8b8a3 --- /dev/null +++ b/source/developers/tutorial.markdown @@ -0,0 +1,117 @@ +--- +layout: page +title: "Development tuorial" +description: "Tutorial about the first steps on Home Assistant development" +date: 2016-02-20 07:00 +sidebar: false +comments: false +sharing: true +footer: true +--- + +This is a simple tutorial on how to write a component for [Home Assistant](https://home-assistant.io/). We will work on a component called "information". The purpose of this component is to display a given text in the frontend. + +The setup of a development environment is described in the [Developers section](/developers/#starting-development) of the documentation. + +As a start, create a file `information.py` in your Git checkout of Home Assistant in the folder `homeassistant/component/`. + +```python +""" +homeassistant.components.information +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The information component allows to show text in the frontend. + +For more details about this component, please refer to the documentation at +https://home-assistant.io/components/information/ +""" +import logging + +_LOGGER = logging.getLogger(__name__) + +DOMAIN = 'information' +DEPENDENCIES = [] + +def setup(hass, config=None): + """ Setup the Information component. """ + + _LOGGER.info("The 'information' component is ready!") + + return True +``` + +1. In the file header we decided to add some details. Like the path, a short description, and the link to the documentation. +2. We want to do some logging. This means that we import the Python logging module and create an alias. +3. The component name is equal to the domain name. +4. At the moment this component has no dependencies. For detail check [dependencies](/developers/creating_components/#dependencies) section. +5. The `setup` function will take care of the initialization of our component. + The component will only write a log message. Keep in mind for later that you have several options for the severity: + + - _LOGGER.info(msg) + - _LOGGER.warning(msg) + - _LOGGER.error(msg) + - _LOGGER.critical(msg) + - _LOGGER.exception(msg) + +7. We return `True` if everything is ok. + +Add the component to your `configuration.yaml` file. + +```yaml +information: +``` + +If you replace `_LOGGER.info("The 'information' component is ready!")` with or add + +```python +hass.states.set('information.Text', 'Info component') +``` + +Then the component will not be different to the sample included in the `config/custom_components` folder or shown as an [example](/cookbook/python_component_basic_state/). After a start or a restart of Home Assistant the component will be visible in the frontend. + +

+ +

+ +The next step is the introduction of configuration options. Most configuration details are coming out of the `configuration.yaml` file. To do that we need to update the `def setup()` method to accept configuration information and access the configuration variable in the `setup` method. + +```python +import logging + +_LOGGER = logging.getLogger(__name__) + +DOMAIN = 'information' +DEPENDENCIES = [] +CONF_NAME = 'text' + +def setup(hass, config): + """ Setup the Information component. """ + + test = config[DOMAIN].get(CONF_NAME, DEFAULT_NAME) + hass.states.set('information.Text', test) + + return True +``` + +To add the latest feature of our component, update the entry in your `configuration.yaml` file. + +```yaml +information: + text: 'Sample text' +``` + +It's important to check if all mandatory configuration variables are provided. If not, the setup should fail. We will use the `validate_config` as a helper to archive this. The next listing shows the essential parts. + +```python +from homeassistant.helpers import validate_config +[...] + if not validate_config(config, {DOMAIN: ['text']}, _LOGGER): + return False +``` + +So far our new component is rendered as a default compoment in the frontend. But we want our own view of the component in the frontend. We assume that you have setup the (frontend development)[/developers/frontend/] already + +We need two new files in the folder `src/cards/`: + +- ha-information-card.html +- ha-information-card.js + diff --git a/source/images/screenshots/create-component01.png b/source/images/screenshots/create-component01.png new file mode 100644 index 0000000000000000000000000000000000000000..74a4fd0cde65d872fb95a24a664f9fb6182ab8a8 GIT binary patch literal 11155 zcmcI~bySpVwD(I0Lyrdq4@is!f`n3ngo1#mfJifxN=Zm}dI%Ln5KuY}NOzZXC?E*Z z-2y{*!?(w~zI*?;|J=3iy6;)%oM9N=dEWi(y??QvcTW^#smK|~5d@)G^iEtZ(Cp9f>#0b(UBk7gMUNEWV(bH&F zoT6x8%dN-C=&{c>c+_U~Y-pzYhzRLSN%T67|My3A?W@c@5h382{NO4 zJfr8ycxebyglmh`@9Ic8L?w3ig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Swd@+4**vWMyPL{1aN!#E8Bun!86%n7f;BoFWk*2n;I#U6{_ojQ1}H ztVuLKLm;>eP+$tFwqQHj*_mG>{!ZYP(tz}$6M9V{@8Q?6v9WdfumrH&V7(XNL834H zoH0b@6&BiBS#`o0vh2QJaY!-aT|XpS&5WM`PFb376l+0>XCH+9`TRrV7V*HqfJw0y zDJdyD0i6$0%y;)U0*q%nJuom3zCt%Q6;7LamBf&kdw{!bY-Tp>hT^q20iSniA3C&F zwptZ8>mdSXItMwvLy$!WsF6=!Ykq=A(xnepiE{_!*R}=7btJhrS+e|3GL(6 z_|OB?liY>O{#`C|f|OW-Tcl~(mF6dlsbo=}@Js!3=xc>18bh@D4&GivnXD{)%y2d^ z6GfbIs>MKvn?tr&?sc3HAbAzK1dn(~BdTh%9^I8kjwtW#3@a*e6Js%LNDSBRXn!u=dc{eS)+eHcGO literal 0 HcmV?d00001 From 3fe9bf754b8e359a626e47d6ada27f4aed672b56 Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Sat, 20 Feb 2016 10:50:24 +0100 Subject: [PATCH 2/2] Add more content --- source/developers/tutorial.markdown | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/source/developers/tutorial.markdown b/source/developers/tutorial.markdown index fb149a8b8a3..8dbde843ce5 100644 --- a/source/developers/tutorial.markdown +++ b/source/developers/tutorial.markdown @@ -1,6 +1,6 @@ --- layout: page -title: "Development tuorial" +title: "Development tutorial" description: "Tutorial about the first steps on Home Assistant development" date: 2016-02-20 07:00 sidebar: false @@ -13,6 +13,9 @@ This is a simple tutorial on how to write a component for [Home Assistant](https The setup of a development environment is described in the [Developers section](/developers/#starting-development) of the documentation. +## {% linkable_title Component %} + + As a start, create a file `information.py` in your Git checkout of Home Assistant in the folder `homeassistant/component/`. ```python @@ -66,7 +69,7 @@ If you replace `_LOGGER.info("The 'information' component is ready!")` with or a hass.states.set('information.Text', 'Info component') ``` -Then the component will not be different to the sample included in the `config/custom_components` folder or shown as an [example](/cookbook/python_component_basic_state/). After a start or a restart of Home Assistant the component will be visible in the frontend. +then the component will not be different to the sample included in the `config/custom_components` folder or shown as an [example](/cookbook/python_component_basic_state/). After a start or a restart of Home Assistant the component will be visible in the frontend.

@@ -74,6 +77,8 @@ Then the component will not be different to the sample included in the `config/c The next step is the introduction of configuration options. Most configuration details are coming out of the `configuration.yaml` file. To do that we need to update the `def setup()` method to accept configuration information and access the configuration variable in the `setup` method. +More details about this topic can be found in the [User given configuration](/developers/creating_components/#config-user-given-configuration) section. + ```python import logging @@ -108,10 +113,28 @@ from homeassistant.helpers import validate_config return False ``` -So far our new component is rendered as a default compoment in the frontend. But we want our own view of the component in the frontend. We assume that you have setup the (frontend development)[/developers/frontend/] already +## {% linkable_title Frontend %} + +So far our new component is rendered as a default compoment in the frontend. But we want our own view of the component in the frontend. We assume that you have setup the (frontend development)[/developers/frontend/] already. We need two new files in the folder `src/cards/`: - ha-information-card.html - ha-information-card.js + +TBD + +Rebuild the frontend. + +```bash +$ script/build_frontend +``` + +Change the [http](/components/http/) component to load the `development` version of the frontend as also mentioned in the [ Setting up the environment](/developers/frontend/#setting-up-the-environment) section of the (frontend development)[/developers/frontend/] page. + +```yaml +http: + development: 1 +``` +