diff --git a/homeassistant/components/alarm_control_panel/demo.py b/homeassistant/components/alarm_control_panel/demo.py index c080a136c08..d2366e5836c 100644 --- a/homeassistant/components/alarm_control_panel/demo.py +++ b/homeassistant/components/alarm_control_panel/demo.py @@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation https://home-assistant.io/components/demo/ """ import datetime -import homeassistant.components.alarm_control_panel.manual as manual +from homeassistant.components.alarm_control_panel import manual from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_CUSTOM_BYPASS, STATE_ALARM_ARMED_HOME, STATE_ALARM_ARMED_NIGHT, diff --git a/homeassistant/components/alarm_control_panel/manual_mqtt.py b/homeassistant/components/alarm_control_panel/manual_mqtt.py index 895f5edd5da..e313f96fb7c 100644 --- a/homeassistant/components/alarm_control_panel/manual_mqtt.py +++ b/homeassistant/components/alarm_control_panel/manual_mqtt.py @@ -19,7 +19,7 @@ from homeassistant.const import ( STATE_ALARM_DISARMED, STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED, CONF_PLATFORM, CONF_NAME, CONF_CODE, CONF_DELAY_TIME, CONF_PENDING_TIME, CONF_TRIGGER_TIME, CONF_DISARM_AFTER_TRIGGER) -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.helpers.event import async_track_state_change from homeassistant.core import callback diff --git a/homeassistant/components/alarm_control_panel/mqtt.py b/homeassistant/components/alarm_control_panel/mqtt.py index 9f2a4176ed8..d6198301d76 100644 --- a/homeassistant/components/alarm_control_panel/mqtt.py +++ b/homeassistant/components/alarm_control_panel/mqtt.py @@ -12,7 +12,7 @@ import voluptuous as vol from homeassistant.core import callback import homeassistant.components.alarm_control_panel as alarm -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.const import ( STATE_ALARM_ARMED_AWAY, STATE_ALARM_ARMED_HOME, STATE_ALARM_DISARMED, STATE_ALARM_PENDING, STATE_ALARM_TRIGGERED, STATE_UNKNOWN, diff --git a/homeassistant/components/automation/mqtt.py b/homeassistant/components/automation/mqtt.py index 172a368225d..60c33ca9b0e 100644 --- a/homeassistant/components/automation/mqtt.py +++ b/homeassistant/components/automation/mqtt.py @@ -10,7 +10,7 @@ import json import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.const import (CONF_PLATFORM, CONF_PAYLOAD) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/bbb_gpio.py b/homeassistant/components/bbb_gpio.py index f932f239969..e3f327f1d5c 100644 --- a/homeassistant/components/bbb_gpio.py +++ b/homeassistant/components/bbb_gpio.py @@ -19,7 +19,7 @@ DOMAIN = 'bbb_gpio' def setup(hass, config): """Set up the BeagleBone Black GPIO component.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO def cleanup_gpio(event): """Stuff to do before stopping.""" @@ -36,14 +36,14 @@ def setup(hass, config): def setup_output(pin): """Set up a GPIO as output.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO GPIO.setup(pin, GPIO.OUT) def setup_input(pin, pull_mode): """Set up a GPIO as input.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO GPIO.setup(pin, GPIO.IN, GPIO.PUD_DOWN if pull_mode == 'DOWN' else GPIO.PUD_UP) @@ -52,20 +52,20 @@ def setup_input(pin, pull_mode): def write_output(pin, value): """Write a value to a GPIO.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO GPIO.output(pin, value) def read_input(pin): """Read a value from a GPIO.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO return GPIO.input(pin) is GPIO.HIGH def edge_detect(pin, event_callback, bounce): """Add detection for RISING and FALLING events.""" # pylint: disable=import-error - import Adafruit_BBIO.GPIO as GPIO + from Adafruit_BBIO import GPIO GPIO.add_event_detect( pin, GPIO.BOTH, callback=event_callback, bouncetime=bounce) diff --git a/homeassistant/components/binary_sensor/bbb_gpio.py b/homeassistant/components/binary_sensor/bbb_gpio.py index 785b178969f..690d1651db9 100644 --- a/homeassistant/components/binary_sensor/bbb_gpio.py +++ b/homeassistant/components/binary_sensor/bbb_gpio.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.bbb_gpio as bbb_gpio +from homeassistant.components import bbb_gpio from homeassistant.components.binary_sensor import ( BinarySensorDevice, PLATFORM_SCHEMA) from homeassistant.const import (DEVICE_DEFAULT_NAME, CONF_NAME) diff --git a/homeassistant/components/binary_sensor/modbus.py b/homeassistant/components/binary_sensor/modbus.py index 00dc588a468..1a45235f15a 100644 --- a/homeassistant/components/binary_sensor/modbus.py +++ b/homeassistant/components/binary_sensor/modbus.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/binary_sensor.modbus/ import logging import voluptuous as vol -import homeassistant.components.modbus as modbus +from homeassistant.components import modbus from homeassistant.const import CONF_NAME, CONF_SLAVE from homeassistant.components.binary_sensor import BinarySensorDevice from homeassistant.helpers import config_validation as cv diff --git a/homeassistant/components/binary_sensor/mqtt.py b/homeassistant/components/binary_sensor/mqtt.py index d2533eb8f5b..cb943ac3f18 100644 --- a/homeassistant/components/binary_sensor/mqtt.py +++ b/homeassistant/components/binary_sensor/mqtt.py @@ -11,7 +11,7 @@ from typing import Optional import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.binary_sensor import ( BinarySensorDevice, DEVICE_CLASSES_SCHEMA) from homeassistant.const import ( diff --git a/homeassistant/components/binary_sensor/rpi_gpio.py b/homeassistant/components/binary_sensor/rpi_gpio.py index 4072f4ae234..31a518dc1dc 100644 --- a/homeassistant/components/binary_sensor/rpi_gpio.py +++ b/homeassistant/components/binary_sensor/rpi_gpio.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.rpi_gpio as rpi_gpio +from homeassistant.components import rpi_gpio from homeassistant.components.binary_sensor import ( BinarySensorDevice, PLATFORM_SCHEMA) from homeassistant.const import DEVICE_DEFAULT_NAME diff --git a/homeassistant/components/binary_sensor/rpi_pfio.py b/homeassistant/components/binary_sensor/rpi_pfio.py index 1abfa25c82b..a1126bdd2f9 100644 --- a/homeassistant/components/binary_sensor/rpi_pfio.py +++ b/homeassistant/components/binary_sensor/rpi_pfio.py @@ -10,7 +10,7 @@ import voluptuous as vol from homeassistant.components.binary_sensor import ( PLATFORM_SCHEMA, BinarySensorDevice) -import homeassistant.components.rpi_pfio as rpi_pfio +from homeassistant.components import rpi_pfio from homeassistant.const import CONF_NAME, DEVICE_DEFAULT_NAME import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/binary_sensor/wemo.py b/homeassistant/components/binary_sensor/wemo.py index e6eff0d9bb5..a589ab4e8c8 100644 --- a/homeassistant/components/binary_sensor/wemo.py +++ b/homeassistant/components/binary_sensor/wemo.py @@ -15,7 +15,7 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices_callback, discovery_info=None): """Register discovered WeMo binary sensors.""" - import pywemo.discovery as discovery + from pywemo import discovery if discovery_info is not None: location = discovery_info['ssdp_description'] diff --git a/homeassistant/components/calendar/__init__.py b/homeassistant/components/calendar/__init__.py index 35566b0cbed..9d105fb02d0 100644 --- a/homeassistant/components/calendar/__init__.py +++ b/homeassistant/components/calendar/__init__.py @@ -130,7 +130,7 @@ class CalendarEventDevice(Entity): now = dt.now() - if start <= now and end > now: + if start <= now < end: return STATE_ON if now >= end: diff --git a/homeassistant/components/calendar/todoist.py b/homeassistant/components/calendar/todoist.py index 71a6a17de10..42ab7b01c63 100644 --- a/homeassistant/components/calendar/todoist.py +++ b/homeassistant/components/calendar/todoist.py @@ -503,7 +503,7 @@ class TodoistProjectData(object): time_format = '%a %d %b %Y %H:%M:%S %z' for task in project_task_data: due_date = datetime.strptime(task['due_date_utc'], time_format) - if due_date > start_date and due_date < end_date: + if start_date < due_date < end_date: event = { 'uid': task['id'], 'title': task['content'], diff --git a/homeassistant/components/camera/mqtt.py b/homeassistant/components/camera/mqtt.py index b2a27230a02..dc991644b8e 100644 --- a/homeassistant/components/camera/mqtt.py +++ b/homeassistant/components/camera/mqtt.py @@ -11,7 +11,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.const import CONF_NAME from homeassistant.components.camera import Camera, PLATFORM_SCHEMA from homeassistant.helpers import config_validation as cv diff --git a/homeassistant/components/camera/nest.py b/homeassistant/components/camera/nest.py index ab26df5caf0..fcd9b7e8a07 100644 --- a/homeassistant/components/camera/nest.py +++ b/homeassistant/components/camera/nest.py @@ -9,7 +9,7 @@ from datetime import timedelta import requests -import homeassistant.components.nest as nest +from homeassistant.components import nest from homeassistant.components.camera import (PLATFORM_SCHEMA, Camera) from homeassistant.util.dt import utcnow diff --git a/homeassistant/components/camera/zoneminder.py b/homeassistant/components/camera/zoneminder.py index 90ef08c24fe..be59a1c1f50 100644 --- a/homeassistant/components/camera/zoneminder.py +++ b/homeassistant/components/camera/zoneminder.py @@ -12,7 +12,7 @@ from homeassistant.const import CONF_NAME from homeassistant.components.camera.mjpeg import ( CONF_MJPEG_URL, CONF_STILL_IMAGE_URL, MjpegCamera) -import homeassistant.components.zoneminder as zoneminder +from homeassistant.components import zoneminder _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/climate/flexit.py b/homeassistant/components/climate/flexit.py index 565e913319f..6c340e4a5f0 100644 --- a/homeassistant/components/climate/flexit.py +++ b/homeassistant/components/climate/flexit.py @@ -20,7 +20,7 @@ from homeassistant.const import ( from homeassistant.components.climate import ( ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE, SUPPORT_FAN_MODE) -import homeassistant.components.modbus as modbus +from homeassistant.components import modbus import homeassistant.helpers.config_validation as cv REQUIREMENTS = ['pyflexit==0.3'] diff --git a/homeassistant/components/climate/modbus.py b/homeassistant/components/climate/modbus.py index 7d392e5a40f..e567340efc9 100644 --- a/homeassistant/components/climate/modbus.py +++ b/homeassistant/components/climate/modbus.py @@ -18,7 +18,7 @@ from homeassistant.const import ( from homeassistant.components.climate import ( ClimateDevice, PLATFORM_SCHEMA, SUPPORT_TARGET_TEMPERATURE) -import homeassistant.components.modbus as modbus +from homeassistant.components import modbus import homeassistant.helpers.config_validation as cv DEPENDENCIES = ['modbus'] diff --git a/homeassistant/components/climate/mqtt.py b/homeassistant/components/climate/mqtt.py index fbe5460979b..1426ff31af9 100644 --- a/homeassistant/components/climate/mqtt.py +++ b/homeassistant/components/climate/mqtt.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.climate import ( STATE_HEAT, STATE_COOL, STATE_DRY, STATE_FAN_ONLY, ClimateDevice, diff --git a/homeassistant/components/cover/mqtt.py b/homeassistant/components/cover/mqtt.py index 62e1069e18b..e1775e2f968 100644 --- a/homeassistant/components/cover/mqtt.py +++ b/homeassistant/components/cover/mqtt.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.cover import ( CoverDevice, ATTR_TILT_POSITION, SUPPORT_OPEN_TILT, SUPPORT_CLOSE_TILT, SUPPORT_STOP_TILT, SUPPORT_SET_TILT_POSITION, diff --git a/homeassistant/components/cover/rfxtrx.py b/homeassistant/components/cover/rfxtrx.py index aefb7ab89d7..5079a3b60c2 100644 --- a/homeassistant/components/cover/rfxtrx.py +++ b/homeassistant/components/cover/rfxtrx.py @@ -6,7 +6,7 @@ https://home-assistant.io/components/cover.rfxtrx/ """ import voluptuous as vol -import homeassistant.components.rfxtrx as rfxtrx +from homeassistant.components import rfxtrx from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA from homeassistant.const import CONF_NAME from homeassistant.components.rfxtrx import ( diff --git a/homeassistant/components/cover/rpi_gpio.py b/homeassistant/components/cover/rpi_gpio.py index 384f96f3f52..2f6951cfc0d 100644 --- a/homeassistant/components/cover/rpi_gpio.py +++ b/homeassistant/components/cover/rpi_gpio.py @@ -14,7 +14,7 @@ import voluptuous as vol from homeassistant.components.cover import CoverDevice, PLATFORM_SCHEMA from homeassistant.const import CONF_NAME -import homeassistant.components.rpi_gpio as rpi_gpio +from homeassistant.components import rpi_gpio import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/cover/scsgate.py b/homeassistant/components/cover/scsgate.py index ac4fddf98bb..04bf0ef1d32 100644 --- a/homeassistant/components/cover/scsgate.py +++ b/homeassistant/components/cover/scsgate.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.scsgate as scsgate +from homeassistant.components import scsgate from homeassistant.components.cover import (CoverDevice, PLATFORM_SCHEMA) from homeassistant.const import (CONF_DEVICES, CONF_NAME) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/demo.py b/homeassistant/components/demo.py index 64ce3cda073..c2c7866148f 100644 --- a/homeassistant/components/demo.py +++ b/homeassistant/components/demo.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/demo/ import asyncio import time -import homeassistant.bootstrap as bootstrap +from homeassistant import bootstrap import homeassistant.core as ha from homeassistant.const import ATTR_ENTITY_ID, CONF_PLATFORM diff --git a/homeassistant/components/device_tracker/__init__.py b/homeassistant/components/device_tracker/__init__.py index 580c0272e46..b95a0a9d73b 100644 --- a/homeassistant/components/device_tracker/__init__.py +++ b/homeassistant/components/device_tracker/__init__.py @@ -24,7 +24,7 @@ from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.restore_state import async_get_last_state from homeassistant.helpers.typing import GPSType, ConfigType, HomeAssistantType import homeassistant.helpers.config_validation as cv -import homeassistant.util as util +from homeassistant import util from homeassistant.util.async_ import run_coroutine_threadsafe import homeassistant.util.dt as dt_util from homeassistant.util.yaml import dump diff --git a/homeassistant/components/device_tracker/mqtt.py b/homeassistant/components/device_tracker/mqtt.py index 2e2d9b10d98..b5031e8ccfb 100644 --- a/homeassistant/components/device_tracker/mqtt.py +++ b/homeassistant/components/device_tracker/mqtt.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.core import callback from homeassistant.const import CONF_DEVICES from homeassistant.components.mqtt import CONF_QOS diff --git a/homeassistant/components/device_tracker/mqtt_json.py b/homeassistant/components/device_tracker/mqtt_json.py index 9a5532fc9f4..7e5ae7c9227 100644 --- a/homeassistant/components/device_tracker/mqtt_json.py +++ b/homeassistant/components/device_tracker/mqtt_json.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.core import callback from homeassistant.components.mqtt import CONF_QOS from homeassistant.components.device_tracker import PLATFORM_SCHEMA diff --git a/homeassistant/components/device_tracker/owntracks.py b/homeassistant/components/device_tracker/owntracks.py index e99524c36db..2d7f1e80406 100644 --- a/homeassistant/components/device_tracker/owntracks.py +++ b/homeassistant/components/device_tracker/owntracks.py @@ -12,7 +12,7 @@ from collections import defaultdict import voluptuous as vol -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt import homeassistant.helpers.config_validation as cv from homeassistant.components import zone as zone_comp from homeassistant.components.device_tracker import ( diff --git a/homeassistant/components/emulated_hue/hue_api.py b/homeassistant/components/emulated_hue/hue_api.py index 2b74984e4ca..f7fbe2e15e3 100644 --- a/homeassistant/components/emulated_hue/hue_api.py +++ b/homeassistant/components/emulated_hue/hue_api.py @@ -237,11 +237,11 @@ class HueOneLightChangeView(HomeAssistantView): # Convert 0-100 to a fan speed if brightness == 0: data[ATTR_SPEED] = SPEED_OFF - elif brightness <= 33.3 and brightness > 0: + elif 0 < brightness <= 33.3: data[ATTR_SPEED] = SPEED_LOW - elif brightness <= 66.6 and brightness > 33.3: + elif 33.3 < brightness <= 66.6: data[ATTR_SPEED] = SPEED_MEDIUM - elif brightness <= 100 and brightness > 66.6: + elif 66.6 < brightness <= 100: data[ATTR_SPEED] = SPEED_HIGH if entity.domain in config.off_maps_to_on_domains: diff --git a/homeassistant/components/fan/insteon_local.py b/homeassistant/components/fan/insteon_local.py index b8a5c99add4..1a5e8124dfc 100644 --- a/homeassistant/components/fan/insteon_local.py +++ b/homeassistant/components/fan/insteon_local.py @@ -11,7 +11,7 @@ from homeassistant.components.fan import ( ATTR_SPEED, SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH, SUPPORT_SET_SPEED, FanEntity) from homeassistant.helpers.entity import ToggleEntity -import homeassistant.util as util +from homeassistant import util _CONFIGURING = {} _LOGGER = logging.getLogger(__name__) @@ -94,10 +94,7 @@ class InsteonLocalFanDevice(FanEntity): def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None: """Turn device on.""" if speed is None: - if ATTR_SPEED in kwargs: - speed = kwargs[ATTR_SPEED] - else: - speed = SPEED_MEDIUM + speed = kwargs.get(ATTR_SPEED, SPEED_MEDIUM) self.set_speed(speed) diff --git a/homeassistant/components/fan/mqtt.py b/homeassistant/components/fan/mqtt.py index 6fa506edec6..5faa735801d 100644 --- a/homeassistant/components/fan/mqtt.py +++ b/homeassistant/components/fan/mqtt.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.const import ( CONF_NAME, CONF_OPTIMISTIC, CONF_STATE, STATE_ON, STATE_OFF, CONF_PAYLOAD_OFF, CONF_PAYLOAD_ON) diff --git a/homeassistant/components/homekit/__init__.py b/homeassistant/components/homekit/__init__.py index 81f66880943..32d0956e878 100644 --- a/homeassistant/components/homekit/__init__.py +++ b/homeassistant/components/homekit/__init__.py @@ -9,7 +9,7 @@ from zlib import adler32 import voluptuous as vol -import homeassistant.components.cover as cover +from homeassistant.components import cover from homeassistant.const import ( ATTR_DEVICE_CLASS, ATTR_SUPPORTED_FEATURES, ATTR_UNIT_OF_MEASUREMENT, CONF_IP_ADDRESS, CONF_NAME, CONF_PORT, CONF_TYPE, DEVICE_CLASS_HUMIDITY, diff --git a/homeassistant/components/homekit/util.py b/homeassistant/components/homekit/util.py index 6a43a0c6228..c2f8951c8d8 100644 --- a/homeassistant/components/homekit/util.py +++ b/homeassistant/components/homekit/util.py @@ -3,7 +3,7 @@ import logging import voluptuous as vol -import homeassistant.components.media_player as media_player +from homeassistant.components import media_player from homeassistant.core import split_entity_id from homeassistant.const import ( ATTR_CODE, ATTR_SUPPORTED_FEATURES, CONF_NAME, CONF_TYPE, TEMP_CELSIUS) diff --git a/homeassistant/components/ifttt.py b/homeassistant/components/ifttt.py index 0a4ad66ce56..9497282ab21 100644 --- a/homeassistant/components/ifttt.py +++ b/homeassistant/components/ifttt.py @@ -63,7 +63,7 @@ def setup(hass, config): value3 = call.data.get(ATTR_VALUE3) try: - import pyfttt as pyfttt + import pyfttt pyfttt.send_event(key, event, value1, value2, value3) except requests.exceptions.RequestException: _LOGGER.exception("Error communicating with IFTTT") diff --git a/homeassistant/components/image_processing/microsoft_face_detect.py b/homeassistant/components/image_processing/microsoft_face_detect.py index bda0e1bc550..0b57dba8bca 100644 --- a/homeassistant/components/image_processing/microsoft_face_detect.py +++ b/homeassistant/components/image_processing/microsoft_face_detect.py @@ -103,7 +103,7 @@ class MicrosoftFaceDetectEntity(ImageProcessingFaceEntity): _LOGGER.error("Can't process image on microsoft face: %s", err) return - if face_data is None or len(face_data) < 1: + if not face_data: return faces = [] diff --git a/homeassistant/components/image_processing/microsoft_face_identify.py b/homeassistant/components/image_processing/microsoft_face_identify.py index 8984f25cdf2..9479a804a44 100644 --- a/homeassistant/components/image_processing/microsoft_face_identify.py +++ b/homeassistant/components/image_processing/microsoft_face_identify.py @@ -90,7 +90,7 @@ class MicrosoftFaceIdentifyEntity(ImageProcessingFaceEntity): face_data = yield from self._api.call_api( 'post', 'detect', image, binary=True) - if face_data is None or len(face_data) < 1: + if not face_data: return face_ids = [data['faceId'] for data in face_data] diff --git a/homeassistant/components/light/hue.py b/homeassistant/components/light/hue.py index 837a6f82510..0da59b6f100 100644 --- a/homeassistant/components/light/hue.py +++ b/homeassistant/components/light/hue.py @@ -11,7 +11,7 @@ import random import async_timeout -import homeassistant.components.hue as hue +from homeassistant.components import hue from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_TRANSITION, ATTR_HS_COLOR, EFFECT_COLORLOOP, EFFECT_RANDOM, diff --git a/homeassistant/components/light/hyperion.py b/homeassistant/components/light/hyperion.py index 8ba2329af7e..cbac8cf4e20 100644 --- a/homeassistant/components/light/hyperion.py +++ b/homeassistant/components/light/hyperion.py @@ -146,10 +146,7 @@ class Hyperion(Light): else: rgb_color = self._rgb_mem - if ATTR_BRIGHTNESS in kwargs: - brightness = kwargs[ATTR_BRIGHTNESS] - else: - brightness = self._brightness + brightness = kwargs.get(ATTR_BRIGHTNESS, self._brightness) if ATTR_EFFECT in kwargs: self._skip_update = True diff --git a/homeassistant/components/light/insteon_local.py b/homeassistant/components/light/insteon_local.py index bd7814df8f3..e2bc54de517 100644 --- a/homeassistant/components/light/insteon_local.py +++ b/homeassistant/components/light/insteon_local.py @@ -9,7 +9,7 @@ from datetime import timedelta from homeassistant.components.light import ( ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) -import homeassistant.util as util +from homeassistant import util _CONFIGURING = {} _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/light/litejet.py b/homeassistant/components/light/litejet.py index 2ebe766c8c5..b8491b6f0f5 100644 --- a/homeassistant/components/light/litejet.py +++ b/homeassistant/components/light/litejet.py @@ -6,7 +6,7 @@ https://home-assistant.io/components/light.litejet/ """ import logging -import homeassistant.components.litejet as litejet +from homeassistant.components import litejet from homeassistant.components.light import ( ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light) diff --git a/homeassistant/components/light/lutron_caseta.py b/homeassistant/components/light/lutron_caseta.py index 09f0a337cc3..29186b8fcd2 100644 --- a/homeassistant/components/light/lutron_caseta.py +++ b/homeassistant/components/light/lutron_caseta.py @@ -48,10 +48,7 @@ class LutronCasetaLight(LutronCasetaDevice, Light): @asyncio.coroutine def async_turn_on(self, **kwargs): """Turn the light on.""" - if ATTR_BRIGHTNESS in kwargs: - brightness = kwargs[ATTR_BRIGHTNESS] - else: - brightness = 255 + brightness = kwargs.get(ATTR_BRIGHTNESS, 255) self._smartbridge.set_value(self._device_id, to_lutron_level(brightness)) diff --git a/homeassistant/components/light/mqtt.py b/homeassistant/components/light/mqtt.py index c0e363f85d6..cfc1ce27b94 100644 --- a/homeassistant/components/light/mqtt.py +++ b/homeassistant/components/light/mqtt.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_HS_COLOR, ATTR_WHITE_VALUE, Light, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, diff --git a/homeassistant/components/light/mqtt_json.py b/homeassistant/components/light/mqtt_json.py index 705e106fdff..d17c7dd73bf 100644 --- a/homeassistant/components/light/mqtt_json.py +++ b/homeassistant/components/light/mqtt_json.py @@ -9,7 +9,7 @@ import json import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_TRANSITION, ATTR_WHITE_VALUE, ATTR_HS_COLOR, diff --git a/homeassistant/components/light/mqtt_template.py b/homeassistant/components/light/mqtt_template.py index f6b3fbe8b70..ffa73aca915 100644 --- a/homeassistant/components/light/mqtt_template.py +++ b/homeassistant/components/light/mqtt_template.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol from homeassistant.core import callback -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_EFFECT, ATTR_FLASH, ATTR_HS_COLOR, ATTR_TRANSITION, ATTR_WHITE_VALUE, Light, PLATFORM_SCHEMA, diff --git a/homeassistant/components/light/rfxtrx.py b/homeassistant/components/light/rfxtrx.py index cdfe2fe5671..293783ee3ab 100644 --- a/homeassistant/components/light/rfxtrx.py +++ b/homeassistant/components/light/rfxtrx.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.rfxtrx as rfxtrx +from homeassistant.components import rfxtrx from homeassistant.components.light import ( ATTR_BRIGHTNESS, SUPPORT_BRIGHTNESS, Light, PLATFORM_SCHEMA) from homeassistant.const import CONF_NAME diff --git a/homeassistant/components/light/scsgate.py b/homeassistant/components/light/scsgate.py index 214a2d99449..3d567afe09e 100644 --- a/homeassistant/components/light/scsgate.py +++ b/homeassistant/components/light/scsgate.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.scsgate as scsgate +from homeassistant.components import scsgate from homeassistant.components.light import (Light, PLATFORM_SCHEMA) from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_STATE, CONF_DEVICES, CONF_NAME) diff --git a/homeassistant/components/light/wemo.py b/homeassistant/components/light/wemo.py index 4cd34b698da..4c912d60fb7 100644 --- a/homeassistant/components/light/wemo.py +++ b/homeassistant/components/light/wemo.py @@ -8,7 +8,7 @@ import asyncio import logging from datetime import timedelta -import homeassistant.util as util +from homeassistant import util from homeassistant.components.light import ( Light, ATTR_BRIGHTNESS, ATTR_COLOR_TEMP, ATTR_HS_COLOR, ATTR_TRANSITION, SUPPORT_BRIGHTNESS, SUPPORT_COLOR_TEMP, SUPPORT_COLOR, SUPPORT_TRANSITION) @@ -27,7 +27,7 @@ SUPPORT_WEMO = (SUPPORT_BRIGHTNESS | SUPPORT_COLOR_TEMP | SUPPORT_COLOR | def setup_platform(hass, config, add_devices, discovery_info=None): """Set up discovered WeMo switches.""" - import pywemo.discovery as discovery + from pywemo import discovery if discovery_info is not None: location = discovery_info['ssdp_description'] diff --git a/homeassistant/components/lock/mqtt.py b/homeassistant/components/lock/mqtt.py index d8af22cd5c3..45029e679a5 100644 --- a/homeassistant/components/lock/mqtt.py +++ b/homeassistant/components/lock/mqtt.py @@ -17,7 +17,7 @@ from homeassistant.components.mqtt import ( MqttAvailability) from homeassistant.const import ( CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE) -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/mailbox/demo.py b/homeassistant/components/mailbox/demo.py index ccb371de2f8..8096a4fabb7 100644 --- a/homeassistant/components/mailbox/demo.py +++ b/homeassistant/components/mailbox/demo.py @@ -9,7 +9,7 @@ import logging import os from hashlib import sha1 -import homeassistant.util.dt as dt +from homeassistant.util import dt from homeassistant.components.mailbox import (Mailbox, CONTENT_TYPE_MPEG, StreamError) diff --git a/homeassistant/components/media_player/bluesound.py b/homeassistant/components/media_player/bluesound.py index ec878e5c043..c96889f4fe4 100644 --- a/homeassistant/components/media_player/bluesound.py +++ b/homeassistant/components/media_player/bluesound.py @@ -333,10 +333,10 @@ class BluesoundPlayer(MediaPlayerDevice): if response.status == 200: result = await response.text() - if len(result) < 1: - data = None - else: + if result: data = xmltodict.parse(result) + else: + data = None elif response.status == 595: _LOGGER.info("Status 595 returned, treating as timeout") raise BluesoundPlayer._TimeoutException() @@ -640,7 +640,7 @@ class BluesoundPlayer(MediaPlayerDevice): volume = self.volume_level if not volume: return None - return volume < 0.001 and volume >= 0 + return 0 <= volume < 0.001 @property def name(self): @@ -847,12 +847,12 @@ class BluesoundPlayer(MediaPlayerDevice): items = [x for x in self._preset_items if x['title'] == source] - if len(items) < 1: + if not items: items = [x for x in self._services_items if x['title'] == source] - if len(items) < 1: + if not items: items = [x for x in self._capture_items if x['title'] == source] - if len(items) < 1: + if not items: return selected_source = items[0] diff --git a/homeassistant/components/media_player/horizon.py b/homeassistant/components/media_player/horizon.py index 4b0f9d0cf21..9be4143ef2b 100644 --- a/homeassistant/components/media_player/horizon.py +++ b/homeassistant/components/media_player/horizon.py @@ -18,7 +18,7 @@ from homeassistant.const import (CONF_HOST, CONF_NAME, CONF_PORT, STATE_OFF, STATE_PAUSED, STATE_PLAYING) from homeassistant.exceptions import PlatformNotReady import homeassistant.helpers.config_validation as cv -import homeassistant.util as util +from homeassistant import util REQUIREMENTS = ['einder==0.3.1'] diff --git a/homeassistant/components/media_player/kodi.py b/homeassistant/components/media_player/kodi.py index 7fa8d5b3fe8..0585692e77d 100644 --- a/homeassistant/components/media_player/kodi.py +++ b/homeassistant/components/media_player/kodi.py @@ -759,7 +759,7 @@ class KodiDevice(MediaPlayerDevice): @asyncio.coroutine def async_set_shuffle(self, shuffle): """Set shuffle mode, for the first player.""" - if len(self._players) < 1: + if not self._players: raise RuntimeError("Error: No active player.") yield from self.server.Player.SetShuffle( {"playerid": self._players[0]['playerid'], "shuffle": shuffle}) diff --git a/homeassistant/components/media_player/lg_netcast.py b/homeassistant/components/media_player/lg_netcast.py index df1ee662124..955ba7ccb32 100644 --- a/homeassistant/components/media_player/lg_netcast.py +++ b/homeassistant/components/media_player/lg_netcast.py @@ -18,7 +18,7 @@ from homeassistant.components.media_player import ( from homeassistant.const import ( CONF_HOST, CONF_NAME, CONF_ACCESS_TOKEN, STATE_OFF, STATE_PLAYING, STATE_PAUSED, STATE_UNKNOWN) -import homeassistant.util as util +from homeassistant import util REQUIREMENTS = ['pylgnetcast-homeassistant==0.2.0.dev0'] diff --git a/homeassistant/components/media_player/vizio.py b/homeassistant/components/media_player/vizio.py index 81e4c3541d3..203a2c2b408 100644 --- a/homeassistant/components/media_player/vizio.py +++ b/homeassistant/components/media_player/vizio.py @@ -18,7 +18,7 @@ from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_HOST, CONF_NAME, STATE_OFF, STATE_ON, STATE_UNKNOWN) from homeassistant.helpers import config_validation as cv -import homeassistant.util as util +from homeassistant import util REQUIREMENTS = ['pyvizio==0.0.3'] diff --git a/homeassistant/components/media_player/webostv.py b/homeassistant/components/media_player/webostv.py index 42d0ae85ab3..362095daee6 100644 --- a/homeassistant/components/media_player/webostv.py +++ b/homeassistant/components/media_player/webostv.py @@ -24,7 +24,7 @@ from homeassistant.const import ( STATE_OFF, STATE_PAUSED, STATE_PLAYING, STATE_UNKNOWN) import homeassistant.helpers.config_validation as cv from homeassistant.helpers.script import Script -import homeassistant.util as util +from homeassistant import util REQUIREMENTS = ['pylgtv==0.1.7', 'websockets==3.2'] diff --git a/homeassistant/components/mqtt/discovery.py b/homeassistant/components/mqtt/discovery.py index 3916714b8d1..1cbe099ddde 100644 --- a/homeassistant/components/mqtt/discovery.py +++ b/homeassistant/components/mqtt/discovery.py @@ -8,7 +8,7 @@ import json import logging import re -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.helpers.discovery import async_load_platform from homeassistant.const import CONF_PLATFORM from homeassistant.components.mqtt import CONF_STATE_TOPIC diff --git a/homeassistant/components/mysensors/gateway.py b/homeassistant/components/mysensors/gateway.py index a7719a80d99..73222cb6be2 100644 --- a/homeassistant/components/mysensors/gateway.py +++ b/homeassistant/components/mysensors/gateway.py @@ -80,7 +80,7 @@ async def setup_gateways(hass, config): async def _get_gateway(hass, config, gateway_conf, persistence_file): """Return gateway after setup of the gateway.""" - import mysensors.mysensors as mysensors + from mysensors import mysensors conf = config[DOMAIN] persistence = conf[CONF_PERSISTENCE] diff --git a/homeassistant/components/remote/harmony.py b/homeassistant/components/remote/harmony.py index 842dce087e8..a63b7325035 100644 --- a/homeassistant/components/remote/harmony.py +++ b/homeassistant/components/remote/harmony.py @@ -10,7 +10,7 @@ import time import voluptuous as vol -import homeassistant.components.remote as remote +from homeassistant.components import remote from homeassistant.components.remote import ( ATTR_ACTIVITY, ATTR_DELAY_SECS, ATTR_DEVICE, ATTR_NUM_REPEATS, DEFAULT_DELAY_SECS, DOMAIN, PLATFORM_SCHEMA) diff --git a/homeassistant/components/remote/itach.py b/homeassistant/components/remote/itach.py index 78d277ca65f..829a038953c 100644 --- a/homeassistant/components/remote/itach.py +++ b/homeassistant/components/remote/itach.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol import homeassistant.helpers.config_validation as cv -import homeassistant.components.remote as remote +from homeassistant.components import remote from homeassistant.const import ( DEVICE_DEFAULT_NAME, CONF_NAME, CONF_MAC, CONF_HOST, CONF_PORT, CONF_DEVICES) diff --git a/homeassistant/components/remote/kira.py b/homeassistant/components/remote/kira.py index 42d4ce77054..dc37eb760f7 100644 --- a/homeassistant/components/remote/kira.py +++ b/homeassistant/components/remote/kira.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/remote.kira/ import functools as ft import logging -import homeassistant.components.remote as remote +from homeassistant.components import remote from homeassistant.const import CONF_DEVICE, CONF_NAME from homeassistant.helpers.entity import Entity diff --git a/homeassistant/components/rpi_gpio.py b/homeassistant/components/rpi_gpio.py index 5cb7bb337ce..824ec46d636 100644 --- a/homeassistant/components/rpi_gpio.py +++ b/homeassistant/components/rpi_gpio.py @@ -19,7 +19,7 @@ DOMAIN = 'rpi_gpio' def setup(hass, config): """Set up the Raspberry PI GPIO component.""" - import RPi.GPIO as GPIO + from RPi import GPIO def cleanup_gpio(event): """Stuff to do before stopping.""" @@ -36,32 +36,32 @@ def setup(hass, config): def setup_output(port): """Set up a GPIO as output.""" - import RPi.GPIO as GPIO + from RPi import GPIO GPIO.setup(port, GPIO.OUT) def setup_input(port, pull_mode): """Set up a GPIO as input.""" - import RPi.GPIO as GPIO + from RPi import GPIO GPIO.setup(port, GPIO.IN, GPIO.PUD_DOWN if pull_mode == 'DOWN' else GPIO.PUD_UP) def write_output(port, value): """Write a value to a GPIO.""" - import RPi.GPIO as GPIO + from RPi import GPIO GPIO.output(port, value) def read_input(port): """Read a value from a GPIO.""" - import RPi.GPIO as GPIO + from RPi import GPIO return GPIO.input(port) def edge_detect(port, event_callback, bounce): """Add detection for RISING and FALLING events.""" - import RPi.GPIO as GPIO + from RPi import GPIO GPIO.add_event_detect( port, GPIO.BOTH, diff --git a/homeassistant/components/scene/litejet.py b/homeassistant/components/scene/litejet.py index 37fb58d8dc7..87539e2dded 100644 --- a/homeassistant/components/scene/litejet.py +++ b/homeassistant/components/scene/litejet.py @@ -6,7 +6,7 @@ https://home-assistant.io/components/scene.litejet/ """ import logging -import homeassistant.components.litejet as litejet +from homeassistant.components import litejet from homeassistant.components.scene import Scene DEPENDENCIES = ['litejet'] diff --git a/homeassistant/components/sensor/arduino.py b/homeassistant/components/sensor/arduino.py index f49d8e76f6c..d4d8ea09d29 100644 --- a/homeassistant/components/sensor/arduino.py +++ b/homeassistant/components/sensor/arduino.py @@ -11,7 +11,7 @@ import logging import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -import homeassistant.components.arduino as arduino +from homeassistant.components import arduino from homeassistant.const import CONF_NAME from homeassistant.helpers.entity import Entity import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/sensor/arwn.py b/homeassistant/components/sensor/arwn.py index 7308cd4f791..6b0d3e569d7 100644 --- a/homeassistant/components/sensor/arwn.py +++ b/homeassistant/components/sensor/arwn.py @@ -8,7 +8,7 @@ import asyncio import json import logging -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.core import callback from homeassistant.const import TEMP_FAHRENHEIT, TEMP_CELSIUS from homeassistant.helpers.entity import Entity diff --git a/homeassistant/components/sensor/dht.py b/homeassistant/components/sensor/dht.py index b22e4df9a50..c5c26bc5ffa 100644 --- a/homeassistant/components/sensor/dht.py +++ b/homeassistant/components/sensor/dht.py @@ -128,7 +128,7 @@ class DHTSensor(Entity): temperature = data[SENSOR_TEMPERATURE] _LOGGER.debug("Temperature %.1f \u00b0C + offset %.1f", temperature, temperature_offset) - if (temperature >= -20) and (temperature < 80): + if -20 <= temperature < 80: self._state = round(temperature + temperature_offset, 1) if self.temp_unit == TEMP_FAHRENHEIT: self._state = round(celsius_to_fahrenheit(temperature), 1) @@ -136,7 +136,7 @@ class DHTSensor(Entity): humidity = data[SENSOR_HUMIDITY] _LOGGER.debug("Humidity %.1f%% + offset %.1f", humidity, humidity_offset) - if (humidity >= 0) and (humidity <= 100): + if 0 <= humidity <= 100: self._state = round(humidity + humidity_offset, 1) diff --git a/homeassistant/components/sensor/filter.py b/homeassistant/components/sensor/filter.py index 261f6e2b510..df913ab6d80 100644 --- a/homeassistant/components/sensor/filter.py +++ b/homeassistant/components/sensor/filter.py @@ -23,7 +23,7 @@ import homeassistant.helpers.config_validation as cv from homeassistant.util.decorator import Registry from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import async_track_state_change -import homeassistant.components.history as history +from homeassistant.components import history import homeassistant.util.dt as dt_util _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/google_travel_time.py b/homeassistant/components/sensor/google_travel_time.py index e7d25872701..d14a70ecc84 100644 --- a/homeassistant/components/sensor/google_travel_time.py +++ b/homeassistant/components/sensor/google_travel_time.py @@ -17,7 +17,7 @@ from homeassistant.const import ( ATTR_LONGITUDE, CONF_MODE) from homeassistant.util import Throttle import homeassistant.helpers.config_validation as cv -import homeassistant.helpers.location as location +from homeassistant.helpers import location import homeassistant.util.dt as dt_util REQUIREMENTS = ['googlemaps==2.5.1'] diff --git a/homeassistant/components/sensor/google_wifi.py b/homeassistant/components/sensor/google_wifi.py index c070a3e990f..388af9b3ce7 100644 --- a/homeassistant/components/sensor/google_wifi.py +++ b/homeassistant/components/sensor/google_wifi.py @@ -10,7 +10,7 @@ from datetime import timedelta import voluptuous as vol import requests -import homeassistant.util.dt as dt +from homeassistant.util import dt import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import ( diff --git a/homeassistant/components/sensor/gtfs.py b/homeassistant/components/sensor/gtfs.py index 93e15b9cd5e..120fe8fdb22 100644 --- a/homeassistant/components/sensor/gtfs.py +++ b/homeassistant/components/sensor/gtfs.py @@ -176,7 +176,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): gtfs = pygtfs.Schedule(joined_path) # pylint: disable=no-member - if len(gtfs.feeds) < 1: + if not gtfs.feeds: pygtfs.append_feed(gtfs, os.path.join(gtfs_dir, data)) add_devices([GTFSDepartureSensor(gtfs, name, origin, destination, offset)]) diff --git a/homeassistant/components/sensor/history_stats.py b/homeassistant/components/sensor/history_stats.py index 7af858b9d94..f1f12b6ecab 100644 --- a/homeassistant/components/sensor/history_stats.py +++ b/homeassistant/components/sensor/history_stats.py @@ -10,7 +10,7 @@ import math import voluptuous as vol -import homeassistant.components.history as history +from homeassistant.components import history import homeassistant.helpers.config_validation as cv import homeassistant.util.dt as dt_util from homeassistant.components.sensor import PLATFORM_SCHEMA diff --git a/homeassistant/components/sensor/modbus.py b/homeassistant/components/sensor/modbus.py index c4014fbd1dd..5f404ccd5f7 100644 --- a/homeassistant/components/sensor/modbus.py +++ b/homeassistant/components/sensor/modbus.py @@ -9,7 +9,7 @@ import struct import voluptuous as vol -import homeassistant.components.modbus as modbus +from homeassistant.components import modbus from homeassistant.const import ( CONF_NAME, CONF_OFFSET, CONF_UNIT_OF_MEASUREMENT, CONF_SLAVE, CONF_STRUCTURE) diff --git a/homeassistant/components/sensor/mold_indicator.py b/homeassistant/components/sensor/mold_indicator.py index 2822ce01dca..62d8af2ee8f 100644 --- a/homeassistant/components/sensor/mold_indicator.py +++ b/homeassistant/components/sensor/mold_indicator.py @@ -10,7 +10,7 @@ import math import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA -import homeassistant.util as util +from homeassistant import util from homeassistant.helpers.entity import Entity from homeassistant.helpers.event import track_state_change from homeassistant.const import ( diff --git a/homeassistant/components/sensor/mqtt.py b/homeassistant/components/sensor/mqtt.py index 997fd312a6a..0e29c55d39d 100644 --- a/homeassistant/components/sensor/mqtt.py +++ b/homeassistant/components/sensor/mqtt.py @@ -20,7 +20,7 @@ from homeassistant.const import ( CONF_FORCE_UPDATE, CONF_NAME, CONF_VALUE_TEMPLATE, STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, CONF_ICON, CONF_DEVICE_CLASS) from homeassistant.helpers.entity import Entity -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt import homeassistant.helpers.config_validation as cv from homeassistant.helpers.typing import HomeAssistantType, ConfigType from homeassistant.helpers.event import async_track_point_in_utc_time diff --git a/homeassistant/components/sensor/mqtt_room.py b/homeassistant/components/sensor/mqtt_room.py index 2c0f8eb4d5a..2a61c1143ee 100644 --- a/homeassistant/components/sensor/mqtt_room.py +++ b/homeassistant/components/sensor/mqtt_room.py @@ -11,7 +11,7 @@ from datetime import timedelta import voluptuous as vol -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt import homeassistant.helpers.config_validation as cv from homeassistant.components.mqtt import CONF_STATE_TOPIC from homeassistant.components.sensor import PLATFORM_SCHEMA diff --git a/homeassistant/components/sensor/pilight.py b/homeassistant/components/sensor/pilight.py index 9784cc3dc4c..c30f1575049 100644 --- a/homeassistant/components/sensor/pilight.py +++ b/homeassistant/components/sensor/pilight.py @@ -12,7 +12,7 @@ from homeassistant.const import ( CONF_NAME, STATE_UNKNOWN, CONF_UNIT_OF_MEASUREMENT, CONF_PAYLOAD) from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.helpers.entity import Entity -import homeassistant.components.pilight as pilight +from homeassistant.components import pilight import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/rfxtrx.py b/homeassistant/components/sensor/rfxtrx.py index a5a6eb5f07b..b410e7e860a 100644 --- a/homeassistant/components/sensor/rfxtrx.py +++ b/homeassistant/components/sensor/rfxtrx.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.rfxtrx as rfxtrx +from homeassistant.components import rfxtrx from homeassistant.components.rfxtrx import ( ATTR_DATA_TYPE, ATTR_FIRE_EVENT, CONF_AUTOMATIC_ADD, CONF_DATA_TYPE, CONF_DEVICES, CONF_FIRE_EVENT, DATA_TYPES) diff --git a/homeassistant/components/sensor/season.py b/homeassistant/components/sensor/season.py index b04b7727e40..f06f6a896e7 100644 --- a/homeassistant/components/sensor/season.py +++ b/homeassistant/components/sensor/season.py @@ -12,7 +12,7 @@ import voluptuous as vol from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_TYPE from homeassistant.helpers.entity import Entity -import homeassistant.util as util +from homeassistant import util REQUIREMENTS = ['ephem==3.7.6.0'] diff --git a/homeassistant/components/sensor/tellstick.py b/homeassistant/components/sensor/tellstick.py index de929aa0942..2fc67e57162 100644 --- a/homeassistant/components/sensor/tellstick.py +++ b/homeassistant/components/sensor/tellstick.py @@ -39,7 +39,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({ def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the Tellstick sensors.""" - import tellcore.telldus as telldus + from tellcore import telldus import tellcore.constants as tellcore_constants sensor_value_descriptions = { diff --git a/homeassistant/components/sensor/thinkingcleaner.py b/homeassistant/components/sensor/thinkingcleaner.py index 83cf799e3cd..0b936d8c8c7 100644 --- a/homeassistant/components/sensor/thinkingcleaner.py +++ b/homeassistant/components/sensor/thinkingcleaner.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/sensor.thinkingcleaner/ import logging from datetime import timedelta -import homeassistant.util as util +from homeassistant import util from homeassistant.helpers.entity import Entity _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/sensor/toon.py b/homeassistant/components/sensor/toon.py index cecce0d270f..a8875f6904c 100644 --- a/homeassistant/components/sensor/toon.py +++ b/homeassistant/components/sensor/toon.py @@ -5,7 +5,7 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/sensor.toon/ """ import logging -import datetime as datetime +import datetime from homeassistant.helpers.entity import Entity import homeassistant.components.toon as toon_main diff --git a/homeassistant/components/sensor/waze_travel_time.py b/homeassistant/components/sensor/waze_travel_time.py index 79b14c94b88..70c169a1b7c 100644 --- a/homeassistant/components/sensor/waze_travel_time.py +++ b/homeassistant/components/sensor/waze_travel_time.py @@ -14,7 +14,7 @@ from homeassistant.const import ( ATTR_ATTRIBUTION, CONF_NAME, CONF_REGION, EVENT_HOMEASSISTANT_START, ATTR_LATITUDE, ATTR_LONGITUDE) import homeassistant.helpers.config_validation as cv -import homeassistant.helpers.location as location +from homeassistant.helpers import location from homeassistant.helpers.entity import Entity from homeassistant.util import Throttle diff --git a/homeassistant/components/sensor/zabbix.py b/homeassistant/components/sensor/zabbix.py index baeed391557..21a3030b79b 100644 --- a/homeassistant/components/sensor/zabbix.py +++ b/homeassistant/components/sensor/zabbix.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.zabbix as zabbix +from homeassistant.components import zabbix import homeassistant.helpers.config_validation as cv from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import CONF_NAME diff --git a/homeassistant/components/sensor/zoneminder.py b/homeassistant/components/sensor/zoneminder.py index 1189a53bb09..60b6a018fc2 100644 --- a/homeassistant/components/sensor/zoneminder.py +++ b/homeassistant/components/sensor/zoneminder.py @@ -12,7 +12,7 @@ from homeassistant.components.sensor import PLATFORM_SCHEMA from homeassistant.const import STATE_UNKNOWN from homeassistant.const import CONF_MONITORED_CONDITIONS from homeassistant.helpers.entity import Entity -import homeassistant.components.zoneminder as zoneminder +from homeassistant.components import zoneminder import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/snips.py b/homeassistant/components/snips.py index 4f50c6beaaa..34290819106 100644 --- a/homeassistant/components/snips.py +++ b/homeassistant/components/snips.py @@ -12,7 +12,7 @@ import voluptuous as vol from homeassistant.core import callback from homeassistant.helpers import intent, config_validation as cv -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt DOMAIN = 'snips' DEPENDENCIES = ['mqtt'] diff --git a/homeassistant/components/switch/arduino.py b/homeassistant/components/switch/arduino.py index 1547f4f1dee..2bcb04c566e 100644 --- a/homeassistant/components/switch/arduino.py +++ b/homeassistant/components/switch/arduino.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol -import homeassistant.components.arduino as arduino +from homeassistant.components import arduino from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import CONF_NAME import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/switch/bbb_gpio.py b/homeassistant/components/switch/bbb_gpio.py index 5412f559b73..94952ac736b 100644 --- a/homeassistant/components/switch/bbb_gpio.py +++ b/homeassistant/components/switch/bbb_gpio.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA -import homeassistant.components.bbb_gpio as bbb_gpio +from homeassistant.components import bbb_gpio from homeassistant.const import (DEVICE_DEFAULT_NAME, CONF_NAME) from homeassistant.helpers.entity import ToggleEntity import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/switch/insteon_local.py b/homeassistant/components/switch/insteon_local.py index 4456436ea61..c4c8a854670 100644 --- a/homeassistant/components/switch/insteon_local.py +++ b/homeassistant/components/switch/insteon_local.py @@ -8,7 +8,7 @@ import logging from datetime import timedelta from homeassistant.components.switch import SwitchDevice -import homeassistant.util as util +from homeassistant import util _CONFIGURING = {} _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/switch/litejet.py b/homeassistant/components/switch/litejet.py index 1e7c46733ad..79ef4a5fd7f 100644 --- a/homeassistant/components/switch/litejet.py +++ b/homeassistant/components/switch/litejet.py @@ -6,7 +6,7 @@ https://home-assistant.io/components/switch.litejet/ """ import logging -import homeassistant.components.litejet as litejet +from homeassistant.components import litejet from homeassistant.components.switch import SwitchDevice DEPENDENCIES = ['litejet'] diff --git a/homeassistant/components/switch/modbus.py b/homeassistant/components/switch/modbus.py index ca70c212774..94e1d7ea6d6 100644 --- a/homeassistant/components/switch/modbus.py +++ b/homeassistant/components/switch/modbus.py @@ -7,7 +7,7 @@ https://home-assistant.io/components/switch.modbus/ import logging import voluptuous as vol -import homeassistant.components.modbus as modbus +from homeassistant.components import modbus from homeassistant.const import ( CONF_NAME, CONF_SLAVE, CONF_COMMAND_ON, CONF_COMMAND_OFF) from homeassistant.helpers.entity import ToggleEntity diff --git a/homeassistant/components/switch/mqtt.py b/homeassistant/components/switch/mqtt.py index 1075888e199..4442b186e30 100644 --- a/homeassistant/components/switch/mqtt.py +++ b/homeassistant/components/switch/mqtt.py @@ -18,7 +18,7 @@ from homeassistant.components.switch import SwitchDevice from homeassistant.const import ( CONF_NAME, CONF_OPTIMISTIC, CONF_VALUE_TEMPLATE, CONF_PAYLOAD_OFF, CONF_PAYLOAD_ON, CONF_ICON, STATE_ON) -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt import homeassistant.helpers.config_validation as cv from homeassistant.helpers.restore_state import async_get_last_state diff --git a/homeassistant/components/switch/pilight.py b/homeassistant/components/switch/pilight.py index 57fa4b00c98..4e5f1c47e9f 100644 --- a/homeassistant/components/switch/pilight.py +++ b/homeassistant/components/switch/pilight.py @@ -10,7 +10,7 @@ import logging import voluptuous as vol import homeassistant.helpers.config_validation as cv -import homeassistant.components.pilight as pilight +from homeassistant.components import pilight from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import (CONF_NAME, CONF_ID, CONF_SWITCHES, CONF_STATE, CONF_PROTOCOL, STATE_ON) diff --git a/homeassistant/components/switch/pulseaudio_loopback.py b/homeassistant/components/switch/pulseaudio_loopback.py index e25368f3c5c..06f2ee5f550 100644 --- a/homeassistant/components/switch/pulseaudio_loopback.py +++ b/homeassistant/components/switch/pulseaudio_loopback.py @@ -11,7 +11,7 @@ from datetime import timedelta import voluptuous as vol -import homeassistant.util as util +from homeassistant import util from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import (CONF_NAME, CONF_HOST, CONF_PORT) import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/switch/rfxtrx.py b/homeassistant/components/switch/rfxtrx.py index 68e91612008..17b5c8e40d5 100644 --- a/homeassistant/components/switch/rfxtrx.py +++ b/homeassistant/components/switch/rfxtrx.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.rfxtrx as rfxtrx +from homeassistant.components import rfxtrx from homeassistant.components.switch import SwitchDevice, PLATFORM_SCHEMA from homeassistant.components.rfxtrx import ( CONF_AUTOMATIC_ADD, CONF_FIRE_EVENT, DEFAULT_SIGNAL_REPETITIONS, diff --git a/homeassistant/components/switch/rpi_gpio.py b/homeassistant/components/switch/rpi_gpio.py index 26de2a78e18..300af4be61d 100644 --- a/homeassistant/components/switch/rpi_gpio.py +++ b/homeassistant/components/switch/rpi_gpio.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol from homeassistant.components.switch import PLATFORM_SCHEMA -import homeassistant.components.rpi_gpio as rpi_gpio +from homeassistant.components import rpi_gpio from homeassistant.const import DEVICE_DEFAULT_NAME from homeassistant.helpers.entity import ToggleEntity import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/switch/rpi_pfio.py b/homeassistant/components/switch/rpi_pfio.py index 3031b1e0290..dad0c7c59ba 100644 --- a/homeassistant/components/switch/rpi_pfio.py +++ b/homeassistant/components/switch/rpi_pfio.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.rpi_pfio as rpi_pfio +from homeassistant.components import rpi_pfio from homeassistant.components.switch import PLATFORM_SCHEMA from homeassistant.const import ATTR_NAME, DEVICE_DEFAULT_NAME import homeassistant.helpers.config_validation as cv diff --git a/homeassistant/components/switch/scsgate.py b/homeassistant/components/switch/scsgate.py index 8b2734612de..adc08a65e71 100644 --- a/homeassistant/components/switch/scsgate.py +++ b/homeassistant/components/switch/scsgate.py @@ -8,7 +8,7 @@ import logging import voluptuous as vol -import homeassistant.components.scsgate as scsgate +from homeassistant.components import scsgate from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import ( ATTR_ENTITY_ID, ATTR_STATE, CONF_NAME, CONF_DEVICES) diff --git a/homeassistant/components/switch/thinkingcleaner.py b/homeassistant/components/switch/thinkingcleaner.py index 37c2f52e228..0753435cfba 100644 --- a/homeassistant/components/switch/thinkingcleaner.py +++ b/homeassistant/components/switch/thinkingcleaner.py @@ -8,8 +8,7 @@ import time import logging from datetime import timedelta -import homeassistant.util as util - +from homeassistant import util from homeassistant.const import (STATE_ON, STATE_OFF) from homeassistant.helpers.entity import ToggleEntity diff --git a/homeassistant/components/switch/wemo.py b/homeassistant/components/switch/wemo.py index c18ad492d40..c189c312b25 100644 --- a/homeassistant/components/switch/wemo.py +++ b/homeassistant/components/switch/wemo.py @@ -35,7 +35,7 @@ WEMO_STANDBY = 8 def setup_platform(hass, config, add_devices_callback, discovery_info=None): """Set up discovered WeMo switches.""" - import pywemo.discovery as discovery + from pywemo import discovery if discovery_info is not None: location = discovery_info['ssdp_description'] diff --git a/homeassistant/components/switch/zoneminder.py b/homeassistant/components/switch/zoneminder.py index adf3bf2d9bd..fa32843eb4b 100644 --- a/homeassistant/components/switch/zoneminder.py +++ b/homeassistant/components/switch/zoneminder.py @@ -10,7 +10,7 @@ import voluptuous as vol from homeassistant.components.switch import (SwitchDevice, PLATFORM_SCHEMA) from homeassistant.const import (CONF_COMMAND_ON, CONF_COMMAND_OFF) -import homeassistant.components.zoneminder as zoneminder +from homeassistant.components import zoneminder import homeassistant.helpers.config_validation as cv _LOGGER = logging.getLogger(__name__) diff --git a/homeassistant/components/thingspeak.py b/homeassistant/components/thingspeak.py index a21d44527a1..9a876a87683 100644 --- a/homeassistant/components/thingspeak.py +++ b/homeassistant/components/thingspeak.py @@ -11,9 +11,8 @@ import voluptuous as vol from homeassistant.const import ( CONF_API_KEY, CONF_ID, CONF_WHITELIST, STATE_UNAVAILABLE, STATE_UNKNOWN) -from homeassistant.helpers import state as state_helper +from homeassistant.helpers import event, state as state_helper import homeassistant.helpers.config_validation as cv -import homeassistant.helpers.event as event REQUIREMENTS = ['thingspeak==0.4.1'] diff --git a/homeassistant/components/vacuum/mqtt.py b/homeassistant/components/vacuum/mqtt.py index 8c2f110257f..fd80f4cdbfb 100644 --- a/homeassistant/components/vacuum/mqtt.py +++ b/homeassistant/components/vacuum/mqtt.py @@ -9,7 +9,7 @@ import logging import voluptuous as vol -import homeassistant.components.mqtt as mqtt +from homeassistant.components import mqtt from homeassistant.components.mqtt import MqttAvailability from homeassistant.components.vacuum import ( SUPPORT_BATTERY, SUPPORT_CLEAN_SPOT, SUPPORT_FAN_SPEED, diff --git a/homeassistant/core.py b/homeassistant/core.py index bfc3aed194f..dac16111de7 100644 --- a/homeassistant/core.py +++ b/homeassistant/core.py @@ -38,9 +38,9 @@ from homeassistant.exceptions import ( from homeassistant.util.async_ import ( run_coroutine_threadsafe, run_callback_threadsafe, fire_coroutine_threadsafe) -import homeassistant.util as util +from homeassistant import util import homeassistant.util.dt as dt_util -import homeassistant.util.location as location +from homeassistant.util import location from homeassistant.util.unit_system import UnitSystem, METRIC_SYSTEM # NOQA # Typing imports that create a circular dependency diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index 7ab90b7a048..e10d608fc62 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -123,7 +123,7 @@ async def async_get_all_descriptions(hass): def domain_yaml_file(domain): """Return the services.yaml location for a domain.""" if domain == ha.DOMAIN: - import homeassistant.components as components + from homeassistant import components component_path = path.dirname(components.__file__) else: component_path = path.dirname(get_component(hass, domain).__file__) diff --git a/homeassistant/scripts/check_config.py b/homeassistant/scripts/check_config.py index 69b1bf21c08..1924de88aaf 100644 --- a/homeassistant/scripts/check_config.py +++ b/homeassistant/scripts/check_config.py @@ -18,7 +18,7 @@ from homeassistant.config import ( CONF_PACKAGES, merge_packages_config, _format_config_error, find_config_file, load_yaml_config_file, extract_domain_configs, config_per_platform) -import homeassistant.util.yaml as yaml +from homeassistant.util import yaml from homeassistant.exceptions import HomeAssistantError REQUIREMENTS = ('colorlog==3.1.4',)