Skip to content

Commit

Permalink
Merge pull request #8685 from home-assistant/release-0-50
Browse files Browse the repository at this point in the history
0.50
  • Loading branch information
balloob authored Jul 29, 2017
2 parents cbf6522 + a760673 commit e13fd05
Show file tree
Hide file tree
Showing 207 changed files with 7,779 additions and 1,895 deletions.
9 changes: 8 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ omit =
homeassistant/components/twilio.py
homeassistant/components/notify/twilio_sms.py
homeassistant/components/notify/twilio_call.py

homeassistant/components/velbus.py
homeassistant/components/*/velbus.py

homeassistant/components/velux.py
homeassistant/components/*/velux.py
Expand All @@ -193,6 +196,9 @@ omit =
homeassistant/components/wink.py
homeassistant/components/*/wink.py

homeassistant/components/xiaomi.py
homeassistant/components/*/xiaomi.py

homeassistant/components/zabbix.py
homeassistant/components/*/zabbix.py

Expand All @@ -208,6 +214,7 @@ omit =

homeassistant/components/alarm_control_panel/alarmdotcom.py
homeassistant/components/alarm_control_panel/concord232.py
homeassistant/components/alarm_control_panel/manual_mqtt.py
homeassistant/components/alarm_control_panel/nx584.py
homeassistant/components/alarm_control_panel/simplisafe.py
homeassistant/components/alarm_control_panel/totalconnect.py
Expand Down Expand Up @@ -274,7 +281,6 @@ omit =
homeassistant/components/device_tracker/tplink.py
homeassistant/components/device_tracker/trackr.py
homeassistant/components/device_tracker/ubus.py
homeassistant/components/device_tracker/xiaomi.py
homeassistant/components/downloader.py
homeassistant/components/emoncms_history.py
homeassistant/components/emulated_hue/upnp.py
Expand Down Expand Up @@ -303,6 +309,7 @@ omit =
homeassistant/components/light/piglow.py
homeassistant/components/light/sensehat.py
homeassistant/components/light/tikteck.py
homeassistant/components/light/tplink.py
homeassistant/components/light/tradfri.py
homeassistant/components/light/x10.py
homeassistant/components/light/yeelight.py
Expand Down
6 changes: 4 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Home Assistant |Build Status| |Coverage Status| |Join the chat at https://gitter.im/home-assistant/home-assistant| |Join the dev chat at https://gitter.im/home-assistant/home-assistant/devs|
==============================================================================================================================================================================================
Home Assistant |Build Status| |Coverage Status| |Chat Status|
=============================================================

Home Assistant is a home automation platform running on Python 3. It is able to track and control all devices at home and offer a platform for automating control.

Expand Down Expand Up @@ -31,6 +31,8 @@ of a component, check the `Home Assistant help section <https://home-assistant.i
:target: https://travis-ci.org/home-assistant/home-assistant
.. |Coverage Status| image:: https://img.shields.io/coveralls/home-assistant/home-assistant.svg
:target: https://coveralls.io/r/home-assistant/home-assistant?branch=master
.. |Chat Status| image:: https://img.shields.io/discord/330944238910963714.svg
:target: https://discord.gg/c5DvZ4e
.. |Join the chat at https://gitter.im/home-assistant/home-assistant| image:: https://img.shields.io/badge/gitter-general-blue.svg
:target: https://gitter.im/home-assistant/home-assistant?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
.. |Join the dev chat at https://gitter.im/home-assistant/home-assistant/devs| image:: https://img.shields.io/badge/gitter-development-yellowgreen.svg
Expand Down
42 changes: 28 additions & 14 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from homeassistant.setup import async_setup_component
import homeassistant.loader as loader
from homeassistant.util.logging import AsyncHandler
from homeassistant.util.package import async_get_user_site, get_user_site
from homeassistant.util.yaml import clear_secret_cache
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.signal import async_register_signal_handling
Expand All @@ -39,7 +40,7 @@ def from_config_dict(config: Dict[str, Any],
skip_pip: bool=False,
log_rotate_days: Any=None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a config dict.
"""Try to configure Home Assistant from a configuration dictionary.
Dynamically loads required components and its dependencies.
"""
Expand All @@ -48,7 +49,8 @@ def from_config_dict(config: Dict[str, Any],
if config_dir is not None:
config_dir = os.path.abspath(config_dir)
hass.config.config_dir = config_dir
mount_local_lib_path(config_dir)
hass.loop.run_until_complete(
async_mount_local_lib_path(config_dir, hass.loop))

# run task
hass = hass.loop.run_until_complete(
Expand All @@ -69,7 +71,7 @@ def async_from_config_dict(config: Dict[str, Any],
skip_pip: bool=False,
log_rotate_days: Any=None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a config dict.
"""Try to configure Home Assistant from a configuration dictionary.
Dynamically loads required components and its dependencies.
This method is a coroutine.
Expand All @@ -90,8 +92,8 @@ def async_from_config_dict(config: Dict[str, Any],

hass.config.skip_pip = skip_pip
if skip_pip:
_LOGGER.warning('Skipping pip installation of required modules. '
'This may cause issues.')
_LOGGER.warning("Skipping pip installation of required modules. "
"This may cause issues")

if not loader.PREPARED:
yield from hass.async_add_job(loader.prepare, hass)
Expand All @@ -116,13 +118,13 @@ def async_from_config_dict(config: Dict[str, Any],
# pylint: disable=not-an-iterable
res = yield from core_components.async_setup(hass, config)
if not res:
_LOGGER.error('Home Assistant core failed to initialize. '
'Further initialization aborted.')
_LOGGER.error("Home Assistant core failed to initialize. "
"further initialization aborted")
return hass

yield from persistent_notification.async_setup(hass, config)

_LOGGER.info('Home Assistant core initialized')
_LOGGER.info("Home Assistant core initialized")

# stage 1
for component in components:
Expand All @@ -141,7 +143,7 @@ def async_from_config_dict(config: Dict[str, Any],
yield from hass.async_block_till_done()

stop = time()
_LOGGER.info('Home Assistant initialized in %.2fs', stop-start)
_LOGGER.info("Home Assistant initialized in %.2fs", stop-start)

async_register_signal_handling(hass)
return hass
Expand Down Expand Up @@ -183,15 +185,15 @@ def async_from_config_file(config_path: str,
# Set config dir to directory holding config file
config_dir = os.path.abspath(os.path.dirname(config_path))
hass.config.config_dir = config_dir
yield from hass.async_add_job(mount_local_lib_path, config_dir)
yield from async_mount_local_lib_path(config_dir, hass.loop)

async_enable_logging(hass, verbose, log_rotate_days)

try:
config_dict = yield from hass.async_add_job(
conf_util.load_yaml_config_file, config_path)
except HomeAssistantError as err:
_LOGGER.error('Error loading %s: %s', config_path, err)
_LOGGER.error("Error loading %s: %s", config_path, err)
return None
finally:
clear_secret_cache()
Expand Down Expand Up @@ -276,11 +278,23 @@ def async_stop_async_handler(event):


def mount_local_lib_path(config_dir: str) -> str:
"""Add local library to Python Path."""
deps_dir = os.path.join(config_dir, 'deps')
lib_dir = get_user_site(deps_dir)
if lib_dir not in sys.path:
sys.path.insert(0, lib_dir)
return deps_dir


@asyncio.coroutine
def async_mount_local_lib_path(config_dir: str,
loop: asyncio.AbstractEventLoop) -> str:
"""Add local library to Python Path.
Async friendly.
This function is a coroutine.
"""
deps_dir = os.path.join(config_dir, 'deps')
if deps_dir not in sys.path:
sys.path.insert(0, os.path.join(config_dir, 'deps'))
lib_dir = yield from async_get_user_site(deps_dir, loop=loop)
if lib_dir not in sys.path:
sys.path.insert(0, lib_dir)
return deps_dir
30 changes: 15 additions & 15 deletions homeassistant/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import homeassistant.config as conf_util
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.service import extract_entity_ids
from homeassistant.loader import get_component
from homeassistant.const import (
ATTR_ENTITY_ID, SERVICE_TURN_ON, SERVICE_TURN_OFF, SERVICE_TOGGLE,
SERVICE_HOMEASSISTANT_STOP, SERVICE_HOMEASSISTANT_RESTART,
Expand All @@ -33,25 +32,27 @@ def is_on(hass, entity_id=None):
If there is no entity id given we will check all.
"""
if entity_id:
group = get_component('group')

entity_ids = group.expand_entity_ids(hass, [entity_id])
entity_ids = hass.components.group.expand_entity_ids([entity_id])
else:
entity_ids = hass.states.entity_ids()

for ent_id in entity_ids:
domain = ha.split_entity_id(ent_id)[0]

module = get_component(domain)

try:
if module.is_on(hass, ent_id):
return True
component = getattr(hass.components, domain)

except ImportError:
_LOGGER.error('Failed to call %s.is_on: component not found',
domain)
continue

if not hasattr(component, 'is_on'):
_LOGGER.warning("Component %s has no is_on method.", domain)
continue

except AttributeError:
# module is None or method is_on does not exist
_LOGGER.exception("Failed to call %s.is_on for %s",
module, ent_id)
if component.is_on(ent_id):
return True

return False

Expand Down Expand Up @@ -161,10 +162,9 @@ def async_handle_core_service(call):
return

if errors:
notif = get_component('persistent_notification')
_LOGGER.error(errors)
notif.async_create(
hass, "Config error. See dev-info panel for details.",
hass.components.persistent_notification.async_create(
"Config error. See dev-info panel for details.",
"Config validating", "{0}.check_config".format(ha.DOMAIN))
return

Expand Down
5 changes: 5 additions & 0 deletions homeassistant/components/alarm_control_panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
ATTR_CODE, ATTR_CODE_FORMAT, ATTR_ENTITY_ID, SERVICE_ALARM_TRIGGER,
SERVICE_ALARM_DISARM, SERVICE_ALARM_ARM_HOME, SERVICE_ALARM_ARM_AWAY)
from homeassistant.config import load_yaml_config_file
from homeassistant.loader import bind_hass
from homeassistant.helpers.config_validation import PLATFORM_SCHEMA # noqa
import homeassistant.helpers.config_validation as cv
from homeassistant.helpers.entity import Entity
Expand Down Expand Up @@ -44,6 +45,7 @@
})


@bind_hass
def alarm_disarm(hass, code=None, entity_id=None):
"""Send the alarm the command for disarm."""
data = {}
Expand All @@ -55,6 +57,7 @@ def alarm_disarm(hass, code=None, entity_id=None):
hass.services.call(DOMAIN, SERVICE_ALARM_DISARM, data)


@bind_hass
def alarm_arm_home(hass, code=None, entity_id=None):
"""Send the alarm the command for arm home."""
data = {}
Expand All @@ -66,6 +69,7 @@ def alarm_arm_home(hass, code=None, entity_id=None):
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_HOME, data)


@bind_hass
def alarm_arm_away(hass, code=None, entity_id=None):
"""Send the alarm the command for arm away."""
data = {}
Expand All @@ -77,6 +81,7 @@ def alarm_arm_away(hass, code=None, entity_id=None):
hass.services.call(DOMAIN, SERVICE_ALARM_ARM_AWAY, data)


@bind_hass
def alarm_trigger(hass, code=None, entity_id=None):
"""Send the alarm the command for trigger."""
data = {}
Expand Down
Loading

0 comments on commit e13fd05

Please sign in to comment.