diff --git a/atom.xml b/atom.xml index 92425cd231..14a7b4b619 100644 --- a/atom.xml +++ b/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/announcements/atom.xml b/blog/categories/announcements/atom.xml index f2a934c096..e89e6d9a77 100644 --- a/blog/categories/announcements/atom.xml +++ b/blog/categories/announcements/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Announcements | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/community/atom.xml b/blog/categories/community/atom.xml index 2da8b9a4b7..70886850fa 100644 --- a/blog/categories/community/atom.xml +++ b/blog/categories/community/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Community | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/device-tracking/atom.xml b/blog/categories/device-tracking/atom.xml index b7b37a6a6a..407d77a4cf 100644 --- a/blog/categories/device-tracking/atom.xml +++ b/blog/categories/device-tracking/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Device-Tracking | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/esp8266/atom.xml b/blog/categories/esp8266/atom.xml index 23e7c62173..737e64d427 100644 --- a/blog/categories/esp8266/atom.xml +++ b/blog/categories/esp8266/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: ESP8266 | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/how-to/atom.xml b/blog/categories/how-to/atom.xml index 56c5afe276..94a5539632 100644 --- a/blog/categories/how-to/atom.xml +++ b/blog/categories/how-to/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: How-To | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/ibeacons/atom.xml b/blog/categories/ibeacons/atom.xml index 18b1e4d8e6..35c8164b84 100644 --- a/blog/categories/ibeacons/atom.xml +++ b/blog/categories/ibeacons/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: iBeacons | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/internet-of-things/atom.xml b/blog/categories/internet-of-things/atom.xml index 5bc0fea6d6..ce16d93cac 100644 --- a/blog/categories/internet-of-things/atom.xml +++ b/blog/categories/internet-of-things/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Internet-of-Things | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/iot-data/atom.xml b/blog/categories/iot-data/atom.xml index a87622d58f..cbb3adfe61 100644 --- a/blog/categories/iot-data/atom.xml +++ b/blog/categories/iot-data/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: IoT-Data | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/media/atom.xml b/blog/categories/media/atom.xml index eb8110d474..01b4506bfe 100644 --- a/blog/categories/media/atom.xml +++ b/blog/categories/media/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Media | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/merchandise/atom.xml b/blog/categories/merchandise/atom.xml index e70812566a..753453ab40 100644 --- a/blog/categories/merchandise/atom.xml +++ b/blog/categories/merchandise/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Merchandise | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/micropython/atom.xml b/blog/categories/micropython/atom.xml index 4df47ef96b..f425a6187c 100644 --- a/blog/categories/micropython/atom.xml +++ b/blog/categories/micropython/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Micropython | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/mqtt/atom.xml b/blog/categories/mqtt/atom.xml index 6cf5c4abf5..0e3c857e8a 100644 --- a/blog/categories/mqtt/atom.xml +++ b/blog/categories/mqtt/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: MQTT | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/organisation/atom.xml b/blog/categories/organisation/atom.xml index 123339e9f7..778776055a 100644 --- a/blog/categories/organisation/atom.xml +++ b/blog/categories/organisation/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Organisation | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/owntracks/atom.xml b/blog/categories/owntracks/atom.xml index 166c6ec15c..970f4cfd2b 100644 --- a/blog/categories/owntracks/atom.xml +++ b/blog/categories/owntracks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: OwnTracks | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/presence-detection/atom.xml b/blog/categories/presence-detection/atom.xml index 6929332025..a4a888a176 100644 --- a/blog/categories/presence-detection/atom.xml +++ b/blog/categories/presence-detection/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Presence-Detection | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/public-service-announcement/atom.xml b/blog/categories/public-service-announcement/atom.xml index edc2207901..e3375cc9ac 100644 --- a/blog/categories/public-service-announcement/atom.xml +++ b/blog/categories/public-service-announcement/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Public-Service-Announcement | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/release-notes/atom.xml b/blog/categories/release-notes/atom.xml index 50e79d77ca..dfd878c1d4 100644 --- a/blog/categories/release-notes/atom.xml +++ b/blog/categories/release-notes/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Release-Notes | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/survey/atom.xml b/blog/categories/survey/atom.xml index 7d57aa5cec..3381275610 100644 --- a/blog/categories/survey/atom.xml +++ b/blog/categories/survey/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Survey | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/talks/atom.xml b/blog/categories/talks/atom.xml index 4b6892c5ff..7c565bba54 100644 --- a/blog/categories/talks/atom.xml +++ b/blog/categories/talks/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Talks | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/technology/atom.xml b/blog/categories/technology/atom.xml index 9b0da484b7..666d5650c4 100644 --- a/blog/categories/technology/atom.xml +++ b/blog/categories/technology/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Technology | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/user-stories/atom.xml b/blog/categories/user-stories/atom.xml index 4154e2bca8..f11bb04a04 100644 --- a/blog/categories/user-stories/atom.xml +++ b/blog/categories/user-stories/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: User-Stories | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/video/atom.xml b/blog/categories/video/atom.xml index f385643b35..b7b8f4f1e3 100644 --- a/blog/categories/video/atom.xml +++ b/blog/categories/video/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Video | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/blog/categories/website/atom.xml b/blog/categories/website/atom.xml index 23f55f259d..60e54ff84d 100644 --- a/blog/categories/website/atom.xml +++ b/blog/categories/website/atom.xml @@ -4,7 +4,7 @@ <![CDATA[Category: Website | Home Assistant]]> - 2017-12-24T23:30:07+00:00 + 2017-12-25T20:27:02+00:00 https://home-assistant.io/ diff --git a/cookbook/index.html b/cookbook/index.html index 50ffa9a2bb..905e51e856 100644 --- a/cookbook/index.html +++ b/cookbook/index.html @@ -142,7 +142,12 @@ A great place to find popular configurations is on this Automation in Python Examples

Custom Python Component Examples

    diff --git a/cookbook/python_component_automation/index.html b/cookbook/python_component_automation/index.html new file mode 100644 index 0000000000..f744b5770b --- /dev/null +++ b/cookbook/python_component_automation/index.html @@ -0,0 +1,292 @@ + + + + + + + + + Automation in Code - Home Assistant + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    +

    + Automation in Code +

    +
    +
    +

    Example component to target an entity_id to:

    +
      +
    • turn it on at 7AM in the morning
    • +
    • turn it on if anyone comes home and it is off
    • +
    • turn it off if all lights are turned off
    • +
    • turn it off if all people leave the house
    • +
    • offer a service to turn it on for 10 seconds
    • +
    +

    To set it up, add the following lines to your configuration.yaml file:

    +
    # Example configuration.yaml entry
    +example:
    +  target: TARGET_ENTITY
    +
    +
    +

    Configuration variables:

    +
      +
    • target (Required): TARGET_ENTITY should be one of your devices that can be turned on and off, e.g., a light or a switch. Example value could be light.Ceiling or switch.AC (if you have these devices with those names).
    • +
    +

    Create the file <config dir>/custom_components/example.py and copy paste the content below:

    +
    """
    +Example of a custom component.
    +"""
    +import time
    +import logging
    +
    +from homeassistant.const import STATE_HOME, STATE_NOT_HOME, STATE_ON, STATE_OFF
    +from homeassistant.helpers import validate_config
    +from homeassistant.helpers.event_decorators import \
    +    track_state_change, track_time_change
    +from homeassistant.helpers.service import service
    +import homeassistant.components as core
    +from homeassistant.components import device_tracker
    +from homeassistant.components import light
    +
    +# The domain of your component. Should be equal to the name of your component.
    +DOMAIN = "example"
    +
    +# List of component names (string) your component depends upon.
    +# We depend on group because group will be loaded after all the components that
    +# initialize devices have been setup.
    +DEPENDENCIES = ['group', 'device_tracker', 'light']
    +
    +# Configuration key for the entity id we are targeting.
    +CONF_TARGET = 'target'
    +
    +# Variable for storing configuration parameters.
    +TARGET_ID = None
    +
    +# Name of the service that we expose.
    +SERVICE_FLASH = 'flash'
    +
    +# Shortcut for the logger
    +_LOGGER = logging.getLogger(__name__)
    +
    +
    +def setup(hass, config):
    +    """Setup example component."""
    +    global TARGET_ID
    +
    +    # Validate that all required config options are given.
    +    if not validate_config(config, {DOMAIN: [CONF_TARGET]}, _LOGGER):
    +        return False
    +
    +    TARGET_ID = config[DOMAIN][CONF_TARGET]
    +
    +    # Validate that the target entity id exists.
    +    if hass.states.get(TARGET_ID) is None:
    +        _LOGGER.error("Target entity id %s does not exist",
    +                      TARGET_ID)
    +
    +        # Tell the bootstrapper that we failed to initialize and clear the
    +        # stored target id so our functions don't run.
    +        TARGET_ID = None
    +        return False
    +
    +    # Tell the bootstrapper that we initialized successfully.
    +    return True
    +
    +
    +@track_state_change(device_tracker.ENTITY_ID_ALL_DEVICES)
    +def track_devices(hass, entity_id, old_state, new_state):
    +    """Called when the group.all devices change state."""
    +    # If the target id is not set, return
    +    if not TARGET_ID:
    +        return
    +
    +    # If anyone comes home and the entity is not on, turn it on.
    +    if new_state.state == STATE_HOME and not core.is_on(hass, TARGET_ID):
    +
    +        core.turn_on(hass, TARGET_ID)
    +
    +    # If all people leave the house and the entity is on, turn it off.
    +    elif new_state.state == STATE_NOT_HOME and core.is_on(hass, TARGET_ID):
    +
    +        core.turn_off(hass, TARGET_ID)
    +
    +
    +@track_time_change(hour=7, minute=0, second=0)
    +def wake_up(hass, now):
    +    """Turn light on in the morning.
    +
    +    Turn the light on at 7 AM if there are people home and it is not already
    +    on.
    +    """
    +    if not TARGET_ID:
    +        return
    +
    +    if device_tracker.is_on(hass) and not core.is_on(hass, TARGET_ID):
    +        _LOGGER.info('People home at 7AM, turning it on')
    +        core.turn_on(hass, TARGET_ID)
    +
    +
    +@track_state_change(light.ENTITY_ID_ALL_LIGHTS, STATE_ON, STATE_OFF)
    +def all_lights_off(hass, entity_id, old_state, new_state):
    +    """If all lights turn off, turn off."""
    +    if not TARGET_ID:
    +        return
    +
    +    if core.is_on(hass, TARGET_ID):
    +        _LOGGER.info('All lights have been turned off, turning it off')
    +        core.turn_off(hass, TARGET_ID)
    +
    +
    +@service(DOMAIN, SERVICE_FLASH)
    +def flash_service(hass, call):
    +    """Service that will toggle the target.
    +
    +    Set the light to off for 10 seconds if on and vice versa.
    +    """
    +    if not TARGET_ID:
    +        return
    +
    +    if core.is_on(hass, TARGET_ID):
    +        core.turn_off(hass, TARGET_ID)
    +        time.sleep(10)
    +        core.turn_on(hass, TARGET_ID)
    +
    +    else:
    +        core.turn_on(hass, TARGET_ID)
    +        time.sleep(10)
    +        core.turn_off(hass, TARGET_ID)
    +
    +
    +
    +
    + +
    +
    + + + + + + + diff --git a/cookbook/python_component_simple_alarm/index.html b/cookbook/python_component_simple_alarm/index.html index ded8269606..603616363d 100644 --- a/cookbook/python_component_simple_alarm/index.html +++ b/cookbook/python_component_simple_alarm/index.html @@ -193,6 +193,9 @@

    Automation in Python Examples

      +
    • + Automation in Code +
    • Flash lights when intruder detected
    • diff --git a/developers/architecture_components/index.html b/developers/architecture_components/index.html index f2a32d148c..c725cb0e17 100644 --- a/developers/architecture_components/index.html +++ b/developers/architecture_components/index.html @@ -102,7 +102,7 @@ Diagram showing interaction between components and the Home Assistant core Turn on the lights
    -

    Look here for a comprehensive example of a home automation component.

    +

    Look here for a comprehensive example of a home automation component.

    The full picture

    When we put all the different pieces of Home Assistant together, it’s a close match for the initial home automation overview sketch. The smart home AI has not been implemented yet, so it’s not included in this picture.

    diff --git a/sitemap.xml b/sitemap.xml index 8e6b09df48..152d3ef1ff 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -3826,7 +3826,7 @@ https://home-assistant.io/components/switch.hook/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/cookbook/automation_for_rainy_days/ @@ -3873,6 +3873,10 @@ 2016-02-13T06:51:00+00:00 +https://home-assistant.io/cookbook/python_component_automation/ +2016-02-14T08:40:00+00:00 + + https://home-assistant.io/cookbook/python_component_simple_alarm/ 2016-02-14T08:40:00+00:00 @@ -4502,99 +4506,99 @@ https://home-assistant.io/docs/autostart/init.d/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/api/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/configuration/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/example_apps/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/installation/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/operation/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/reboot/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/running/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/tutorial/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/updating/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/appdaemon/windows/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/certificates/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/hadashboard/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/hass-configurator/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/ios/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/nginx/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/notebooks/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/scenegen/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/ecosystem/synology/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/tools/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/tools/dev-tools/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/tools/hass/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/docs/tools/scripts/ -2017-12-24T23:30:07+00:00 +2017-12-25T20:27:02+00:00 https://home-assistant.io/faq/after-upgrading/ @@ -5726,62 +5730,62 @@ https://home-assistant.io/demo/frontend.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/index.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-event.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-info.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-service.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-state.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-dev-template.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-history.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-iframe.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-logbook.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/demo/panels/ha-panel-map.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/googlef4f3693c209fe788.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/static/fonts/roboto/DESCRIPTION.en_us.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/static/fonts/robotomono/DESCRIPTION.en_us.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00 https://home-assistant.io/static/mdi-demo.html -2017-12-24T23:29:21+00:00 +2017-12-25T20:26:24+00:00