Upgrade pylint to 1.8.2 (#12274)

* Upgrade pylint to 1.8.1

* Fix no-else-return

* Fix bad-whitespace

* Fix too-many-nested-blocks

* Fix raising-format-tuple

See https://github.com/PyCQA/pylint/blob/master/doc/whatsnew/1.8.rst

* Fix len-as-condition

* Fix logging-not-lazy

Not sure about that TEMP_CELSIUS though, but internally it's probably just like if you concatenated any other (variable) string

* Fix stop-iteration-return

* Fix useless-super-delegation

* Fix trailing-comma-tuple

Both of these seem to simply be bugs:
 * Nest: The value of self._humidity never seems to be used anywhere
 * Dovado: The called API method seems to expect a "normal" number

* Fix redefined-argument-from-local

* Fix consider-using-enumerate

* Fix wrong-import-order

* Fix arguments-differ

* Fix missed no-else-return

* Fix no-member and related

* Fix signatures-differ

* Revert "Upgrade pylint to 1.8.1"

This reverts commit af78aa00f125a7d34add97b9d50c14db48412211.

* Fix arguments-differ

* except for device_tracker

* Cleanup

* Fix test using positional argument

* Fix line too long

I forgot to run flake8 - shame on me... 🙃

* Fix bad-option-value for 1.6.5

* Fix arguments-differ for device_tracker

* Upgrade pylint to 1.8.2

* 👕 Fix missed no-member
This commit is contained in:
Otto Winter 2018-02-11 18:20:28 +01:00 committed by Paulus Schoutsen
parent 64c5d26a84
commit 678f284015
196 changed files with 541 additions and 593 deletions

View file

@ -35,13 +35,13 @@ FIRST_INIT_COMPONENT = set((
def from_config_dict(config: Dict[str, Any],
hass: Optional[core.HomeAssistant]=None,
config_dir: Optional[str]=None,
enable_log: bool=True,
verbose: bool=False,
skip_pip: bool=False,
log_rotate_days: Any=None,
log_file: Any=None) \
hass: Optional[core.HomeAssistant] = None,
config_dir: Optional[str] = None,
enable_log: bool = True,
verbose: bool = False,
skip_pip: bool = False,
log_rotate_days: Any = None,
log_file: Any = None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a configuration dictionary.
@ -68,12 +68,12 @@ def from_config_dict(config: Dict[str, Any],
@asyncio.coroutine
def async_from_config_dict(config: Dict[str, Any],
hass: core.HomeAssistant,
config_dir: Optional[str]=None,
enable_log: bool=True,
verbose: bool=False,
skip_pip: bool=False,
log_rotate_days: Any=None,
log_file: Any=None) \
config_dir: Optional[str] = None,
enable_log: bool = True,
verbose: bool = False,
skip_pip: bool = False,
log_rotate_days: Any = None,
log_file: Any = None) \
-> Optional[core.HomeAssistant]:
"""Try to configure Home Assistant from a configuration dictionary.
@ -163,11 +163,11 @@ def async_from_config_dict(config: Dict[str, Any],
def from_config_file(config_path: str,
hass: Optional[core.HomeAssistant]=None,
verbose: bool=False,
skip_pip: bool=True,
log_rotate_days: Any=None,
log_file: Any=None):
hass: Optional[core.HomeAssistant] = None,
verbose: bool = False,
skip_pip: bool = True,
log_rotate_days: Any = None,
log_file: Any = None):
"""Read the configuration file and try to start all the functionality.
Will add functionality to 'hass' parameter if given,
@ -188,10 +188,10 @@ def from_config_file(config_path: str,
@asyncio.coroutine
def async_from_config_file(config_path: str,
hass: core.HomeAssistant,
verbose: bool=False,
skip_pip: bool=True,
log_rotate_days: Any=None,
log_file: Any=None):
verbose: bool = False,
skip_pip: bool = True,
log_rotate_days: Any = None,
log_file: Any = None):
"""Read the configuration file and try to start all the functionality.
Will add functionality to 'hass' parameter.
@ -219,7 +219,7 @@ def async_from_config_file(config_path: str,
@core.callback
def async_enable_logging(hass: core.HomeAssistant, verbose: bool=False,
def async_enable_logging(hass: core.HomeAssistant, verbose: bool = False,
log_rotate_days=None, log_file=None) -> None:
"""Set up the logging.

View file

@ -7,6 +7,7 @@ https://home-assistant.io/components/abode/
import asyncio
import logging
from functools import partial
from requests.exceptions import HTTPError, ConnectTimeout
import voluptuous as vol
@ -17,7 +18,6 @@ from homeassistant.const import (
from homeassistant.helpers import config_validation as cv
from homeassistant.helpers import discovery
from homeassistant.helpers.entity import Entity
from requests.exceptions import HTTPError, ConnectTimeout
REQUIREMENTS = ['abodepy==0.12.2']

View file

@ -59,8 +59,7 @@ class CanaryAlarm(AlarmControlPanel):
return STATE_ALARM_ARMED_HOME
elif mode.name == LOCATION_MODE_NIGHT:
return STATE_ALARM_ARMED_NIGHT
else:
return None
return None
@property
def device_state_attributes(self):

View file

@ -172,9 +172,8 @@ class ManualAlarm(alarm.AlarmControlPanel):
trigger_time) < dt_util.utcnow():
if self._disarm_after_trigger:
return STATE_ALARM_DISARMED
else:
self._state = self._previous_state
return self._state
self._state = self._previous_state
return self._state
if self._state in SUPPORTED_PENDING_STATES and \
self._within_pending_time(self._state):
@ -187,8 +186,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
"""Get the current state."""
if self.state == STATE_ALARM_PENDING:
return self._previous_state
else:
return self._state
return self._state
def _pending_time(self, state):
"""Get the pending time."""

View file

@ -208,9 +208,8 @@ class ManualMQTTAlarm(alarm.AlarmControlPanel):
trigger_time) < dt_util.utcnow():
if self._disarm_after_trigger:
return STATE_ALARM_DISARMED
else:
self._state = self._previous_state
return self._state
self._state = self._previous_state
return self._state
if self._state in SUPPORTED_PENDING_STATES and \
self._within_pending_time(self._state):
@ -223,8 +222,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanel):
"""Get the current state."""
if self.state == STATE_ALARM_PENDING:
return self._previous_state
else:
return self._state
return self._state
def _pending_time(self, state):
"""Get the pending time."""

View file

@ -50,7 +50,7 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
self._zone_type = zone_type
self._zone_number = zone_number
_LOGGER.debug('Setting up zone: ' + zone_name)
_LOGGER.debug('Setting up zone: %s', zone_name)
super().__init__(zone_name, info, controller)
@asyncio.coroutine

View file

@ -70,7 +70,7 @@ class IHCBinarySensor(IHCDevice, BinarySensorDevice):
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
sensor_type: str, inverting: bool,
product: Element=None) -> None:
product: Element = None) -> None:
"""Initialize the IHC binary sensor."""
super().__init__(ihc_controller, name, ihc_id, info, product)
self._state = None

View file

@ -498,7 +498,7 @@ class TodoistProjectData(object):
# Organize the best tasks (so users can see all the tasks
# they have, organized)
while len(project_tasks) > 0:
while project_tasks:
best_task = self.select_best_task(project_tasks)
_LOGGER.debug("Found Todoist Task: %s", best_task[SUMMARY])
project_tasks.remove(best_task)

View file

@ -119,6 +119,8 @@ class MjpegCamera(Camera):
else:
req = requests.get(self._mjpeg_url, stream=True, timeout=10)
# https://github.com/PyCQA/pylint/issues/1437
# pylint: disable=no-member
with closing(req) as response:
return extract_image_from_mjpeg(response.iter_content(102400))

View file

@ -188,7 +188,7 @@ class UnifiVideoCamera(Camera):
self._nvr.set_recordmode(self._uuid, set_mode)
self._motion_status = mode
except NvrError as err:
_LOGGER.error("Unable to set recordmode to " + set_mode)
_LOGGER.error("Unable to set recordmode to %s", set_mode)
_LOGGER.debug(err)
def enable_motion_detection(self):

View file

@ -42,7 +42,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
@asyncio.coroutine
# pylint: disable=unused-argument
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Discover and setup Xeoma Cameras."""
from pyxeoma.xeoma import Xeoma, XeomaError
@ -69,6 +68,8 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
]
for cam in config[CONF_CAMERAS]:
# https://github.com/PyCQA/pylint/issues/1830
# pylint: disable=stop-iteration-return
camera = next(
(dc for dc in discovered_cameras
if dc[CONF_IMAGE_NAME] == cam[CONF_IMAGE_NAME]), None)

View file

@ -669,16 +669,16 @@ class ClimateDevice(Entity):
"""
return self.hass.async_add_job(self.set_humidity, humidity)
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
raise NotImplementedError()
def async_set_fan_mode(self, fan):
def async_set_fan_mode(self, fan_mode):
"""Set new target fan mode.
This method must be run in the event loop and returns a coroutine.
"""
return self.hass.async_add_job(self.set_fan_mode, fan)
return self.hass.async_add_job(self.set_fan_mode, fan_mode)
def set_operation_mode(self, operation_mode):
"""Set new target operation mode."""

View file

@ -236,9 +236,9 @@ class DaikinClimate(ClimateDevice):
"""Return the fan setting."""
return self.get(ATTR_FAN_MODE)
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set fan mode."""
self.set({ATTR_FAN_MODE: fan})
self.set({ATTR_FAN_MODE: fan_mode})
@property
def fan_list(self):

View file

@ -195,9 +195,9 @@ class DemoClimate(ClimateDevice):
self._current_swing_mode = swing_mode
self.schedule_update_ha_state()
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new target temperature."""
self._current_fan_mode = fan
self._current_fan_mode = fan_mode
self.schedule_update_ha_state()
def set_operation_mode(self, operation_mode):
@ -225,9 +225,9 @@ class DemoClimate(ClimateDevice):
self._away = False
self.schedule_update_ha_state()
def set_hold_mode(self, hold):
"""Update hold mode on."""
self._hold = hold
def set_hold_mode(self, hold_mode):
"""Update hold_mode on."""
self._hold = hold_mode
self.schedule_update_ha_state()
def turn_aux_heat_on(self):

View file

@ -98,8 +98,7 @@ class EphEmberThermostat(ClimateDevice):
"""Return current operation ie. heat, cool, idle."""
if self._zone['isCurrentlyActive']:
return STATE_HEAT
else:
return STATE_IDLE
return STATE_IDLE
@property
def is_aux_heat_on(self):

View file

@ -53,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(devices)
# pylint: disable=import-error
# pylint: disable=import-error, no-name-in-module
class EQ3BTSmartThermostat(ClimateDevice):
"""Representation of an eQ-3 Bluetooth Smart thermostat."""

View file

@ -152,6 +152,6 @@ class Flexit(ClimateDevice):
self._target_temperature = kwargs.get(ATTR_TEMPERATURE)
self.unit.set_temp(self._target_temperature)
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new fan mode."""
self.unit.set_fan_speed(self._fan_list.index(fan))
self.unit.set_fan_speed(self._fan_list.index(fan_mode))

View file

@ -190,11 +190,9 @@ class GenericThermostat(ClimateDevice):
"""Return the current state."""
if self._is_device_active:
return self.current_operation
else:
if self._enabled:
return STATE_IDLE
else:
return STATE_OFF
if self._enabled:
return STATE_IDLE
return STATE_OFF
@property
def should_poll(self):

View file

@ -146,10 +146,10 @@ class MelissaClimate(ClimateDevice):
temp = kwargs.get(ATTR_TEMPERATURE)
self.send({self._api.TEMP: temp})
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set fan mode."""
fan_mode = self.hass_fan_to_melissa(fan)
self.send({self._api.FAN: fan_mode})
melissa_fan_mode = self.hass_fan_to_melissa(fan_mode)
self.send({self._api.FAN: melissa_fan_mode})
def set_operation_mode(self, operation_mode):
"""Set operation mode."""
@ -174,8 +174,7 @@ class MelissaClimate(ClimateDevice):
if not self._api.send(self._serial_number, self._cur_settings):
self._cur_settings = old_value
return False
else:
return True
return True
def update(self):
"""Get latest data from Melissa."""
@ -196,8 +195,7 @@ class MelissaClimate(ClimateDevice):
return STATE_OFF
elif state == self._api.STATE_IDLE:
return STATE_IDLE
else:
return None
return None
def melissa_op_to_hass(self, mode):
"""Translate Melissa modes to hass states."""
@ -211,10 +209,9 @@ class MelissaClimate(ClimateDevice):
return STATE_DRY
elif mode == self._api.MODE_FAN:
return STATE_FAN_ONLY
else:
_LOGGER.warning(
"Operation mode %s could not be mapped to hass", mode)
return None
_LOGGER.warning(
"Operation mode %s could not be mapped to hass", mode)
return None
def melissa_fan_to_hass(self, fan):
"""Translate Melissa fan modes to hass modes."""
@ -226,9 +223,8 @@ class MelissaClimate(ClimateDevice):
return SPEED_MEDIUM
elif fan == self._api.FAN_HIGH:
return SPEED_HIGH
else:
_LOGGER.warning("Fan mode %s could not be mapped to hass", fan)
return None
_LOGGER.warning("Fan mode %s could not be mapped to hass", fan)
return None
def hass_mode_to_melissa(self, mode):
"""Translate hass states to melissa modes."""

View file

@ -482,15 +482,15 @@ class MqttClimate(MqttAvailability, ClimateDevice):
self.async_schedule_update_ha_state()
@asyncio.coroutine
def async_set_fan_mode(self, fan):
def async_set_fan_mode(self, fan_mode):
"""Set new target temperature."""
if self._send_if_off or self._current_operation != STATE_OFF:
mqtt.async_publish(
self.hass, self._topic[CONF_FAN_MODE_COMMAND_TOPIC],
fan, self._qos, self._retain)
fan_mode, self._qos, self._retain)
if self._topic[CONF_FAN_MODE_STATE_TOPIC] is None:
self._current_fan_mode = fan
self._current_fan_mode = fan_mode
self.async_schedule_update_ha_state()
@asyncio.coroutine
@ -552,15 +552,15 @@ class MqttClimate(MqttAvailability, ClimateDevice):
self.async_schedule_update_ha_state()
@asyncio.coroutine
def async_set_hold_mode(self, hold):
def async_set_hold_mode(self, hold_mode):
"""Update hold mode on."""
if self._topic[CONF_HOLD_COMMAND_TOPIC] is not None:
mqtt.async_publish(self.hass,
self._topic[CONF_HOLD_COMMAND_TOPIC],
hold, self._qos, self._retain)
hold_mode, self._qos, self._retain)
if self._topic[CONF_HOLD_STATE_TOPIC] is None:
self._hold = hold
self._hold = hold_mode
self.async_schedule_update_ha_state()
@asyncio.coroutine

View file

@ -143,14 +143,14 @@ class MySensorsHVAC(mysensors.MySensorsEntity, ClimateDevice):
self._values[value_type] = value
self.schedule_update_ha_state()
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new target temperature."""
set_req = self.gateway.const.SetReq
self.gateway.set_child_value(
self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan)
self.node_id, self.child_id, set_req.V_HVAC_SPEED, fan_mode)
if self.gateway.optimistic:
# Optimistically assume that device has changed state
self._values[set_req.V_HVAC_SPEED] = fan
self._values[set_req.V_HVAC_SPEED] = fan_mode
self.schedule_update_ha_state()
def set_operation_mode(self, operation_mode):

View file

@ -207,9 +207,9 @@ class NestThermostat(ClimateDevice):
"""List of available fan modes."""
return self._fan_list
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Turn fan on/off."""
self.device.fan = fan.lower()
self.device.fan = fan_mode.lower()
@property
def min_temp(self):
@ -225,7 +225,7 @@ class NestThermostat(ClimateDevice):
"""Cache value from Python-nest."""
self._location = self.device.where
self._name = self.device.name
self._humidity = self.device.humidity,
self._humidity = self.device.humidity
self._temperature = self.device.temperature
self._mode = self.device.mode
self._target_temperature = self.device.target

View file

@ -185,7 +185,7 @@ class NuHeatThermostat(ClimateDevice):
self._thermostat.resume_schedule()
self._force_update = True
def set_hold_mode(self, hold_mode, **kwargs):
def set_hold_mode(self, hold_mode):
"""Update the hold mode of the thermostat."""
if hold_mode == MODE_AUTO:
schedule_mode = SCHEDULE_RUN

View file

@ -183,17 +183,16 @@ class RadioThermostat(ClimateDevice):
"""List of available fan modes."""
if self._is_model_ct80:
return CT80_FAN_OPERATION_LIST
else:
return CT30_FAN_OPERATION_LIST
return CT30_FAN_OPERATION_LIST
@property
def current_fan_mode(self):
"""Return whether the fan is on."""
return self._fmode
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Turn fan on/off."""
code = FAN_MODE_TO_CODE.get(fan, None)
code = FAN_MODE_TO_CODE.get(fan_mode, None)
if code is not None:
self.device.fmode = code

View file

@ -240,13 +240,13 @@ class SensiboClimate(ClimateDevice):
def min_temp(self):
"""Return the minimum temperature."""
return self._temperatures_list[0] \
if len(self._temperatures_list) else super().min_temp()
if self._temperatures_list else super().min_temp()
@property
def max_temp(self):
"""Return the maximum temperature."""
return self._temperatures_list[-1] \
if len(self._temperatures_list) else super().max_temp()
if self._temperatures_list else super().max_temp()
@asyncio.coroutine
def async_set_temperature(self, **kwargs):
@ -273,11 +273,11 @@ class SensiboClimate(ClimateDevice):
self._id, 'targetTemperature', temperature, self._ac_states)
@asyncio.coroutine
def async_set_fan_mode(self, fan):
def async_set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
with async_timeout.timeout(TIMEOUT):
yield from self._client.async_set_ac_state_property(
self._id, 'fanLevel', fan, self._ac_states)
self._id, 'fanLevel', fan_mode, self._ac_states)
@asyncio.coroutine
def async_set_operation_mode(self, operation_mode):

View file

@ -213,6 +213,7 @@ class TadoClimate(ClimateDevice):
self._target_temp = temperature
self._control_heating()
# pylint: disable=arguments-differ
def set_operation_mode(self, readable_operation_mode):
"""Set new operation mode."""
operation_mode = CONST_MODE_SMART_SCHEDULE

View file

@ -51,8 +51,7 @@ class TeslaThermostat(TeslaDevice, ClimateDevice):
mode = self.tesla_device.is_hvac_enabled()
if mode:
return OPERATION_LIST[0] # On
else:
return OPERATION_LIST[1] # Off
return OPERATION_LIST[1] # Off
@property
def operation_list(self):

View file

@ -111,8 +111,7 @@ class VenstarThermostat(ClimateDevice):
"""Return the unit of measurement, as defined by the API."""
if self._client.tempunits == self._client.TEMPUNITS_F:
return TEMP_FAHRENHEIT
else:
return TEMP_CELSIUS
return TEMP_CELSIUS
@property
def fan_list(self):
@ -143,16 +142,14 @@ class VenstarThermostat(ClimateDevice):
return STATE_COOL
elif self._client.mode == self._client.MODE_AUTO:
return STATE_AUTO
else:
return STATE_OFF
return STATE_OFF
@property
def current_fan_mode(self):
"""Return the fan setting."""
if self._client.fan == self._client.FAN_AUTO:
return STATE_AUTO
else:
return STATE_ON
return STATE_ON
@property
def device_state_attributes(self):
@ -169,24 +166,21 @@ class VenstarThermostat(ClimateDevice):
return self._client.heattemp
elif self._client.mode == self._client.MODE_COOL:
return self._client.cooltemp
else:
return None
return None
@property
def target_temperature_low(self):
"""Return the lower bound temp if auto mode is on."""
if self._client.mode == self._client.MODE_AUTO:
return self._client.heattemp
else:
return None
return None
@property
def target_temperature_high(self):
"""Return the upper bound temp if auto mode is on."""
if self._client.mode == self._client.MODE_AUTO:
return self._client.cooltemp
else:
return None
return None
@property
def target_humidity(self):
@ -245,9 +239,9 @@ class VenstarThermostat(ClimateDevice):
if not success:
_LOGGER.error("Failed to change the temperature")
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
if fan == STATE_ON:
if fan_mode == STATE_ON:
success = self._client.set_fan(self._client.FAN_ON)
else:
success = self._client.set_fan(self._client.FAN_AUTO)

View file

@ -85,13 +85,13 @@ class VeraThermostat(VeraDevice, ClimateDevice):
"""Return a list of available fan modes."""
return FAN_OPERATION_LIST
def set_fan_mode(self, mode):
def set_fan_mode(self, fan_mode):
"""Set new target temperature."""
if mode == FAN_OPERATION_LIST[0]:
if fan_mode == FAN_OPERATION_LIST[0]:
self.vera_device.fan_on()
elif mode == FAN_OPERATION_LIST[1]:
elif fan_mode == FAN_OPERATION_LIST[1]:
self.vera_device.fan_auto()
elif mode == FAN_OPERATION_LIST[2]:
elif fan_mode == FAN_OPERATION_LIST[2]:
return self.vera_device.fan_cycle()
@property

View file

@ -324,9 +324,9 @@ class WinkThermostat(WinkDevice, ClimateDevice):
return self.wink.fan_modes()
return None
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Turn fan on/off."""
self.wink.set_fan_mode(fan.lower())
self.wink.set_fan_mode(fan_mode.lower())
def turn_aux_heat_on(self):
"""Turn auxiliary heater on."""
@ -486,26 +486,25 @@ class WinkAC(WinkDevice, ClimateDevice):
return SPEED_LOW
elif speed <= 0.66:
return SPEED_MEDIUM
else:
return SPEED_HIGH
return SPEED_HIGH
@property
def fan_list(self):
"""Return a list of available fan modes."""
return [SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""
Set fan speed.
The official Wink app only supports 3 modes [low, medium, high]
which are equal to [0.33, 0.66, 1.0] respectively.
"""
if fan == SPEED_LOW:
if fan_mode == SPEED_LOW:
speed = 0.33
elif fan == SPEED_MEDIUM:
elif fan_mode == SPEED_MEDIUM:
speed = 0.66
elif fan == SPEED_HIGH:
elif fan_mode == SPEED_HIGH:
speed = 1.0
self.wink.set_ac_fan_speed(speed)

View file

@ -198,10 +198,10 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
self.values.primary.data = temperature
def set_fan_mode(self, fan):
def set_fan_mode(self, fan_mode):
"""Set new target fan mode."""
if self.values.fan_mode:
self.values.fan_mode.data = fan
self.values.fan_mode.data = fan_mode
def set_operation_mode(self, operation_mode):
"""Set new target operation mode."""

View file

@ -31,6 +31,8 @@ class InvalidCode(CloudError):
class PasswordChangeRequired(CloudError):
"""Raised when a password change is required."""
# https://github.com/PyCQA/pylint/issues/1085
# pylint: disable=useless-super-delegation
def __init__(self, message='Password change required.'):
"""Initialize a password change required error."""
super().__init__(message)

View file

@ -5,7 +5,8 @@ For more details about this platform, please refer to the documentation
https://home-assistant.io/components/demo/
"""
from homeassistant.components.cover import (
CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE)
CoverDevice, SUPPORT_OPEN, SUPPORT_CLOSE, ATTR_POSITION,
ATTR_TILT_POSITION)
from homeassistant.helpers.event import track_utc_time_change
@ -137,8 +138,9 @@ class DemoCover(CoverDevice):
self._listen_cover_tilt()
self._requested_closing_tilt = False
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
position = kwargs.get(ATTR_POSITION)
self._set_position = round(position, -1)
if self._position == position:
return
@ -146,8 +148,9 @@ class DemoCover(CoverDevice):
self._listen_cover()
self._requested_closing = position < self._position
def set_cover_tilt_position(self, tilt_position, **kwargs):
def set_cover_tilt_position(self, **kwargs):
"""Move the cover til to a specific position."""
tilt_position = kwargs.get(ATTR_TILT_POSITION)
self._set_tilt_position = round(tilt_position, -1)
if self._tilt_position == tilt_position:
return

View file

@ -201,21 +201,21 @@ class GaradgetCover(CoverDevice):
"""Check the state of the service during an operation."""
self.schedule_update_ha_state(True)
def close_cover(self):
def close_cover(self, **kwargs):
"""Close the cover."""
if self._state not in ['close', 'closing']:
ret = self._put_command('setState', 'close')
self._start_watcher('close')
return ret.get('return_value') == 1
def open_cover(self):
def open_cover(self, **kwargs):
"""Open the cover."""
if self._state not in ['open', 'opening']:
ret = self._put_command('setState', 'open')
self._start_watcher('open')
return ret.get('return_value') == 1
def stop_cover(self):
def stop_cover(self, **kwargs):
"""Stop the door where it is."""
if self._state not in ['stopped']:
ret = self._put_command('setState', 'stop')

View file

@ -42,10 +42,6 @@ def setup_platform(hass, config: ConfigType,
class ISYCoverDevice(ISYDevice, CoverDevice):
"""Representation of an ISY994 cover device."""
def __init__(self, node: object) -> None:
"""Initialize the ISY994 cover device."""
super().__init__(node)
@property
def current_cover_position(self) -> int:
"""Return the current cover position."""
@ -61,8 +57,7 @@ class ISYCoverDevice(ISYDevice, CoverDevice):
"""Get the state of the ISY994 cover device."""
if self.is_unknown():
return None
else:
return VALUE_TO_STATE.get(self.value, STATE_OPEN)
return VALUE_TO_STATE.get(self.value, STATE_OPEN)
def open_cover(self, **kwargs) -> None:
"""Send the open cover command to the ISY994 cover device."""

View file

@ -84,11 +84,11 @@ class MyQDevice(CoverDevice):
"""Return true if cover is closed, else False."""
return self._status == STATE_CLOSED
def close_cover(self):
def close_cover(self, **kwargs):
"""Issue close command to cover."""
self.myq.close_device(self.device_id)
def open_cover(self):
def open_cover(self, **kwargs):
"""Issue open command to cover."""
self.myq.open_device(self.device_id)

View file

@ -119,14 +119,14 @@ class OpenGarageCover(CoverDevice):
return None
return self._state in [STATE_CLOSED, STATE_OPENING]
def close_cover(self):
def close_cover(self, **kwargs):
"""Close the cover."""
if self._state not in [STATE_CLOSED, STATE_CLOSING]:
self._state_before_move = self._state
self._state = STATE_CLOSING
self._push_button()
def open_cover(self):
def open_cover(self, **kwargs):
"""Open the cover."""
if self._state not in [STATE_OPEN, STATE_OPENING]:
self._state_before_move = self._state

View file

@ -109,12 +109,12 @@ class RPiGPIOCover(CoverDevice):
sleep(self._relay_time)
rpi_gpio.write_output(self._relay_pin, not self._invert_relay)
def close_cover(self):
def close_cover(self, **kwargs):
"""Close the cover."""
if not self.is_closed:
self._trigger()
def open_cover(self):
def open_cover(self, **kwargs):
"""Open the cover."""
if self.is_closed:
self._trigger()

View file

@ -6,7 +6,7 @@ https://home-assistant.io/components/cover.tahoma/
"""
import logging
from homeassistant.components.cover import CoverDevice
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
from homeassistant.components.tahoma import (
DOMAIN as TAHOMA_DOMAIN, TahomaDevice)
@ -49,9 +49,9 @@ class TahomaCover(TahomaDevice, CoverDevice):
except KeyError:
return None
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
self.apply_action('setPosition', 100 - position)
self.apply_action('setPosition', 100 - kwargs.get(ATTR_POSITION))
@property
def is_closed(self):
@ -64,8 +64,7 @@ class TahomaCover(TahomaDevice, CoverDevice):
"""Return the class of the device."""
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
return 'window'
else:
return None
return None
def open_cover(self, **kwargs):
"""Open the cover."""

View file

@ -6,7 +6,8 @@ https://home-assistant.io/components/cover.vera/
"""
import logging
from homeassistant.components.cover import CoverDevice, ENTITY_ID_FORMAT
from homeassistant.components.cover import CoverDevice, ENTITY_ID_FORMAT, \
ATTR_POSITION
from homeassistant.components.vera import (
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
@ -44,9 +45,9 @@ class VeraCover(VeraDevice, CoverDevice):
return 100
return position
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
self.vera_device.set_level(position)
self.vera_device.set_level(kwargs.get(ATTR_POSITION))
self.schedule_update_ha_state()
@property

View file

@ -6,7 +6,8 @@ https://home-assistant.io/components/cover.wink/
"""
import asyncio
from homeassistant.components.cover import CoverDevice, STATE_UNKNOWN
from homeassistant.components.cover import CoverDevice, STATE_UNKNOWN, \
ATTR_POSITION
from homeassistant.components.wink import WinkDevice, DOMAIN
DEPENDENCIES = ['wink']
@ -42,17 +43,17 @@ class WinkCoverDevice(WinkDevice, CoverDevice):
"""Open the cover."""
self.wink.set_state(1)
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the cover shutter to a specific position."""
self.wink.set_state(float(position)/100)
position = kwargs.get(ATTR_POSITION)
self.wink.set_state(position/100)
@property
def current_cover_position(self):
"""Return the current position of cover shutter."""
if self.wink.state() is not None:
return int(self.wink.state()*100)
else:
return STATE_UNKNOWN
return STATE_UNKNOWN
@property
def is_closed(self):

View file

@ -1,7 +1,7 @@
"""Support for Xiaomi curtain."""
import logging
from homeassistant.components.cover import CoverDevice
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
from homeassistant.components.xiaomi_aqara import (PY_XIAOMI_GATEWAY,
XiaomiDevice)
@ -55,8 +55,9 @@ class XiaomiGenericCover(XiaomiDevice, CoverDevice):
"""Stop the cover."""
self._write_to_hub(self._sid, **{self._data_key['status']: 'stop'})
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the cover to a specific position."""
position = kwargs.get(ATTR_POSITION)
self._write_to_hub(self._sid, **{self._data_key['pos']: str(position)})
def parse_data(self, data, raw_data):

View file

@ -8,7 +8,7 @@ https://home-assistant.io/components/cover.zwave/
# pylint: disable=import-error
import logging
from homeassistant.components.cover import (
DOMAIN, SUPPORT_OPEN, SUPPORT_CLOSE)
DOMAIN, SUPPORT_OPEN, SUPPORT_CLOSE, ATTR_POSITION)
from homeassistant.components.zwave import ZWaveDeviceEntity
from homeassistant.components import zwave
from homeassistant.components.zwave import async_setup_platform # noqa # pylint: disable=unused-import
@ -97,9 +97,10 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
"""Move the roller shutter down."""
self._network.manager.pressButton(self._close_id)
def set_cover_position(self, position, **kwargs):
def set_cover_position(self, **kwargs):
"""Move the roller shutter to a specific position."""
self.node.set_dimmer(self.values.primary.value_id, position)
self.node.set_dimmer(self.values.primary.value_id,
kwargs.get(ATTR_POSITION))
def stop_cover(self, **kwargs):
"""Stop the roller shutter."""
@ -139,11 +140,11 @@ class ZwaveGarageDoorSwitch(ZwaveGarageDoorBase):
"""Return the current position of Zwave garage door."""
return not self._state
def close_cover(self):
def close_cover(self, **kwargs):
"""Close the garage door."""
self.values.primary.data = False
def open_cover(self):
def open_cover(self, **kwargs):
"""Open the garage door."""
self.values.primary.data = True
@ -166,10 +167,10 @@ class ZwaveGarageDoorBarrier(ZwaveGarageDoorBase):
"""Return the current position of Zwave garage door."""
return self._state == "Closed"
def close_cover(self):
def close_cover(self, **kwargs):
"""Close the garage door."""
self.values.primary.data = "Closed"
def open_cover(self):
def open_cover(self, **kwargs):
"""Open the garage door."""
self.values.primary.data = "Opened"

View file

@ -99,17 +99,17 @@ PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
@bind_hass
def is_on(hass: HomeAssistantType, entity_id: str=None):
def is_on(hass: HomeAssistantType, entity_id: str = None):
"""Return the state if any or a specified device is home."""
entity = entity_id or ENTITY_ID_ALL_DEVICES
return hass.states.is_state(entity, STATE_HOME)
def see(hass: HomeAssistantType, mac: str=None, dev_id: str=None,
host_name: str=None, location_name: str=None,
gps: GPSType=None, gps_accuracy=None,
battery=None, attributes: dict=None):
def see(hass: HomeAssistantType, mac: str = None, dev_id: str = None,
host_name: str = None, location_name: str = None,
gps: GPSType = None, gps_accuracy=None,
battery=None, attributes: dict = None):
"""Call service to notify you see device."""
data = {key: value for key, value in
((ATTR_MAC, mac),
@ -239,11 +239,11 @@ class DeviceTracker(object):
_LOGGER.warning('Duplicate device MAC addresses detected %s',
dev.mac)
def see(self, mac: str=None, dev_id: str=None, host_name: str=None,
location_name: str=None, gps: GPSType=None, gps_accuracy=None,
battery: str=None, attributes: dict=None,
source_type: str=SOURCE_TYPE_GPS, picture: str=None,
icon: str=None):
def see(self, mac: str = None, dev_id: str = None, host_name: str = None,
location_name: str = None, gps: GPSType = None, gps_accuracy=None,
battery: str = None, attributes: dict = None,
source_type: str = SOURCE_TYPE_GPS, picture: str = None,
icon: str = None):
"""Notify the device tracker that you see a device."""
self.hass.add_job(
self.async_see(mac, dev_id, host_name, location_name, gps,
@ -252,11 +252,11 @@ class DeviceTracker(object):
)
@asyncio.coroutine
def async_see(self, mac: str=None, dev_id: str=None, host_name: str=None,
location_name: str=None, gps: GPSType=None,
gps_accuracy=None, battery: str=None, attributes: dict=None,
source_type: str=SOURCE_TYPE_GPS, picture: str=None,
icon: str=None):
def async_see(self, mac: str = None, dev_id: str = None,
host_name: str = None, location_name: str = None,
gps: GPSType = None, gps_accuracy=None, battery: str = None,
attributes: dict = None, source_type: str = SOURCE_TYPE_GPS,
picture: str = None, icon: str = None):
"""Notify the device tracker that you see a device.
This method is a coroutine.
@ -396,9 +396,9 @@ class Device(Entity):
_state = STATE_NOT_HOME
def __init__(self, hass: HomeAssistantType, consider_home: timedelta,
track: bool, dev_id: str, mac: str, name: str=None,
picture: str=None, gravatar: str=None, icon: str=None,
hide_if_away: bool=False, vendor: str=None) -> None:
track: bool, dev_id: str, mac: str, name: str = None,
picture: str = None, gravatar: str = None, icon: str = None,
hide_if_away: bool = False, vendor: str = None) -> None:
"""Initialize a device."""
self.hass = hass
self.entity_id = ENTITY_ID_FORMAT.format(dev_id)
@ -475,9 +475,10 @@ class Device(Entity):
return self.away_hide and self.state != STATE_HOME
@asyncio.coroutine
def async_seen(self, host_name: str=None, location_name: str=None,
gps: GPSType=None, gps_accuracy=0, battery: str=None,
attributes: dict=None, source_type: str=SOURCE_TYPE_GPS):
def async_seen(self, host_name: str = None, location_name: str = None,
gps: GPSType = None, gps_accuracy=0, battery: str = None,
attributes: dict = None,
source_type: str = SOURCE_TYPE_GPS):
"""Mark the device as seen."""
self.source_type = source_type
self.last_seen = dt_util.utcnow()
@ -504,7 +505,7 @@ class Device(Entity):
# pylint: disable=not-an-iterable
yield from self.async_update()
def stale(self, now: dt_util.dt.datetime=None):
def stale(self, now: dt_util.dt.datetime = None):
"""Return if device state is stale.
Async friendly.
@ -621,16 +622,16 @@ class DeviceScanner(object):
"""
return self.hass.async_add_job(self.scan_devices)
def get_device_name(self, mac: str) -> str:
"""Get device name from mac."""
def get_device_name(self, device: str) -> str:
"""Get the name of a device."""
raise NotImplementedError()
def async_get_device_name(self, mac: str) -> Any:
"""Get device name from mac.
def async_get_device_name(self, device: str) -> Any:
"""Get the name of a device.
This method must be run in the event loop and returns a coroutine.
"""
return self.hass.async_add_job(self.get_device_name, mac)
return self.hass.async_add_job(self.get_device_name, device)
def load_config(path: str, hass: HomeAssistantType, consider_home: timedelta):

View file

@ -177,10 +177,9 @@ class AutomaticAuthCallbackView(HomeAssistantView):
_LOGGER.error(
"Error authorizing Automatic: %s", params['error'])
return response
else:
_LOGGER.error(
"Error authorizing Automatic. Invalid response returned")
return response
_LOGGER.error(
"Error authorizing Automatic. Invalid response returned")
return response
if DATA_CONFIGURING not in hass.data or \
params['state'] not in hass.data[DATA_CONFIGURING]:

View file

@ -45,10 +45,10 @@ class BboxDeviceScanner(DeviceScanner):
return [device.mac for device in self.last_results]
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [device.name for device in self.last_results if
device.mac == mac]
filter_named = [result.name for result in self.last_results if
result.mac == device]
if filter_named:
return filter_named[0]

View file

@ -102,7 +102,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
"""Lookup Bluetooth LE devices and update status."""
devs = discover_ble_devices()
for mac in devs_to_track:
_LOGGER.debug("Checking " + mac)
_LOGGER.debug("Checking %s", mac)
result = mac in devs
if not result:
# Could not lookup device name

View file

@ -41,7 +41,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
result = bluetooth.discover_devices(
duration=8, lookup_names=True, flush_cache=True,
lookup_class=False)
_LOGGER.debug("Bluetooth devices discovered = " + str(len(result)))
_LOGGER.debug("Bluetooth devices discovered = %d", len(result))
return result
yaml_path = hass.config.path(YAML_DEVICES)

View file

@ -75,9 +75,9 @@ class FritzBoxScanner(DeviceScanner):
active_hosts.append(known_host['mac'])
return active_hosts
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if is not known."""
ret = self.fritz_box.get_specific_host_entry(mac).get(
ret = self.fritz_box.get_specific_host_entry(device).get(
'NewHostName'
)
if ret == {}:

View file

@ -120,8 +120,7 @@ class GeofencyView(HomeAssistantView):
"""Return name of device tracker."""
if 'beaconUUID' in data:
return "{}_{}".format(BEACON_DEV_PREFIX, data['name'])
else:
return data['device']
return data['device']
@asyncio.coroutine
def _set_location(self, hass, data, location_name):

View file

@ -60,11 +60,11 @@ class HitronCODADeviceScanner(DeviceScanner):
return [device.mac for device in self.last_results]
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the device with the given MAC address."""
name = next((
device.name for device in self.last_results
if device.mac == mac), None)
result.name for result in self.last_results
if result.mac == device), None)
return name
def _login(self):

View file

@ -86,6 +86,7 @@ class HuaweiDeviceScanner(DeviceScanner):
active_clients = [client for client in data if client.state]
self.last_results = active_clients
# pylint: disable=logging-not-lazy
_LOGGER.debug("Active clients: " + "\n"
.join((client.mac + " " + client.name)
for client in active_clients))

View file

@ -67,10 +67,10 @@ class KeeneticNDMS2DeviceScanner(DeviceScanner):
return [device.mac for device in self.last_results]
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [device.name for device in self.last_results
if device.mac == mac]
filter_named = [result.name for result in self.last_results
if result.mac == device]
if filter_named:
return filter_named[0]

View file

@ -62,7 +62,7 @@ class LinksysAPDeviceScanner(DeviceScanner):
return self.last_results
# pylint: disable=no-self-use
def get_device_name(self, mac):
def get_device_name(self, device):
"""
Return the name (if known) of the device.

View file

@ -45,9 +45,9 @@ class LinksysSmartWifiDeviceScanner(DeviceScanner):
return self.last_results.keys()
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name (if known) of the device."""
return self.last_results.get(mac)
return self.last_results.get(device)
def _update_info(self):
"""Check for connected devices."""

View file

@ -85,7 +85,7 @@ class MerakiView(HomeAssistantView):
return self.json_message('Invalid device type',
HTTP_UNPROCESSABLE_ENTITY)
_LOGGER.debug("Processing %s", data['type'])
if len(data["data"]["observations"]) == 0:
if not data["data"]["observations"]:
_LOGGER.debug("No observations found")
return
self._handle(request.app['hass'], data)
@ -107,8 +107,7 @@ class MerakiView(HomeAssistantView):
if lat == "NaN" or lng == "NaN":
_LOGGER.debug(
"No coordinates received, skipping location for: " + mac
)
"No coordinates received, skipping location for: %s", mac)
gps_location = None
accuracy = None
else:

View file

@ -137,9 +137,9 @@ class MikrotikScanner(DeviceScanner):
self._update_info()
return [device for device in self.last_results]
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
return self.last_results.get(mac)
return self.last_results.get(device)
def _update_info(self):
"""Retrieve latest information from the Mikrotik box."""

View file

@ -70,11 +70,11 @@ class NetgearDeviceScanner(DeviceScanner):
return (device.mac for device in self.last_results)
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
try:
return next(device.name for device in self.last_results
if device.mac == mac)
return next(result.name for result in self.last_results
if result.mac == device)
except StopIteration:
return None

View file

@ -85,10 +85,10 @@ class NmapDeviceScanner(DeviceScanner):
return [device.mac for device in self.last_results]
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [device.name for device in self.last_results
if device.mac == mac]
filter_named = [result.name for result in self.last_results
if result.mac == device]
if filter_named:
return filter_named[0]

View file

@ -83,10 +83,10 @@ class TadoDeviceScanner(DeviceScanner):
return [device.mac for device in self.last_results]
@asyncio.coroutine
def async_get_device_name(self, mac):
def async_get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
filter_named = [device.name for device in self.last_results
if device.mac == mac]
filter_named = [result.name for result in self.last_results
if result.mac == device]
if filter_named:
return filter_named[0]

View file

@ -96,11 +96,11 @@ class UbusDeviceScanner(DeviceScanner):
raise NotImplementedError
@_refresh_on_access_denied
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name of the given device or None if we don't know."""
if self.mac2name is None:
self._generate_mac2name()
name = self.mac2name.get(mac.upper(), None)
name = self.mac2name.get(device.upper(), None)
return name
@_refresh_on_access_denied

View file

@ -101,13 +101,13 @@ class UnifiScanner(DeviceScanner):
self._update()
return self._clients.keys()
def get_device_name(self, mac):
def get_device_name(self, device):
"""Return the name (if known) of the device.
If a name has been set in Unifi, then return that, else
return the hostname if it has been detected.
"""
client = self._clients.get(mac, {})
client = self._clients.get(device, {})
name = client.get('name') or client.get('hostname')
_LOGGER.debug("Device mac %s name %s", mac, name)
_LOGGER.debug("Device mac %s name %s", device, name)
return name

View file

@ -140,21 +140,20 @@ class Dominos():
if self.closest_store is None:
_LOGGER.warning('Cannot get menu. Store may be closed')
return []
else:
menu = self.closest_store.get_menu()
product_entries = []
menu = self.closest_store.get_menu()
product_entries = []
for product in menu.products:
item = {}
if isinstance(product.menu_data['Variants'], list):
variants = ', '.join(product.menu_data['Variants'])
else:
variants = product.menu_data['Variants']
item['name'] = product.name
item['variants'] = variants
product_entries.append(item)
for product in menu.products:
item = {}
if isinstance(product.menu_data['Variants'], list):
variants = ', '.join(product.menu_data['Variants'])
else:
variants = product.menu_data['Variants']
item['name'] = product.name
item['variants'] = variants
product_entries.append(item)
return product_entries
return product_entries
class DominosProductListView(http.HomeAssistantView):
@ -203,8 +202,7 @@ class DominosOrder(Entity):
"""Return the state either closed, orderable or unorderable."""
if self.dominos.closest_store is None:
return 'closed'
else:
return 'orderable' if self._orderable else 'unorderable'
return 'orderable' if self._orderable else 'unorderable'
@Throttle(MIN_TIME_BETWEEN_UPDATES)
def update(self):

View file

@ -118,7 +118,7 @@ SERVICE_TO_METHOD = {
@bind_hass
def is_on(hass, entity_id: str=None) -> bool:
def is_on(hass, entity_id: str = None) -> bool:
"""Return if the fans are on based on the statemachine."""
entity_id = entity_id or ENTITY_ID_ALL_FANS
state = hass.states.get(entity_id)
@ -126,7 +126,7 @@ def is_on(hass, entity_id: str=None) -> bool:
@bind_hass
def turn_on(hass, entity_id: str=None, speed: str=None) -> None:
def turn_on(hass, entity_id: str = None, speed: str = None) -> None:
"""Turn all or specified fan on."""
data = {
key: value for key, value in [
@ -139,7 +139,7 @@ def turn_on(hass, entity_id: str=None, speed: str=None) -> None:
@bind_hass
def turn_off(hass, entity_id: str=None) -> None:
def turn_off(hass, entity_id: str = None) -> None:
"""Turn all or specified fan off."""
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
@ -147,7 +147,7 @@ def turn_off(hass, entity_id: str=None) -> None:
@bind_hass
def toggle(hass, entity_id: str=None) -> None:
def toggle(hass, entity_id: str = None) -> None:
"""Toggle all or specified fans."""
data = {
ATTR_ENTITY_ID: entity_id
@ -157,7 +157,8 @@ def toggle(hass, entity_id: str=None) -> None:
@bind_hass
def oscillate(hass, entity_id: str=None, should_oscillate: bool=True) -> None:
def oscillate(hass, entity_id: str = None,
should_oscillate: bool = True) -> None:
"""Set oscillation on all or specified fan."""
data = {
key: value for key, value in [
@ -170,7 +171,7 @@ def oscillate(hass, entity_id: str=None, should_oscillate: bool=True) -> None:
@bind_hass
def set_speed(hass, entity_id: str=None, speed: str=None) -> None:
def set_speed(hass, entity_id: str = None, speed: str = None) -> None:
"""Set speed for all or specified fan."""
data = {
key: value for key, value in [
@ -183,7 +184,7 @@ def set_speed(hass, entity_id: str=None, speed: str=None) -> None:
@bind_hass
def set_direction(hass, entity_id: str=None, direction: str=None) -> None:
def set_direction(hass, entity_id: str = None, direction: str = None) -> None:
"""Set direction for all or specified fan."""
data = {
key: value for key, value in [
@ -258,11 +259,13 @@ class FanEntity(ToggleEntity):
"""
return self.hass.async_add_job(self.set_direction, direction)
def turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
# pylint: disable=arguments-differ
def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
raise NotImplementedError()
def async_turn_on(self: ToggleEntity, speed: str=None, **kwargs):
# pylint: disable=arguments-differ
def async_turn_on(self: ToggleEntity, speed: str = None, **kwargs):
"""Turn on the fan.
This method must be run in the event loop and returns a coroutine.

View file

@ -87,7 +87,7 @@ class ComfoConnectFan(FanEntity):
"""List of available fan modes."""
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def turn_on(self, speed: str=None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
if speed is None:
speed = SPEED_LOW
@ -97,21 +97,21 @@ class ComfoConnectFan(FanEntity):
"""Turn off the fan (to away)."""
self.set_speed(SPEED_OFF)
def set_speed(self, mode):
def set_speed(self, speed: str):
"""Set fan speed."""
_LOGGER.debug('Changing fan mode to %s.', mode)
_LOGGER.debug('Changing fan speed to %s.', speed)
from pycomfoconnect import (
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
CMD_FAN_MODE_HIGH)
if mode == SPEED_OFF:
if speed == SPEED_OFF:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)
elif mode == SPEED_LOW:
elif speed == SPEED_LOW:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_LOW)
elif mode == SPEED_MEDIUM:
elif speed == SPEED_MEDIUM:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_MEDIUM)
elif mode == SPEED_HIGH:
elif speed == SPEED_HIGH:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_HIGH)
# Update current mode

View file

@ -59,13 +59,13 @@ class DemoFan(FanEntity):
"""Get the list of available speeds."""
return [STATE_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def turn_on(self, speed: str=None) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the entity."""
if speed is None:
speed = SPEED_MEDIUM
self.set_speed(speed)
def turn_off(self) -> None:
def turn_off(self, **kwargs) -> None:
"""Turn off the entity."""
self.oscillate(False)
self.set_speed(STATE_OFF)

View file

@ -113,7 +113,7 @@ class DysonPureCoolLinkDevice(FanEntity):
self._device.set_configuration(
fan_mode=FanMode.FAN, fan_speed=fan_speed)
def turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
from libpurecoollink.const import FanSpeed, FanMode

View file

@ -91,7 +91,7 @@ class InsteonLocalFanDevice(FanEntity):
"""Flag supported features."""
return SUPPORT_INSTEON_LOCAL
def turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
"""Turn device on."""
if speed is None:
if ATTR_SPEED in kwargs:

View file

@ -48,10 +48,6 @@ def setup_platform(hass, config: ConfigType,
class ISYFanDevice(ISYDevice, FanEntity):
"""Representation of an ISY994 fan device."""
def __init__(self, node) -> None:
"""Initialize the ISY994 fan device."""
super().__init__(node)
@property
def speed(self) -> str:
"""Return the current speed."""
@ -66,7 +62,7 @@ class ISYFanDevice(ISYDevice, FanEntity):
"""Send the set speed command to the ISY994 fan device."""
self._node.on(val=STATE_TO_VALUE.get(speed, 255))
def turn_on(self, speed: str=None, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Send the turn on command to the ISY994 fan device."""
self.set_speed(speed)
@ -99,7 +95,7 @@ class ISYFanProgram(ISYFanDevice):
if not self._actions.runThen():
_LOGGER.error("Unable to turn off the fan")
def turn_on(self, **kwargs) -> None:
def turn_on(self, speed: str = None, **kwargs) -> None:
"""Send the turn off command to ISY994 fan program."""
if not self._actions.runElse():
_LOGGER.error("Unable to turn on the fan")

View file

@ -252,7 +252,7 @@ class MqttFan(MqttAvailability, FanEntity):
return self._oscillation
@asyncio.coroutine
def async_turn_on(self, speed: str=None) -> None:
def async_turn_on(self, speed: str = None, **kwargs) -> None:
"""Turn on the entity.
This method is a coroutine.
@ -264,7 +264,7 @@ class MqttFan(MqttAvailability, FanEntity):
yield from self.async_set_speed(speed)
@asyncio.coroutine
def async_turn_off(self) -> None:
def async_turn_off(self, **kwargs) -> None:
"""Turn off the entity.
This method is a coroutine.

View file

@ -128,13 +128,13 @@ class VelbusFan(FanEntity):
"""Get the list of available speeds."""
return [STATE_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
def turn_on(self, speed, **kwargs):
def turn_on(self, speed=None, **kwargs):
"""Turn on the entity."""
if speed is None:
speed = SPEED_MEDIUM
self.set_speed(speed)
def turn_off(self):
def turn_off(self, **kwargs):
"""Turn off the entity."""
self.set_speed(STATE_OFF)

View file

@ -47,7 +47,7 @@ class WinkFanDevice(WinkDevice, FanEntity):
"""Set the speed of the fan."""
self.wink.set_state(True, speed)
def turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
def turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
"""Turn on the fan."""
self.wink.set_state(True, speed)

View file

@ -214,7 +214,7 @@ class XiaomiAirPurifier(FanEntity):
return False
@asyncio.coroutine
def async_turn_on(self: ToggleEntity, speed: str=None, **kwargs) -> None:
def async_turn_on(self: ToggleEntity, speed: str = None, **kwargs) -> None:
"""Turn the fan on."""
if speed:
# If operation mode was set the device must not be turned on.
@ -283,7 +283,7 @@ class XiaomiAirPurifier(FanEntity):
@asyncio.coroutine
def async_set_speed(self: ToggleEntity, speed: str) -> None:
"""Set the speed of the fan."""
_LOGGER.debug("Setting the operation mode to: " + speed)
_LOGGER.debug("Setting the operation mode to: %s", speed)
from miio.airpurifier import OperationMode
yield from self._try_command(
@ -333,7 +333,7 @@ class XiaomiAirPurifier(FanEntity):
self._air_purifier.set_child_lock, False)
@asyncio.coroutine
def async_set_led_brightness(self, brightness: int=2):
def async_set_led_brightness(self, brightness: int = 2):
"""Set the led brightness."""
from miio.airpurifier import LedBrightness
@ -342,7 +342,7 @@ class XiaomiAirPurifier(FanEntity):
self._air_purifier.set_led_brightness, LedBrightness(brightness))
@asyncio.coroutine
def async_set_favorite_level(self, level: int=1):
def async_set_favorite_level(self, level: int = 1):
"""Set the favorite level."""
yield from self._try_command(
"Setting the favorite level of the air purifier failed.",

View file

@ -103,7 +103,7 @@ def process_wrong_login(request):
class IpBan(object):
"""Represents banned IP address."""
def __init__(self, ip_ban: str, banned_at: datetime=None) -> None:
def __init__(self, ip_ban: str, banned_at: datetime = None) -> None:
"""Initialize IP Ban object."""
self.ip_address = ip_address(ip_ban)
self.banned_at = banned_at or datetime.utcnow()

View file

@ -14,7 +14,7 @@ class IHCDevice(Entity):
"""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
product: Element=None) -> None:
product: Element = None) -> None:
"""Initialize IHC attributes."""
self.ihc_controller = ihc_controller
self._name = name

View file

@ -135,7 +135,7 @@ WeatherNode = namedtuple('WeatherNode', ('status', 'name', 'uom'))
def _check_for_node_def(hass: HomeAssistant, node,
single_domain: str=None) -> bool:
single_domain: str = None) -> bool:
"""Check if the node matches the node_def_id for any domains.
This is only present on the 5.0 ISY firmware, and is the most reliable
@ -157,7 +157,7 @@ def _check_for_node_def(hass: HomeAssistant, node,
def _check_for_insteon_type(hass: HomeAssistant, node,
single_domain: str=None) -> bool:
single_domain: str = None) -> bool:
"""Check if the node matches the Insteon type for any domains.
This is for (presumably) every version of the ISY firmware, but only
@ -180,7 +180,8 @@ def _check_for_insteon_type(hass: HomeAssistant, node,
def _check_for_uom_id(hass: HomeAssistant, node,
single_domain: str=None, uom_list: list=None) -> bool:
single_domain: str = None,
uom_list: list = None) -> bool:
"""Check if a node's uom matches any of the domains uom filter.
This is used for versions of the ISY firmware that report uoms as a single
@ -207,8 +208,8 @@ def _check_for_uom_id(hass: HomeAssistant, node,
def _check_for_states_in_uom(hass: HomeAssistant, node,
single_domain: str=None,
states_list: list=None) -> bool:
single_domain: str = None,
states_list: list = None) -> bool:
"""Check if a list of uoms matches two possible filters.
This is for versions of the ISY firmware that report uoms as a list of all
@ -302,24 +303,25 @@ def _categorize_programs(hass: HomeAssistant, programs: dict) -> None:
pass
else:
for dtype, _, node_id in folder.children:
if dtype == KEY_FOLDER:
entity_folder = folder[node_id]
try:
status = entity_folder[KEY_STATUS]
assert status.dtype == 'program', 'Not a program'
if domain != 'binary_sensor':
actions = entity_folder[KEY_ACTIONS]
assert actions.dtype == 'program', 'Not a program'
else:
actions = None
except (AttributeError, KeyError, AssertionError):
_LOGGER.warning("Program entity '%s' not loaded due "
"to invalid folder structure.",
entity_folder.name)
continue
if dtype != KEY_FOLDER:
continue
entity_folder = folder[node_id]
try:
status = entity_folder[KEY_STATUS]
assert status.dtype == 'program', 'Not a program'
if domain != 'binary_sensor':
actions = entity_folder[KEY_ACTIONS]
assert actions.dtype == 'program', 'Not a program'
else:
actions = None
except (AttributeError, KeyError, AssertionError):
_LOGGER.warning("Program entity '%s' not loaded due "
"to invalid folder structure.",
entity_folder.name)
continue
entity = (entity_folder.name, status, actions)
hass.data[ISY994_PROGRAMS][domain].append(entity)
entity = (entity_folder.name, status, actions)
hass.data[ISY994_PROGRAMS][domain].append(entity)
def _categorize_weather(hass: HomeAssistant, climate) -> None:
@ -461,8 +463,7 @@ class ISYDevice(Entity):
"""Return the state of the ISY device."""
if self.is_unknown():
return None
else:
return super().state
return super().state
@property
def device_state_attributes(self) -> Dict:

View file

@ -37,7 +37,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up an Avion switch."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import avion
lights = []
@ -70,7 +70,7 @@ class AvionLight(Light):
def __init__(self, device):
"""Initialize the light."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import avion
self._name = device['name']
@ -117,7 +117,7 @@ class AvionLight(Light):
def set_state(self, brightness):
"""Set the state of this lamp to the provided brightness."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import avion
# Bluetooth LE is unreliable, and the connection may drop at any

View file

@ -29,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Blinkt Light platform."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import blinkt
# ensure that the lights are off when exiting

View file

@ -37,7 +37,7 @@ def retry(method):
@wraps(method)
def wrapper_retry(device, *args, **kwargs):
"""Try send command and retry on error."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import decora
import bluepy
@ -75,7 +75,7 @@ class DecoraLight(Light):
def __init__(self, device):
"""Initialize the light."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member
import decora
self._name = device['name']

View file

@ -36,7 +36,7 @@ NOTIFICATION_TITLE = 'myLeviton Decora Setup'
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the Decora WiFi platform."""
# pylint: disable=import-error
# pylint: disable=import-error, no-member, no-name-in-module
from decora_wifi import DecoraWiFiSession
from decora_wifi.models.person import Person
from decora_wifi.models.residential_account import ResidentialAccount
@ -93,8 +93,7 @@ class DecoraWifiLight(Light):
"""Return supported features."""
if self._switch.canSetLevel:
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
else:
return 0
return 0
@property
def name(self):

View file

@ -116,7 +116,7 @@ class HiveDeviceLight(Light):
for entity in self.session.entities:
entity.handle_update(self.data_updatesource)
def turn_off(self):
def turn_off(self, **kwargs):
"""Instruct the light to turn off."""
self.session.light.turn_off(self.node_id)
for entity in self.session.entities:

View file

@ -91,7 +91,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if discovery_info is None or 'bridge_id' not in discovery_info:
return
if config is not None and len(config) > 0:
if config is not None and config:
# Legacy configuration, will be removed in 0.60
config_str = yaml.dump([config])
# Indent so it renders in a fixed-width font

View file

@ -64,7 +64,7 @@ class IhcLight(IHCDevice, Light):
"""
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
dimmable=False, product: Element=None) -> None:
dimmable=False, product: Element = None) -> None:
"""Initialize the light."""
super().__init__(ihc_controller, name, ihc_id, info, product)
self._brightness = 0

View file

@ -29,10 +29,6 @@ def setup_platform(hass, config: ConfigType,
class ISYLightDevice(ISYDevice, Light):
"""Representation of an ISY994 light device."""
def __init__(self, node: object) -> None:
"""Initialize the ISY994 light device."""
super().__init__(node)
@property
def is_on(self) -> bool:
"""Get whether the ISY994 light is on."""
@ -48,6 +44,7 @@ class ISYLightDevice(ISYDevice, Light):
if not self._node.off():
_LOGGER.debug("Unable to turn off light")
# pylint: disable=arguments-differ
def turn_on(self, brightness=None, **kwargs) -> None:
"""Send the turn on command to the ISY994 light device."""
if not self._node.on(val=brightness):

View file

@ -198,6 +198,7 @@ class LimitlessLEDGroup(Light):
"""Return the brightness property."""
return self._brightness
# pylint: disable=arguments-differ
@state(False)
def turn_off(self, transition_time, pipeline, **kwargs):
"""Turn off a group."""
@ -231,6 +232,7 @@ class LimitlessLEDWhiteGroup(LimitlessLEDGroup):
"""Flag supported features."""
return SUPPORT_LIMITLESSLED_WHITE
# pylint: disable=arguments-differ
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""
@ -271,6 +273,7 @@ class LimitlessLEDRGBWGroup(LimitlessLEDGroup):
"""Flag supported features."""
return SUPPORT_LIMITLESSLED_RGB
# pylint: disable=arguments-differ
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""
@ -337,6 +340,7 @@ class LimitlessLEDRGBWWGroup(LimitlessLEDGroup):
"""Flag supported features."""
return SUPPORT_LIMITLESSLED_RGBWW
# pylint: disable=arguments-differ
@state(True)
def turn_on(self, transition_time, pipeline, **kwargs):
"""Turn on (or adjust property of) a group."""

View file

@ -130,7 +130,7 @@ class MySensorsLight(mysensors.MySensorsEntity, Light):
self._white = white
self._values[self.value_type] = hex_color
def turn_off(self):
def turn_off(self, **kwargs):
"""Turn the device off."""
value_type = self.gateway.const.SetReq.V_LIGHT
self.gateway.set_child_value(

View file

@ -118,7 +118,7 @@ class TPLinkSmartBulb(Light):
rgb = kwargs.get(ATTR_RGB_COLOR)
self.smartbulb.hsv = rgb_to_hsv(rgb)
def turn_off(self):
def turn_off(self, **kwargs):
"""Turn the light off."""
self.smartbulb.state = self.smartbulb.BULB_STATE_OFF

View file

@ -118,6 +118,6 @@ class WinkLight(WinkDevice, Light):
self.wink.set_state(True, **state_kwargs)
def turn_off(self):
def turn_off(self, **kwargs):
"""Turn the switch off."""
self.wink.set_state(False)

View file

@ -242,7 +242,7 @@ class XiaomiPhilipsGenericLight(Light):
_LOGGER.error("Got exception while fetching the state: %s", ex)
@asyncio.coroutine
def async_set_scene(self, scene: int=1):
def async_set_scene(self, scene: int = 1):
"""Set the fixed scene."""
yield from self._try_command(
"Setting a fixed scene failed.",
@ -260,10 +260,6 @@ class XiaomiPhilipsGenericLight(Light):
class XiaomiPhilipsLightBall(XiaomiPhilipsGenericLight, Light):
"""Representation of a Xiaomi Philips Light Ball."""
def __init__(self, name, light, device_info):
"""Initialize the light device."""
super().__init__(name, light, device_info)
@property
def color_temp(self):
"""Return the color temperature."""
@ -345,10 +341,6 @@ class XiaomiPhilipsLightBall(XiaomiPhilipsGenericLight, Light):
class XiaomiPhilipsCeilingLamp(XiaomiPhilipsLightBall, Light):
"""Representation of a Xiaomi Philips Ceiling Lamp."""
def __init__(self, name, light, device_info):
"""Initialize the light device."""
super().__init__(name, light, device_info)
@property
def min_mireds(self):
"""Return the coldest color_temp that this light supports."""
@ -363,6 +355,4 @@ class XiaomiPhilipsCeilingLamp(XiaomiPhilipsLightBall, Light):
class XiaomiPhilipsEyecareLamp(XiaomiPhilipsGenericLight, Light):
"""Representation of a Xiaomi Philips Eyecare Lamp 2."""
def __init__(self, name, light, device_info):
"""Initialize the light device."""
super().__init__(name, light, device_info)
pass

View file

@ -4,7 +4,7 @@ LIRC interface to receive signals from an infrared remote control.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/lirc/
"""
# pylint: disable=import-error
# pylint: disable=import-error,no-member
import threading
import time
import logging

View file

@ -53,8 +53,7 @@ class ISYLockDevice(ISYDevice, LockDevice):
"""Get the state of the lock."""
if self.is_unknown():
return None
else:
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN)
return VALUE_TO_STATE.get(self.value, STATE_UNKNOWN)
def lock(self, **kwargs) -> None:
"""Send the lock command to the ISY994 device."""

View file

@ -85,7 +85,7 @@ class MediaExtractor(object):
else:
entities = self.get_entities()
if len(entities) == 0:
if not entities:
self.call_media_player_service(stream_selector, None)
for entity_id in entities:
@ -108,7 +108,7 @@ class MediaExtractor(object):
_LOGGER.warning(
"Playlists are not supported, looking for the first video")
entries = list(all_media['entries'])
if len(entries) > 0:
if entries:
selected_media = entries[0]
else:
_LOGGER.error("Playlist is empty")

View file

@ -201,9 +201,9 @@ class SharpAquosTVDevice(MediaPlayerDevice):
self._remote.volume(int(self._volume * 60) - 2)
@_retry
def set_volume_level(self, level):
def set_volume_level(self, volume):
"""Set Volume media player."""
self._remote.volume(int(level * 60))
self._remote.volume(int(volume * 60))
@_retry
def mute_volume(self, mute):

View file

@ -440,8 +440,7 @@ class BluesoundPlayer(MediaPlayerDevice):
return STATE_PAUSED
elif status == 'stream' or status == 'play':
return STATE_PLAYING
else:
return STATE_IDLE
return STATE_IDLE
@property
def media_title(self):
@ -595,7 +594,7 @@ class BluesoundPlayer(MediaPlayerDevice):
# But it works with radio service_items will catch playlists.
items = [x for x in self._preset_items if 'url2' in x and
parse.unquote(x['url2']) == stream_url]
if len(items) > 0:
if items:
return items[0]['title']
# This could be a bit difficult to detect. Bluetooth could be named
@ -606,11 +605,11 @@ class BluesoundPlayer(MediaPlayerDevice):
if title == 'bluetooth' or stream_url == 'Capture:hw:2,0/44100/16/2':
items = [x for x in self._capture_items
if x['url'] == "Capture%3Abluez%3Abluetooth"]
if len(items) > 0:
if items:
return items[0]['title']
items = [x for x in self._capture_items if x['url'] == stream_url]
if len(items) > 0:
if items:
return items[0]['title']
if stream_url[:8] == 'Capture:':
@ -631,12 +630,12 @@ class BluesoundPlayer(MediaPlayerDevice):
items = [x for x in self._capture_items
if x['name'] == current_service]
if len(items) > 0:
if items:
return items[0]['title']
items = [x for x in self._services_items
if x['name'] == current_service]
if len(items) > 0:
if items:
return items[0]['title']
if self._status.get('streamUrl', '') != '':

View file

@ -87,7 +87,7 @@ class CecPlayerDevice(CecDevice, MediaPlayerDevice):
self.send_keypress(KEY_STOP)
self._state = STATE_IDLE
def play_media(self, media_type, media_id):
def play_media(self, media_type, media_id, **kwargs):
"""Not supported."""
raise NotImplementedError()

View file

@ -182,8 +182,7 @@ class MpdDevice(MediaPlayerDevice):
if name is None and title is None:
if file_name is None:
return "None"
else:
return os.path.basename(file_name)
return os.path.basename(file_name)
elif name is None:
return title
elif title is None:

View file

@ -296,7 +296,7 @@ class SoundTouchDevice(MediaPlayerDevice):
def play_media(self, media_type, media_id, **kwargs):
"""Play a piece of media."""
_LOGGER.debug("Starting media with media_id: " + str(media_id))
_LOGGER.debug("Starting media with media_id: %s", media_id)
if re.match(r'http://', str(media_id)):
# URL
_LOGGER.debug("Playing URL %s", str(media_id))
@ -307,11 +307,10 @@ class SoundTouchDevice(MediaPlayerDevice):
preset = next([preset for preset in presets if
preset.preset_id == str(media_id)].__iter__(), None)
if preset is not None:
_LOGGER.debug("Playing preset: " + preset.name)
_LOGGER.debug("Playing preset: %s", preset.name)
self._device.select_preset(preset)
else:
_LOGGER.warning(
"Unable to find preset with id " + str(media_id))
_LOGGER.warning("Unable to find preset with id %s", media_id)
def create_zone(self, slaves):
"""
@ -323,8 +322,8 @@ class SoundTouchDevice(MediaPlayerDevice):
if not slaves:
_LOGGER.warning("Unable to create zone without slaves")
else:
_LOGGER.info(
"Creating zone with master " + str(self.device.config.name))
_LOGGER.info("Creating zone with master %s",
self.device.config.name)
self.device.create_zone([slave.device for slave in slaves])
def remove_zone_slave(self, slaves):
@ -341,8 +340,8 @@ class SoundTouchDevice(MediaPlayerDevice):
if not slaves:
_LOGGER.warning("Unable to find slaves to remove")
else:
_LOGGER.info("Removing slaves from zone with master " +
str(self.device.config.name))
_LOGGER.info("Removing slaves from zone with master %s",
self.device.config.name)
self.device.remove_zone_slave([slave.device for slave in slaves])
def add_zone_slave(self, slaves):
@ -357,7 +356,6 @@ class SoundTouchDevice(MediaPlayerDevice):
if not slaves:
_LOGGER.warning("Unable to find slaves to add")
else:
_LOGGER.info(
"Adding slaves to zone with master " + str(
self.device.config.name))
_LOGGER.info("Adding slaves to zone with master %s",
self.device.config.name)
self.device.add_zone_slave([slave.device for slave in slaves])

View file

@ -270,8 +270,7 @@ class LgWebOSDevice(MediaPlayerDevice):
"""Title of current playing media."""
if (self._channel is not None) and ('channelName' in self._channel):
return self._channel['channelName']
else:
return None
return None
@property
def media_image_url(self):

View file

@ -136,7 +136,7 @@ def _load_config(filename):
class JSONBytesDecoder(json.JSONEncoder):
"""JSONEncoder to decode bytes objects to unicode."""
# pylint: disable=method-hidden
# pylint: disable=method-hidden, arguments-differ
def default(self, obj):
"""Decode object if it's a bytes object, else defer to base class."""
if isinstance(obj, bytes):

View file

@ -56,4 +56,4 @@ class AutomateNotificationService(BaseNotificationService):
response = requests.post(_RESOURCE, json=data)
if response.status_code != 200:
_LOGGER.error("Error sending message: " + str(response))
_LOGGER.error("Error sending message: %s", response)

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