From ba7b9c625e239620320c69c0e2d42ea85689f231 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Thu, 27 Aug 2015 01:06:07 -0700 Subject: [PATCH] Add an introduction component to support first usage --- homeassistant/components/introduction.py | 41 ++++++++++++++++++++++++ homeassistant/config.py | 14 ++++++-- homeassistant/loader.py | 7 ++-- 3 files changed, 56 insertions(+), 6 deletions(-) create mode 100644 homeassistant/components/introduction.py diff --git a/homeassistant/components/introduction.py b/homeassistant/components/introduction.py new file mode 100644 index 00000000000..b84a02d5fa5 --- /dev/null +++ b/homeassistant/components/introduction.py @@ -0,0 +1,41 @@ +""" +homeassistant.components.introduction +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Component that will help guide the user taking its first steps. +""" +import logging + +DOMAIN = 'introduction' +DEPENDENCIES = [] + + +def setup(hass, config=None): + """ Setup the introduction component. """ + log = logging.getLogger(__name__) + log.info(""" + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Hello, and welcome to Home Assistant! + + We'll hope that we can make all your dreams come true. + + Here are some resources to get started: + + - Configuring Home Assistant: + https://home-assistant.io/getting-started/configuration.html + + - Available components: + https://home-assistant.io/components/ + + - Chat room: + https://gitter.im/balloob/home-assistant + + This message is generated by the introduction component. You can + disable it in configuration.yaml. + + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + """) + + return True diff --git a/homeassistant/config.py b/homeassistant/config.py index 6ae40e9e7c7..54ad297e62a 100644 --- a/homeassistant/config.py +++ b/homeassistant/config.py @@ -28,8 +28,15 @@ DEFAULT_CONFIG = ( (CONF_TIME_ZONE, 'UTC', 'time_zone', 'Pick yours from here: http://en.wiki' 'pedia.org/wiki/List_of_tz_database_time_zones'), ) -DEFAULT_COMPONENTS = ( - 'discovery', 'frontend', 'conversation', 'history', 'logbook', 'sun') +DEFAULT_COMPONENTS = { + 'introduction': 'Show links to resources in log and frontend', + 'frontend': 'Enables the frontend', + 'discovery': 'Discover some devices automatically', + 'conversation': 'Allows you to issue voice commands from the frontend', + 'history': 'Enables support for tracking state changes over time.', + 'logbook': 'View all events in a logbook', + 'sun': 'Track the sun', +} def ensure_config_exists(config_dir, detect_location=True): @@ -78,7 +85,8 @@ def create_default_config(config_dir, detect_location=True): config_file.write("\n") - for component in DEFAULT_COMPONENTS: + for component, description in DEFAULT_COMPONENTS.items(): + config_file.write("# {}\n".format(description)) config_file.write("{}:\n\n".format(component)) return config_path diff --git a/homeassistant/loader.py b/homeassistant/loader.py index b0eb8d287db..7b755214252 100644 --- a/homeassistant/loader.py +++ b/homeassistant/loader.py @@ -166,9 +166,10 @@ def load_order_components(components): key=lambda order: 'group' in order): load_order.update(comp_load_order) - # Push recorder to first place in load order - if 'recorder' in load_order: - load_order.promote('recorder') + # Push some to first place in load order + for comp in ('recorder', 'introduction'): + if comp in load_order: + load_order.promote(comp) return load_order