More pylint 2 fixes (#15516)

* Pylint 2 useless-import-alias fixes

* Pylint 2 chained-comparison fixes

* Pylint 2 consider-using-get fixes

* Pylint 2 len-as-condition fixes
This commit is contained in:
Ville Skyttä 2018-07-18 12:54:27 +03:00 committed by Paulus Schoutsen
parent 058081b1f5
commit bf17ed0917
104 changed files with 126 additions and 137 deletions

View file

@ -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,

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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 (

View file

@ -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

View file

@ -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

View file

@ -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']

View file

@ -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:

View file

@ -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'],

View file

@ -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

View file

@ -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

View file

@ -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__)

View file

@ -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']

View file

@ -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']

View file

@ -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,

View file

@ -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,

View file

@ -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 (

View file

@ -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__)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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 (

View file

@ -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:

View file

@ -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)

View file

@ -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)

View file

@ -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,

View file

@ -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)

View file

@ -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")

View file

@ -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 = []

View file

@ -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]

View file

@ -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,

View file

@ -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

View file

@ -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__)

View file

@ -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)

View file

@ -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))

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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

View file

@ -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)

View file

@ -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']

View file

@ -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__)

View file

@ -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)

View file

@ -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]

View file

@ -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']

View file

@ -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})

View file

@ -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']

View file

@ -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']

View file

@ -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']

View file

@ -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

View file

@ -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]

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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,

View file

@ -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']

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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__)

View file

@ -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']

View file

@ -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 (

View file

@ -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)])

View file

@ -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

View file

@ -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)

View file

@ -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 (

View file

@ -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

View file

@ -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

View file

@ -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__)

View file

@ -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)

View file

@ -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']

View file

@ -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 = {

View file

@ -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__)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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__)

View file

@ -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']

View file

@ -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

View file

@ -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

View file

@ -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__)

View file

@ -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']

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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,

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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']

View file

@ -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__)

View file

@ -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']

Some files were not shown because too many files have changed in this diff Show more