Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
geversonsto committed May 4, 2018
2 parents 3848888 + d1460de commit 52b4d96
Show file tree
Hide file tree
Showing 203 changed files with 7,960 additions and 2,283 deletions.
16 changes: 14 additions & 2 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ omit =
homeassistant/components/envisalink.py
homeassistant/components/*/envisalink.py

homeassistant/components/fritzbox.py
homeassistant/components/*/fritzbox.py

homeassistant/components/eufy.py
homeassistant/components/*/eufy.py

homeassistant/components/gc100.py
homeassistant/components/*/gc100.py

Expand All @@ -106,6 +112,9 @@ omit =
homeassistant/components/hive.py
homeassistant/components/*/hive.py

homeassistant/components/homekit_controller/__init__.py
homeassistant/components/*/homekit_controller.py

homeassistant/components/homematic/__init__.py
homeassistant/components/*/homematic.py

Expand Down Expand Up @@ -190,8 +199,8 @@ omit =
homeassistant/components/pilight.py
homeassistant/components/*/pilight.py

homeassistant/components/qwikswitch.py
homeassistant/components/*/qwikswitch.py
homeassistant/components/switch/qwikswitch.py
homeassistant/components/light/qwikswitch.py

homeassistant/components/rachio.py
homeassistant/components/*/rachio.py
Expand Down Expand Up @@ -639,7 +648,9 @@ omit =
homeassistant/components/sensor/sensehat.py
homeassistant/components/sensor/serial_pm.py
homeassistant/components/sensor/serial.py
homeassistant/components/sensor/sht31.py
homeassistant/components/sensor/shodan.py
homeassistant/components/sensor/sigfox.py
homeassistant/components/sensor/simulated.py
homeassistant/components/sensor/skybeacon.py
homeassistant/components/sensor/sma.py
Expand Down Expand Up @@ -669,6 +680,7 @@ omit =
homeassistant/components/sensor/uber.py
homeassistant/components/sensor/upnp.py
homeassistant/components/sensor/ups.py
homeassistant/components/sensor/uscis.py
homeassistant/components/sensor/vasttrafik.py
homeassistant/components/sensor/viaggiatreno.py
homeassistant/components/sensor/waqi.py
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ script: travis_wait 30 tox --develop
services:
- docker
before_deploy:
- docker pull lokalise/lokalise-cli@sha256:79b3108211ed1fcc9f7b09a011bfc53c240fc2f3b7fa7f0c8390f593271b4cd7
- docker pull lokalise/lokalise-cli@sha256:2198814ebddfda56ee041a4b427521757dd57f75415ea9693696a64c550cef21
deploy:
skip_cleanup: true
provider: script
Expand Down
2 changes: 2 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ homeassistant/components/media_player/xiaomi_tv.py @fattdev
homeassistant/components/media_player/yamaha_musiccast.py @jalmeroth
homeassistant/components/plant.py @ChristianKuehnel
homeassistant/components/sensor/airvisual.py @bachya
homeassistant/components/sensor/filter.py @dgomes
homeassistant/components/sensor/gearbest.py @HerrHofrat
homeassistant/components/sensor/irish_rail_transport.py @ttroy50
homeassistant/components/sensor/miflora.py @danielhiversen @ChristianKuehnel
Expand All @@ -72,6 +73,7 @@ homeassistant/components/sensor/sma.py @kellerza
homeassistant/components/sensor/sql.py @dgomes
homeassistant/components/sensor/sytadin.py @gautric
homeassistant/components/sensor/tibber.py @danielhiversen
homeassistant/components/sensor/upnp.py @dgomes
homeassistant/components/sensor/waqi.py @andrey-git
homeassistant/components/switch/rainmachine.py @bachya
homeassistant/components/switch/tplink.py @rytilahti
Expand Down
9 changes: 7 additions & 2 deletions homeassistant/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ def get_arguments() -> argparse.Namespace:
default=None,
help='Log file to write to. If not set, CONFIG/home-assistant.log '
'is used')
parser.add_argument(
'--log-no-color',
action='store_true',
help="Disable color logs")
parser.add_argument(
'--runner',
action='store_true',
Expand Down Expand Up @@ -259,13 +263,14 @@ def setup_and_run_hass(config_dir: str,
hass = bootstrap.from_config_dict(
config, config_dir=config_dir, verbose=args.verbose,
skip_pip=args.skip_pip, log_rotate_days=args.log_rotate_days,
log_file=args.log_file)
log_file=args.log_file, log_no_color=args.log_no_color)
else:
config_file = ensure_config_file(config_dir)
print('Config directory:', config_dir)
hass = bootstrap.from_config_file(
config_file, verbose=args.verbose, skip_pip=args.skip_pip,
log_rotate_days=args.log_rotate_days, log_file=args.log_file)
log_rotate_days=args.log_rotate_days, log_file=args.log_file,
log_no_color=args.log_no_color)

if hass is None:
return None
Expand Down
76 changes: 47 additions & 29 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ def from_config_dict(config: Dict[str, Any],
verbose: bool = False,
skip_pip: bool = False,
log_rotate_days: Any = None,
log_file: Any = None) \
log_file: Any = None,
log_no_color: bool = False) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a configuration dictionary.
Expand All @@ -60,7 +61,7 @@ def from_config_dict(config: Dict[str, Any],
hass = hass.loop.run_until_complete(
async_from_config_dict(
config, hass, config_dir, enable_log, verbose, skip_pip,
log_rotate_days, log_file)
log_rotate_days, log_file, log_no_color)
)

return hass
Expand All @@ -74,7 +75,8 @@ def async_from_config_dict(config: Dict[str, Any],
verbose: bool = False,
skip_pip: bool = False,
log_rotate_days: Any = None,
log_file: Any = None) \
log_file: Any = None,
log_no_color: bool = False) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a configuration dictionary.
Expand All @@ -84,7 +86,8 @@ def async_from_config_dict(config: Dict[str, Any],
start = time()

if enable_log:
async_enable_logging(hass, verbose, log_rotate_days, log_file)
async_enable_logging(hass, verbose, log_rotate_days, log_file,
log_no_color)

core_config = config.get(core.DOMAIN, {})

Expand Down Expand Up @@ -164,7 +167,8 @@ def from_config_file(config_path: str,
verbose: bool = False,
skip_pip: bool = True,
log_rotate_days: Any = None,
log_file: Any = None):
log_file: Any = None,
log_no_color: bool = False):
"""Read the configuration file and try to start all the functionality.
Will add functionality to 'hass' parameter if given,
Expand All @@ -176,7 +180,8 @@ def from_config_file(config_path: str,
# run task
hass = hass.loop.run_until_complete(
async_from_config_file(
config_path, hass, verbose, skip_pip, log_rotate_days, log_file)
config_path, hass, verbose, skip_pip,
log_rotate_days, log_file, log_no_color)
)

return hass
Expand All @@ -188,7 +193,8 @@ def async_from_config_file(config_path: str,
verbose: bool = False,
skip_pip: bool = True,
log_rotate_days: Any = None,
log_file: Any = None):
log_file: Any = None,
log_no_color: bool = False):
"""Read the configuration file and try to start all the functionality.
Will add functionality to 'hass' parameter.
Expand All @@ -199,7 +205,8 @@ def async_from_config_file(config_path: str,
hass.config.config_dir = config_dir
yield from async_mount_local_lib_path(config_dir, hass.loop)

async_enable_logging(hass, verbose, log_rotate_days, log_file)
async_enable_logging(hass, verbose, log_rotate_days, log_file,
log_no_color)

try:
config_dict = yield from hass.async_add_job(
Expand All @@ -216,40 +223,51 @@ def async_from_config_file(config_path: str,


@core.callback
def async_enable_logging(hass: core.HomeAssistant, verbose: bool = False,
log_rotate_days=None, log_file=None) -> None:
def async_enable_logging(hass: core.HomeAssistant,
verbose: bool = False,
log_rotate_days=None,
log_file=None,
log_no_color: bool = False) -> None:
"""Set up the logging.
This method must be run in the event loop.
"""
logging.basicConfig(level=logging.INFO)
fmt = ("%(asctime)s %(levelname)s (%(threadName)s) "
"[%(name)s] %(message)s")
colorfmt = "%(log_color)s{}%(reset)s".format(fmt)
datefmt = '%Y-%m-%d %H:%M:%S'

if not log_no_color:
try:
from colorlog import ColoredFormatter
# basicConfig must be called after importing colorlog in order to
# ensure that the handlers it sets up wraps the correct streams.
logging.basicConfig(level=logging.INFO)

colorfmt = "%(log_color)s{}%(reset)s".format(fmt)
logging.getLogger().handlers[0].setFormatter(ColoredFormatter(
colorfmt,
datefmt=datefmt,
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red',
}
))
except ImportError:
pass

# If the above initialization failed for any reason, setup the default
# formatting. If the above succeeds, this wil result in a no-op.
logging.basicConfig(format=fmt, datefmt=datefmt, level=logging.INFO)

# Suppress overly verbose logs from libraries that aren't helpful
logging.getLogger('requests').setLevel(logging.WARNING)
logging.getLogger('urllib3').setLevel(logging.WARNING)
logging.getLogger('aiohttp.access').setLevel(logging.WARNING)

try:
from colorlog import ColoredFormatter
logging.getLogger().handlers[0].setFormatter(ColoredFormatter(
colorfmt,
datefmt=datefmt,
reset=True,
log_colors={
'DEBUG': 'cyan',
'INFO': 'green',
'WARNING': 'yellow',
'ERROR': 'red',
'CRITICAL': 'red',
}
))
except ImportError:
pass

# Log errors to a file if we have write access to file or config dir
if log_file is None:
err_log_path = hass.config.path(ERROR_LOG_FILENAME)
Expand Down
11 changes: 7 additions & 4 deletions homeassistant/components/abode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@
from homeassistant.helpers import discovery
from homeassistant.helpers.entity import Entity

REQUIREMENTS = ['abodepy==0.12.3']
REQUIREMENTS = ['abodepy==0.13.1']

_LOGGER = logging.getLogger(__name__)

CONF_ATTRIBUTION = "Data provided by goabode.com"
CONF_POLLING = 'polling'

DOMAIN = 'abode'
DEFAULT_CACHEDB = './abodepy_cache.pickle'

NOTIFICATION_ID = 'abode_notification'
NOTIFICATION_TITLE = 'Abode Security Setup'
Expand Down Expand Up @@ -87,12 +88,13 @@
class AbodeSystem(object):
"""Abode System class."""

def __init__(self, username, password, name, polling, exclude, lights):
def __init__(self, username, password, cache,
name, polling, exclude, lights):
"""Initialize the system."""
import abodepy
self.abode = abodepy.Abode(
username, password, auto_login=True, get_devices=True,
get_automations=True)
get_automations=True, cache_path=cache)
self.name = name
self.polling = polling
self.exclude = exclude
Expand Down Expand Up @@ -129,8 +131,9 @@ def setup(hass, config):
lights = conf.get(CONF_LIGHTS)

try:
cache = hass.config.path(DEFAULT_CACHEDB)
hass.data[DOMAIN] = AbodeSystem(
username, password, name, polling, exclude, lights)
username, password, cache, name, polling, exclude, lights)
except (AbodeException, ConnectTimeout, HTTPError) as ex:
_LOGGER.error("Unable to connect to Abode: %s", str(ex))

Expand Down
1 change: 1 addition & 0 deletions homeassistant/components/alexa/smart_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@ async def async_api_adjust_target_temp(hass, config, request, entity):
async def async_api_set_thermostat_mode(hass, config, request, entity):
"""Process a set thermostat mode request."""
mode = request[API_PAYLOAD]['thermostatMode']
mode = mode if isinstance(mode, str) else mode['value']

operation_list = entity.attributes.get(climate.ATTR_OPERATION_LIST)
# Work around a pylint false positive due to
Expand Down
6 changes: 6 additions & 0 deletions homeassistant/components/binary_sensor/bmw_connected_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def __init__(self, account, vehicle, attribute: str, sensor_name,
self._vehicle = vehicle
self._attribute = attribute
self._name = '{} {}'.format(self._vehicle.name, self._attribute)
self._unique_id = '{}-{}'.format(self._vehicle.vin, self._attribute)
self._sensor_name = sensor_name
self._device_class = device_class
self._state = None
Expand All @@ -55,6 +56,11 @@ def should_poll(self) -> bool:
"""Data update is triggered from BMWConnectedDriveEntity."""
return False

@property
def unique_id(self):
"""Return the unique ID of the binary sensor."""
return self._unique_id

@property
def name(self):
"""Return the name of the binary sensor."""
Expand Down
8 changes: 8 additions & 0 deletions homeassistant/components/binary_sensor/hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(self, hivesession, hivedevice):
self.device_type = hivedevice["HA_DeviceType"]
self.node_device_type = hivedevice["Hive_DeviceType"]
self.session = hivesession
self.attributes = {}
self.data_updatesource = '{}.{}'.format(self.device_type,
self.node_id)

Expand All @@ -52,6 +53,11 @@ def name(self):
"""Return the name of the binary sensor."""
return self.node_name

@property
def device_state_attributes(self):
"""Show Device Attributes."""
return self.attributes

@property
def is_on(self):
"""Return true if the binary sensor is on."""
Expand All @@ -61,3 +67,5 @@ def is_on(self):
def update(self):
"""Update all Node data from Hive."""
self.session.core.update_data(self.node_id)
self.attributes = self.session.attributes.state_attributes(
self.node_id)
Loading

0 comments on commit 52b4d96

Please sign in to comment.