8000 Check that no configuration is provided by fabaff · Pull Request #3553 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Check that no configuration is provided #3553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions homeassistant/components/conversation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
vol.Required(ATTR_TEXT): vol.All(cv.string, vol.Lower),
})

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


def setup(hass, config):
"""Register the process service."""
Expand All @@ -48,8 +52,8 @@ def process(service):

name, command = match.groups()
entities = {state.entity_id: state.name for state in hass.states.all()}
entity_ids = fuzzyExtract.extractOne(name, entities,
score_cutoff=65)[2]
entity_ids = fuzzyExtract.extractOne(
name, entities, score_cutoff=65)[2]

if not entity_ids:
logger.error(
Expand All @@ -70,6 +74,7 @@ def process(service):
logger.error('Got unsupported command %s from text %s',
command, text)

hass.services.register(DOMAIN, SERVICE_PROCESS, process,
schema=SERVICE_PROCESS_SCHEMA)
hass.services.register(
DOMAIN, SERVICE_PROCESS, process, schema=SERVICE_PROCESS_SCHEMA)

return True
6 changes: 6 additions & 0 deletions homeassistant/components/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import logging
import threading

import voluptuous as vol

from homeassistant.const import EVENT_HOMEASSISTANT_START
from homeassistant.helpers.discovery import load_platform, discover

Expand All @@ -33,6 +35,10 @@
'directv': ('media_player', 'directv'),
}

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


def setup(hass, config):
"""Start a discovery service."""
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/introduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@
"""
import logging

import voluptuous as vol

DOMAIN = 'introduction'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


def setup(hass, config=None):
"""Setup the introduction component."""
Expand Down
34 changes: 23 additions & 11 deletions homeassistant/components/sun.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,38 @@
import logging
from datetime import timedelta

import homeassistant.util as util
import voluptuous as vol

from homeassistant.const import CONF_ELEVATION
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import (
track_point_in_utc_time, track_utc_time_change)
from homeassistant.util import dt as dt_util
from homeassistant.const import CONF_ELEVATION
import homeassistant.helpers.config_validation as cv
import homeassistant.util as util


REQUIREMENTS = ['astral==1.2']
DOMAIN = "sun"
ENTITY_ID = "sun.sun"

STATE_ABOVE_HORIZON = "above_horizon"
STATE_BELOW_HORIZON = "below_horizon"
_LOGGER = logging.getLogger(__name__)

STATE_ATTR_NEXT_RISING = "next_rising"
STATE_ATTR_NEXT_SETTING = "next_setting"
STATE_ATTR_ELEVATION = "elevation"
STATE_ATTR_AZIMUTH = "azimuth"
DOMAIN = 'sun'

_LOGGER = logging.getLogger(__name__)
ENTITY_ID = 'sun.sun'

STATE_ABOVE_HORIZON = 'above_horizon'
STATE_BELOW_HORIZON = 'below_horizon'

STATE_ATTR_AZIMUTH = 'azimuth'
STATE_ATTR_ELEVATION = 'elevation'
STATE_ATTR_NEXT_RISING = 'next_rising'
STATE_ATTR_NEXT_SETTING = 'next_setting'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Optional(CONF_ELEVATION): cv.positive_int,
}),
}, extra=vol.ALLOW_EXTRA)


def is_on(hass, entity_id=None):
Expand Down
29 changes: 18 additions & 11 deletions homeassistant/components/updater.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
"""
Support to check for available updates.

For more details about this platform, please refer to the documentation at
at https://home-assistant.io/components/updater/
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/updater/
"""
import logging

import requests
import voluptuous as vol

from homeassistant.const import __version__ as CURRENT_VERSION
from homeassistant.const import ATTR_FRIENDLY_NAME
from homeassistant.helpers import event

_LOGGER = logging.getLogger(__name__)
PYPI_URL = 'https://pypi.python.org/pypi/homeassistant/json'

DOMAIN = 'updater'

ENTITY_ID = 'updater.updater'

PYPI_URL = 'https://pypi.python.org/pypi/homeassistant/json'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


def setup(hass, config):
"""Setup the updater component."""
if 'dev' in CURRENT_VERSION:
# This component only makes sense in release versions
_LOGGER.warning('Updater not supported in development version')
_LOGGER.warning("Updater not supported in development version")
return False

def check_newest_version(_=None):
Expand All @@ -31,10 +38,10 @@ def check_newest_version(_=None):

if newest != CURRENT_VERSION and newest is not None:
hass.states.set(
ENTITY_ID, newest, {ATTR_FRIENDLY_NAME: 'Update Available'})
ENTITY_ID, newest, {ATTR_FRIENDLY_NAME: 'Update available'})

event.track_time_change(hass, check_newest_version,
hour=[0, 12], minute=0, second=0)
event.track_time_change(
hass, check_newest_version, hour=[0, 12], minute=0, second=0)

check_newest_version()

Expand All @@ -48,11 +55,11 @@ def get_newest_version():

return req.json()['info']['version']
except requests.RequestException:
_LOGGER.exception('Could not contact PyPI to check for updates')
_LOGGER.exception("Could not contact PyPI to check for updates")
return None
except ValueError:
_LOGGER.exception('Received invalid response from PyPI')
_LOGGER.exception("Received invalid response from PyPI")
return None
except KeyError:
_LOGGER.exception('Response from PyPI did not include version')
_LOGGER.exception("Response from PyPI did not include version")
return None
22 changes: 12 additions & 10 deletions homeassistant/components/upnp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,41 @@
"""
import logging

from homeassistant.const import (EVENT_HOMEASSISTANT_STOP)
import voluptuous as vol

DEPENDENCIES = ["api"]
from homeassistant.const import (EVENT_HOMEASSISTANT_STOP)

_LOGGER = logging.getLogger(__name__)

DOMAIN = "upnp"
DEPENDENCIES = ['api']
DOMAIN = 'upnp'

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


# pylint: disable=import-error, no-member, broad-except
def setup(hass, config):
"""Register a port mapping for Home Assistant via UPnP."""
# pylint: disable=import-error
import miniupnpc

# pylint: disable=no-member
upnp = miniupnpc.UPnP()

upnp.discoverdelay = 200
upnp.discover()
try:
upnp.selectigd()
# pylint: disable=broad-except
except Exception:
_LOGGER.exception("Error when attempting to discover a UPnP IGD")
return False

upnp.addportmapping(hass.config.api.port, "TCP",
hass.config.api.host, hass.config.api.port,
"Home Assistant", "")
upnp.addportmapping(hass.config.api.port, 'TCP', hass.config.api.host,
hass.config.api.port, 'Home Assistant', '')

def deregister_port(event):
"""De-register the UPnP port mapping."""
upnp.deleteportmapping(hass.config.api.port, "TCP")
upnp.deleteportmapping(hass.config.api.port, 'TCP')

hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, deregister_port)

Expand Down
31 changes: 18 additions & 13 deletions homeassistant/components/zeroconf.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
"""
This module exposes Home Assistant via Zeroconf.

Zeroconf is also known as Bonjour, Avahi or Multicast DNS (mDNS).

For more details about Zeroconf, please refer to the documentation at
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/zeroconf/
"""
import logging
import socket

import voluptuous as vol

from homeassistant.const import (EVENT_HOMEASSISTANT_STOP, __version__)

REQUIREMENTS = ["zeroconf==0.17.6"]
_LOGGER = logging.getLogger(__name__)

DEPENDENCIES = ["api"]
DEPENDENCIES = ['api']
DOMAIN = 'zeroconf'

_LOGGER = logging.getLogger(__name__)
REQUIREMENTS = ['zeroconf==0.17.6']

DOMAIN = "zeroconf"
ZEROCONF_TYPE = '_home-assistant._tcp.local.'

ZEROCONF_TYPE = "_home-assistant._tcp.local."
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)


def setup(hass, config):
Expand All @@ -28,12 +31,14 @@ def setup(hass, config):

zeroconf = Zeroconf()

zeroconf_name = "{}.{}".format(hass.config.location_name,
ZEROCONF_TYPE)
zeroconf_name = '{}.{}'.format(hass.config.location_name, ZEROCONF_TYPE)

requires_api_password = (hass.config.api.api_password is not None)
params = {"version": __version__, "base_url": hass.config.api.base_url,
"requires_api_password": requires_api_password}
requires_api_password = hass.config.api.api_password is not None
params = {
'version': __version__,
'base_url': hass.config.api.base_url,
'requires_api_password': requires_api_password,
}

info = ServiceInfo(ZEROCONF_TYPE, zeroconf_name,
socket.inet_aton(hass.config.api.host),
Expand Down
18 changes: 9 additions & 9 deletions tests/components/test_updater.py
B03B
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ def test_new_version_shows_entity_on_start(self, mock_get_newest_version):
updater.CURRENT_VERSION = MOCK_CURRENT_VERSION

self.assertTrue(setup_component(self.hass, updater.DOMAIN, {
'updater': None
'updater': {}
}))

self.assertTrue(self.hass.states.is_state(updater.ENTITY_ID,
NEW_VERSION))
self.assertTrue(self.hass.states.is_state(
updater.ENTITY_ID, NEW_VERSION))

@patch('homeassistant.components.updater.get_newest_version')
def test_no_entity_on_same_version(self, mock_get_newest_version):
Expand All @@ -46,20 +46,20 @@ def test_no_entity_on_same_version(self, mock_get_newest_version):
updater.CURRENT_VERSION = MOCK_CURRENT_VERSION

self.assertTrue(setup_component(self.hass, updater.DOMAIN, {
'updater': None
'updater': {}
}))

self.assertIsNone(self.hass.states.get(updater.ENTITY_ID))

mock_get_newest_version.return_value = NEW_VERSION

fire_time_changed(self.hass,
dt_util.utcnow().replace(hour=0, minute=0, second=0))
fire_time_changed(
self.hass, dt_util.utcnow().replace(hour=0, minute=0, second=0))

self.hass.block_till_done()

self.assertTrue(self.hass.states.is_state(updater.ENTITY_ID,
NEW_VERSION))
self.assertTrue(self.hass.states.is_state(
updater.ENTITY_ID, NEW_VERSION))

@patch('homeassistant.components.updater.requests.get')
def test_errors_while_fetching_new_version(self, mock_get):
Expand All @@ -78,5 +78,5 @@ def test_updater_disabled_on_dev(self):
updater.CURRENT_VERSION = MOCK_CURRENT_VERSION + 'dev'

self.assertFalse(setup_component(self.hass, updater.DOMAIN, {
'updater': None
'updater': {}
}))
0