Check that no configuration is provided (#3553)

This commit is contained in:
Fabian Affolter 2016-09-30 04:02:22 +02:00 committed by Paulus Schoutsen
parent 68028afb98
commit a7266ae6cf
8 changed files with 103 additions and 60 deletions

View file

@ -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"]
DEPENDENCIES = ["api"]
_LOGGER = logging.getLogger(__name__)
DOMAIN = "zeroconf"
DEPENDENCIES = ['api']
DOMAIN = 'zeroconf'
ZEROCONF_TYPE = "_home-assistant._tcp.local."
REQUIREMENTS = ['zeroconf==0.17.6']
ZEROCONF_TYPE = '_home-assistant._tcp.local.'
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({}),
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
@ -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),