mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-22 00:36:49 +00:00
Add categories to cookbook
This commit is contained in:
parent
f5a7217b3f
commit
a06217bbee
@ -6,9 +6,9 @@ module Jekyll
|
||||
end
|
||||
|
||||
def render(context)
|
||||
slug = @title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
||||
|
||||
"<a class='title-link' name='#{slug}' href='\##{slug}'></a> #{@title}"
|
||||
title = Liquid::Template.parse(@markup).render context
|
||||
slug = title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')
|
||||
"<a class='title-link' name='#{slug}' href='\##{slug}'></a> #{title}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Automation for rainy days"
|
||||
description: "Basic example how to use weather conditions to set states"
|
||||
date: 2015-10-08 19:05
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
### {% linkable_title Rainy Day Light %}
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Automation examples using the sun"
|
||||
description: "Automation examples that use the sun."
|
||||
date: 2015-10-08 19:05
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### {% linkable_title Turn on the living room lights 45 minutes before sunset if anyone home %}
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Automation: use_trigger_values"
|
||||
description: "Basic example how to use use_trigger_values in automation"
|
||||
date: 2015-10-08 19:05
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
### {% linkable_title Basic example for use_trigger_values %}
|
||||
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Configuration.yaml by Carlo Costanzo"
|
||||
description: ""
|
||||
date: 2016-02-07 11:45
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Full configuration.yaml Examples
|
||||
ha_external_link: https://gist.github.com/CCOSTAN/9934de973a293b809868
|
||||
---
|
||||
|
@ -0,0 +1,13 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Configuration.yaml by happyleavesaoc"
|
||||
description: ""
|
||||
date: 2016-02-07 11:45
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Full configuration.yaml Examples
|
||||
ha_external_link: https://github.com/happyleavesaoc/my-home-automation/tree/master/homeassistant
|
||||
---
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Dim lights when playing media"
|
||||
description: "Dim lights up or down when playing media"
|
||||
date: 2015-10-15 19:05
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
Like it how the lights dim up/down at the movies? Do it at home as well!
|
||||
|
56
source/_cookbook/python_component_basic_service.markdown
Normal file
56
source/_cookbook/python_component_basic_service.markdown
Normal file
@ -0,0 +1,56 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Basic Service Example"
|
||||
description: ""
|
||||
date: 2016-02-07 12:13
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Custom Python Component Examples
|
||||
---
|
||||
|
||||
This is a simple hello world example to show the basics of registering a service. To use this example, create the file `<config dir>/custom_components/hello_service.py` and copy the below example code.
|
||||
|
||||
Services can be called from automation and from the service developer tools in the frontend.
|
||||
|
||||
```python
|
||||
# The domain of your component. Should be equal to the name of your component
|
||||
DOMAIN = "hello_service"
|
||||
|
||||
ATTR_NAME = 'name'
|
||||
DEFAULT_NAME = 'World'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Setup is called when Home Assistant is loading our component. """
|
||||
|
||||
def handle_hello(call):
|
||||
name = call.data.get(ATTR_NAME, DEFAULT_NAME)
|
||||
|
||||
hass.states.set('hello.service.hello', name)
|
||||
|
||||
hass.services.register(DOMAIN, 'hello', handle_hello)
|
||||
|
||||
# return boolean to indicate that initialization was successful
|
||||
return True
|
||||
```
|
||||
|
||||
Load the component by adding the following to your `configuration.yaml`. When your component is loaded, a new service should be available to call.
|
||||
|
||||
```yaml
|
||||
# configuration.yaml entry
|
||||
hello_service:
|
||||
```
|
||||
|
||||
Open the frontend and in the sidebar, click the first icon in the developer tool section. This will open the Call Service developer tool. On the right, find your service and click on it. This will automatically fill in the correct values.
|
||||
|
||||
Pressing "Call Service" will now call your service without any parameters. This will cause your service to create a state with the default name 'World'. If you want to specify the name, you have to specify parameters. Add the following JSON as Service Data and press "Call Service again".
|
||||
|
||||
```json
|
||||
{
|
||||
"name": "Planet"
|
||||
}
|
||||
```
|
||||
|
||||
The service will now overwrite the previous state with "Planet".
|
43
source/_cookbook/python_component_basic_state.markdown
Normal file
43
source/_cookbook/python_component_basic_state.markdown
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Basic State Setting Example"
|
||||
description: ""
|
||||
date: 2016-02-07 12:13
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Custom Python Component Examples
|
||||
---
|
||||
|
||||
This is a simple hello world example to show the basics for setting a state. To use this example, create the file `<config dir>/custom_components/hello_state.py` and copy the below example code.
|
||||
|
||||
```python
|
||||
# The domain of your component. Should be equal to the name of your component
|
||||
DOMAIN = "hello_state"
|
||||
|
||||
CONF_NAME = 'name'
|
||||
DEFAULT_NAME = 'World'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Setup is called when Home Assistant is loading our component. """
|
||||
|
||||
# Get the name from the configuration. Use DEFAULT_NAME if no name provided.
|
||||
name = config[DOMAIN].get(CONF_NAME, DEFAULT_NAME)
|
||||
|
||||
# States are in the format DOMAIN.OBJECT_ID
|
||||
hass.states.set('hello_state.hello', name)
|
||||
|
||||
# return boolean to indicate that initialization was successful
|
||||
return True
|
||||
```
|
||||
|
||||
Load the component by adding the following to your `configuration.yaml`:
|
||||
|
||||
```yaml
|
||||
# configuration.yaml entry
|
||||
hello_state:
|
||||
# optional
|
||||
name: Paulus
|
||||
```
|
78
source/_cookbook/python_component_mqtt_basic.markdown
Normal file
78
source/_cookbook/python_component_mqtt_basic.markdown
Normal file
@ -0,0 +1,78 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Basic MQTT Example"
|
||||
description: ""
|
||||
date: 2016-02-07 12:13
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Custom Python Component Examples
|
||||
---
|
||||
|
||||
<p class='note'>
|
||||
This example requires you to have the [MQTT component](/components/mqtt/) up and running.
|
||||
</p>
|
||||
|
||||
This is a simple hello world example to show the basics of using MQTT in a custom component. To use this example, create the file `<config dir>/custom_components/hello_mqtt.py` and copy the below example code.
|
||||
|
||||
This example follows a topic on MQTT and updates the state of an entity to the last message received on that topic. It will also register a service 'set_state' that will publish a message to the MQTT topic that we're listening to.
|
||||
|
||||
```python
|
||||
import homeassistant.loader as loader
|
||||
|
||||
# The domain of your component. Should be equal to the name of your component
|
||||
DOMAIN = "hello_mqtt"
|
||||
|
||||
# List of component names (string) your component depends upon
|
||||
DEPENDENCIES = ['mqtt']
|
||||
|
||||
|
||||
CONF_TOPIC = 'topic'
|
||||
DEFAULT_TOPIC = 'home-assistant/hello_mqtt'
|
||||
|
||||
|
||||
def setup(hass, config):
|
||||
""" Setup our hello_mqtt component. """
|
||||
mqtt = loader.get_component('mqtt')
|
||||
topic = config[DOMAIN].get('topic', DEFAULT_TOPIC)
|
||||
entity_id = 'hello_mqtt.last_message'
|
||||
|
||||
# Listener to be called when we receive a message
|
||||
def message_received(topic, payload, qos):
|
||||
""" A new MQTT message has been received. """
|
||||
hass.states.set(entity_id, payload)
|
||||
|
||||
# Subscribe our listener to a topic
|
||||
mqtt.subscribe(hass, topic, message_received)
|
||||
|
||||
# Set the intial state
|
||||
hass.states.set(entity_id, 'No messages')
|
||||
|
||||
# Service to publish a message on MQTT
|
||||
def set_state_service(call):
|
||||
""" Service to send a message. """
|
||||
mqtt.publish(hass, topic, call.data.get('new_state'))
|
||||
|
||||
# Register our service with Home Assistant
|
||||
hass.services.register(DOMAIN, 'set_state', set_state_service)
|
||||
|
||||
# return boolean to indicate that initialization was successful
|
||||
return True
|
||||
```
|
||||
|
||||
Load the component by adding the following to your `configuration.yaml`. When your component is loaded, a new entity should popup and there should be a new service available to call.
|
||||
|
||||
```yaml
|
||||
# configuration.yaml entry
|
||||
hello_mqtt:
|
||||
topic: some_mqtt/topic/here
|
||||
```
|
||||
|
||||
You can call the service with example payload:
|
||||
|
||||
```json
|
||||
{
|
||||
"new_state": "some new state"
|
||||
}
|
||||
```
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Restart Home Assistant if Wemo Switch is not detected"
|
||||
description: "Restart Home Assistant if Wemo Switch is not detected."
|
||||
date: 2016-01-29 08:00
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
### {% linkable_title Restart Home Assistant %}
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Send a reminder"
|
||||
description: "Send a reminder"
|
||||
date: 2015-12-16 08:00
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### {% linkable_title Send a reminder %}
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Track your battery level"
|
||||
description: "Basic example how to track the battery level of your mobile devices."
|
||||
date: 2016-01-29 09:00
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
### {% linkable_title Battery level %}
|
||||
|
@ -3,10 +3,11 @@ layout: page
|
||||
title: "Motion detected light"
|
||||
description: "Turn on lights for 10 minutes when motion detected."
|
||||
date: 2015-10-08 19:05
|
||||
sidebar: false
|
||||
sidebar: true
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
ha_category: Automation Examples
|
||||
---
|
||||
|
||||
#### {% linkable_title Turn on lights with a resettable off timer %}
|
||||
|
25
source/_includes/asides/cookbook_navigation.html
Normal file
25
source/_includes/asides/cookbook_navigation.html
Normal file
@ -0,0 +1,25 @@
|
||||
<section class="aside-module grid__item one-whole lap-one-half">
|
||||
{% include edit_github.html %}
|
||||
{% assign cookbook = site.cookbook | sort: 'title' %}
|
||||
|
||||
<div class='section'>
|
||||
<a href='/cookbook'>Back to the cookbook</a>
|
||||
</div>
|
||||
|
||||
<div class='section'>
|
||||
<h1 class="title delta">{{page.ha_category}}</h1>
|
||||
<ul class='divided'>
|
||||
{% for recipe in cookbook %}
|
||||
{% if recipe.ha_category == page.ha_category %}
|
||||
<li>
|
||||
{% if recipe.url == page.url %}
|
||||
{{recipe.title}}
|
||||
{% else %}
|
||||
<a href='{{recipe.url}}'>{{recipe.title}}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
@ -2,6 +2,8 @@
|
||||
{% assign url_parts = page.url | split: '/' %}
|
||||
{% if url_parts[1] == 'components' %}
|
||||
{% include asides/component_navigation.html | compact_newlines %}
|
||||
{% elsif url_parts[1] == 'cookbook' %}
|
||||
{% include asides/cookbook_navigation.html | compact_newlines %}
|
||||
{% else %}
|
||||
{% include asides/about.html %}
|
||||
|
||||
|
@ -1,24 +1,39 @@
|
||||
---
|
||||
layout: page
|
||||
title: "Configuration Cookbook"
|
||||
description: "Community maintained list of configuration exmaples."
|
||||
title: "Cookbook"
|
||||
description: "Community maintained list of different ways to use Home Assistant."
|
||||
date: 2015-10-08 19:05
|
||||
sidebar: false
|
||||
comments: false
|
||||
sharing: true
|
||||
footer: true
|
||||
regenerate: true
|
||||
hide_github_edit: true
|
||||
---
|
||||
|
||||
This is a community currated list of `configuration.yaml` examples. New recipes can be added via the [home-assistant.io repository](https://github.com/balloob/home-assistant.io/tree/master/source/_cookbook).
|
||||
This is a community currated list of different ways to use Home Assistant. New recipes can be added via the [home-assistant.io repository](https://github.com/balloob/home-assistant.io/tree/master/source/_cookbook).
|
||||
|
||||
{% for recipe in site.cookbook %}
|
||||
* [{{recipe.title}}]({{recipe.url}})
|
||||
{% endfor %}
|
||||
{% assign cookbook = site.cookbook | sort: 'title' %}
|
||||
{% assign categories = cookbook | sort: 'ha_category' | map: 'ha_category' | uniq %}
|
||||
|
||||
### {% linkable_title Configuration.yaml Gists %}
|
||||
{% for category in categories %}
|
||||
### {% linkable_title {{ category }} %}
|
||||
|
||||
{% if category == 'Automation Examples' %}
|
||||
|
||||
{% elsif category == 'Full configuration.yaml examples' %}
|
||||
Some users keep a public scrubbed copy of their `configuration.yaml` to learn from.
|
||||
{% elsif category == '' %}
|
||||
|
||||
- [Configuration.yaml by Carlo Costanzo](https://gist.github.com/CCOSTAN/9934de973a293b809868)
|
||||
- [Configuration.yaml by happyleavesaoc](https://github.com/happyleavesaoc/my-home-automation/tree/master/homeassistant)
|
||||
{% endif %}
|
||||
|
||||
{% for recipe in site.cookbook %}
|
||||
{% if recipe.ha_category == category %}
|
||||
{% if recipe.ha_external_link %}
|
||||
* [{{recipe.title}}]({{recipe.ha_external_link}})
|
||||
{% else %}
|
||||
* [{{recipe.title}}]({{recipe.url}})
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user