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:
parent
64c5d26a84
commit
678f284015
196 changed files with 541 additions and 593 deletions
|
@ -35,13 +35,13 @@ FIRST_INIT_COMPONENT = set((
|
||||||
|
|
||||||
|
|
||||||
def from_config_dict(config: Dict[str, Any],
|
def from_config_dict(config: Dict[str, Any],
|
||||||
hass: Optional[core.HomeAssistant]=None,
|
hass: Optional[core.HomeAssistant] = None,
|
||||||
config_dir: Optional[str]=None,
|
config_dir: Optional[str] = None,
|
||||||
enable_log: bool=True,
|
enable_log: bool = True,
|
||||||
verbose: bool=False,
|
verbose: bool = False,
|
||||||
skip_pip: bool=False,
|
skip_pip: bool = False,
|
||||||
log_rotate_days: Any=None,
|
log_rotate_days: Any = None,
|
||||||
log_file: Any=None) \
|
log_file: Any = None) \
|
||||||
-> Optional[core.HomeAssistant]:
|
-> Optional[core.HomeAssistant]:
|
||||||
"""Try to configure Home Assistant from a configuration dictionary.
|
"""Try to configure Home Assistant from a configuration dictionary.
|
||||||
|
|
||||||
|
@ -68,12 +68,12 @@ def from_config_dict(config: Dict[str, Any],
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_from_config_dict(config: Dict[str, Any],
|
def async_from_config_dict(config: Dict[str, Any],
|
||||||
hass: core.HomeAssistant,
|
hass: core.HomeAssistant,
|
||||||
config_dir: Optional[str]=None,
|
config_dir: Optional[str] = None,
|
||||||
enable_log: bool=True,
|
enable_log: bool = True,
|
||||||
verbose: bool=False,
|
verbose: bool = False,
|
||||||
skip_pip: bool=False,
|
skip_pip: bool = False,
|
||||||
log_rotate_days: Any=None,
|
log_rotate_days: Any = None,
|
||||||
log_file: Any=None) \
|
log_file: Any = None) \
|
||||||
-> Optional[core.HomeAssistant]:
|
-> Optional[core.HomeAssistant]:
|
||||||
"""Try to configure Home Assistant from a configuration dictionary.
|
"""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,
|
def from_config_file(config_path: str,
|
||||||
hass: Optional[core.HomeAssistant]=None,
|
hass: Optional[core.HomeAssistant] = None,
|
||||||
verbose: bool=False,
|
verbose: bool = False,
|
||||||
skip_pip: bool=True,
|
skip_pip: bool = True,
|
||||||
log_rotate_days: Any=None,
|
log_rotate_days: Any = None,
|
||||||
log_file: Any=None):
|
log_file: Any = None):
|
||||||
"""Read the configuration file and try to start all the functionality.
|
"""Read the configuration file and try to start all the functionality.
|
||||||
|
|
||||||
Will add functionality to 'hass' parameter if given,
|
Will add functionality to 'hass' parameter if given,
|
||||||
|
@ -188,10 +188,10 @@ def from_config_file(config_path: str,
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_from_config_file(config_path: str,
|
def async_from_config_file(config_path: str,
|
||||||
hass: core.HomeAssistant,
|
hass: core.HomeAssistant,
|
||||||
verbose: bool=False,
|
verbose: bool = False,
|
||||||
skip_pip: bool=True,
|
skip_pip: bool = True,
|
||||||
log_rotate_days: Any=None,
|
log_rotate_days: Any = None,
|
||||||
log_file: Any=None):
|
log_file: Any = None):
|
||||||
"""Read the configuration file and try to start all the functionality.
|
"""Read the configuration file and try to start all the functionality.
|
||||||
|
|
||||||
Will add functionality to 'hass' parameter.
|
Will add functionality to 'hass' parameter.
|
||||||
|
@ -219,7 +219,7 @@ def async_from_config_file(config_path: str,
|
||||||
|
|
||||||
|
|
||||||
@core.callback
|
@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:
|
log_rotate_days=None, log_file=None) -> None:
|
||||||
"""Set up the logging.
|
"""Set up the logging.
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ https://home-assistant.io/components/abode/
|
||||||
import asyncio
|
import asyncio
|
||||||
import logging
|
import logging
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
from requests.exceptions import HTTPError, ConnectTimeout
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
|
@ -17,7 +18,6 @@ from homeassistant.const import (
|
||||||
from homeassistant.helpers import config_validation as cv
|
from homeassistant.helpers import config_validation as cv
|
||||||
from homeassistant.helpers import discovery
|
from homeassistant.helpers import discovery
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from requests.exceptions import HTTPError, ConnectTimeout
|
|
||||||
|
|
||||||
REQUIREMENTS = ['abodepy==0.12.2']
|
REQUIREMENTS = ['abodepy==0.12.2']
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ class CanaryAlarm(AlarmControlPanel):
|
||||||
return STATE_ALARM_ARMED_HOME
|
return STATE_ALARM_ARMED_HOME
|
||||||
elif mode.name == LOCATION_MODE_NIGHT:
|
elif mode.name == LOCATION_MODE_NIGHT:
|
||||||
return STATE_ALARM_ARMED_NIGHT
|
return STATE_ALARM_ARMED_NIGHT
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -172,9 +172,8 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
trigger_time) < dt_util.utcnow():
|
trigger_time) < dt_util.utcnow():
|
||||||
if self._disarm_after_trigger:
|
if self._disarm_after_trigger:
|
||||||
return STATE_ALARM_DISARMED
|
return STATE_ALARM_DISARMED
|
||||||
else:
|
self._state = self._previous_state
|
||||||
self._state = self._previous_state
|
return self._state
|
||||||
return self._state
|
|
||||||
|
|
||||||
if self._state in SUPPORTED_PENDING_STATES and \
|
if self._state in SUPPORTED_PENDING_STATES and \
|
||||||
self._within_pending_time(self._state):
|
self._within_pending_time(self._state):
|
||||||
|
@ -187,8 +186,7 @@ class ManualAlarm(alarm.AlarmControlPanel):
|
||||||
"""Get the current state."""
|
"""Get the current state."""
|
||||||
if self.state == STATE_ALARM_PENDING:
|
if self.state == STATE_ALARM_PENDING:
|
||||||
return self._previous_state
|
return self._previous_state
|
||||||
else:
|
return self._state
|
||||||
return self._state
|
|
||||||
|
|
||||||
def _pending_time(self, state):
|
def _pending_time(self, state):
|
||||||
"""Get the pending time."""
|
"""Get the pending time."""
|
||||||
|
|
|
@ -208,9 +208,8 @@ class ManualMQTTAlarm(alarm.AlarmControlPanel):
|
||||||
trigger_time) < dt_util.utcnow():
|
trigger_time) < dt_util.utcnow():
|
||||||
if self._disarm_after_trigger:
|
if self._disarm_after_trigger:
|
||||||
return STATE_ALARM_DISARMED
|
return STATE_ALARM_DISARMED
|
||||||
else:
|
self._state = self._previous_state
|
||||||
self._state = self._previous_state
|
return self._state
|
||||||
return self._state
|
|
||||||
|
|
||||||
if self._state in SUPPORTED_PENDING_STATES and \
|
if self._state in SUPPORTED_PENDING_STATES and \
|
||||||
self._within_pending_time(self._state):
|
self._within_pending_time(self._state):
|
||||||
|
@ -223,8 +222,7 @@ class ManualMQTTAlarm(alarm.AlarmControlPanel):
|
||||||
"""Get the current state."""
|
"""Get the current state."""
|
||||||
if self.state == STATE_ALARM_PENDING:
|
if self.state == STATE_ALARM_PENDING:
|
||||||
return self._previous_state
|
return self._previous_state
|
||||||
else:
|
return self._state
|
||||||
return self._state
|
|
||||||
|
|
||||||
def _pending_time(self, state):
|
def _pending_time(self, state):
|
||||||
"""Get the pending time."""
|
"""Get the pending time."""
|
||||||
|
|
|
@ -50,7 +50,7 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
|
||||||
self._zone_type = zone_type
|
self._zone_type = zone_type
|
||||||
self._zone_number = zone_number
|
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)
|
super().__init__(zone_name, info, controller)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
|
@ -70,7 +70,7 @@ class IHCBinarySensor(IHCDevice, BinarySensorDevice):
|
||||||
|
|
||||||
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
||||||
sensor_type: str, inverting: bool,
|
sensor_type: str, inverting: bool,
|
||||||
product: Element=None) -> None:
|
product: Element = None) -> None:
|
||||||
"""Initialize the IHC binary sensor."""
|
"""Initialize the IHC binary sensor."""
|
||||||
super().__init__(ihc_controller, name, ihc_id, info, product)
|
super().__init__(ihc_controller, name, ihc_id, info, product)
|
||||||
self._state = None
|
self._state = None
|
||||||
|
|
|
@ -498,7 +498,7 @@ class TodoistProjectData(object):
|
||||||
|
|
||||||
# Organize the best tasks (so users can see all the tasks
|
# Organize the best tasks (so users can see all the tasks
|
||||||
# they have, organized)
|
# they have, organized)
|
||||||
while len(project_tasks) > 0:
|
while project_tasks:
|
||||||
best_task = self.select_best_task(project_tasks)
|
best_task = self.select_best_task(project_tasks)
|
||||||
_LOGGER.debug("Found Todoist Task: %s", best_task[SUMMARY])
|
_LOGGER.debug("Found Todoist Task: %s", best_task[SUMMARY])
|
||||||
project_tasks.remove(best_task)
|
project_tasks.remove(best_task)
|
||||||
|
|
|
@ -119,6 +119,8 @@ class MjpegCamera(Camera):
|
||||||
else:
|
else:
|
||||||
req = requests.get(self._mjpeg_url, stream=True, timeout=10)
|
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:
|
with closing(req) as response:
|
||||||
return extract_image_from_mjpeg(response.iter_content(102400))
|
return extract_image_from_mjpeg(response.iter_content(102400))
|
||||||
|
|
||||||
|
|
|
@ -188,7 +188,7 @@ class UnifiVideoCamera(Camera):
|
||||||
self._nvr.set_recordmode(self._uuid, set_mode)
|
self._nvr.set_recordmode(self._uuid, set_mode)
|
||||||
self._motion_status = mode
|
self._motion_status = mode
|
||||||
except NvrError as err:
|
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)
|
_LOGGER.debug(err)
|
||||||
|
|
||||||
def enable_motion_detection(self):
|
def enable_motion_detection(self):
|
||||||
|
|
|
@ -42,7 +42,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
# pylint: disable=unused-argument
|
|
||||||
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
|
||||||
"""Discover and setup Xeoma Cameras."""
|
"""Discover and setup Xeoma Cameras."""
|
||||||
from pyxeoma.xeoma import Xeoma, XeomaError
|
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]:
|
for cam in config[CONF_CAMERAS]:
|
||||||
|
# https://github.com/PyCQA/pylint/issues/1830
|
||||||
|
# pylint: disable=stop-iteration-return
|
||||||
camera = next(
|
camera = next(
|
||||||
(dc for dc in discovered_cameras
|
(dc for dc in discovered_cameras
|
||||||
if dc[CONF_IMAGE_NAME] == cam[CONF_IMAGE_NAME]), None)
|
if dc[CONF_IMAGE_NAME] == cam[CONF_IMAGE_NAME]), None)
|
||||||
|
|
|
@ -669,16 +669,16 @@ class ClimateDevice(Entity):
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.set_humidity, humidity)
|
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."""
|
"""Set new target fan mode."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def async_set_fan_mode(self, fan):
|
def async_set_fan_mode(self, fan_mode):
|
||||||
"""Set new target fan mode.
|
"""Set new target fan mode.
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
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):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set new target operation mode."""
|
"""Set new target operation mode."""
|
||||||
|
|
|
@ -236,9 +236,9 @@ class DaikinClimate(ClimateDevice):
|
||||||
"""Return the fan setting."""
|
"""Return the fan setting."""
|
||||||
return self.get(ATTR_FAN_MODE)
|
return self.get(ATTR_FAN_MODE)
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set fan mode."""
|
"""Set fan mode."""
|
||||||
self.set({ATTR_FAN_MODE: fan})
|
self.set({ATTR_FAN_MODE: fan_mode})
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
|
|
|
@ -195,9 +195,9 @@ class DemoClimate(ClimateDevice):
|
||||||
self._current_swing_mode = swing_mode
|
self._current_swing_mode = swing_mode
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
self._current_fan_mode = fan
|
self._current_fan_mode = fan_mode
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
|
@ -225,9 +225,9 @@ class DemoClimate(ClimateDevice):
|
||||||
self._away = False
|
self._away = False
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def set_hold_mode(self, hold):
|
def set_hold_mode(self, hold_mode):
|
||||||
"""Update hold mode on."""
|
"""Update hold_mode on."""
|
||||||
self._hold = hold
|
self._hold = hold_mode
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def turn_aux_heat_on(self):
|
def turn_aux_heat_on(self):
|
||||||
|
|
|
@ -98,8 +98,7 @@ class EphEmberThermostat(ClimateDevice):
|
||||||
"""Return current operation ie. heat, cool, idle."""
|
"""Return current operation ie. heat, cool, idle."""
|
||||||
if self._zone['isCurrentlyActive']:
|
if self._zone['isCurrentlyActive']:
|
||||||
return STATE_HEAT
|
return STATE_HEAT
|
||||||
else:
|
return STATE_IDLE
|
||||||
return STATE_IDLE
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_aux_heat_on(self):
|
def is_aux_heat_on(self):
|
||||||
|
|
|
@ -53,7 +53,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
add_devices(devices)
|
add_devices(devices)
|
||||||
|
|
||||||
|
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-name-in-module
|
||||||
class EQ3BTSmartThermostat(ClimateDevice):
|
class EQ3BTSmartThermostat(ClimateDevice):
|
||||||
"""Representation of an eQ-3 Bluetooth Smart thermostat."""
|
"""Representation of an eQ-3 Bluetooth Smart thermostat."""
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,6 @@ class Flexit(ClimateDevice):
|
||||||
self._target_temperature = kwargs.get(ATTR_TEMPERATURE)
|
self._target_temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||||
self.unit.set_temp(self._target_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."""
|
"""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))
|
||||||
|
|
|
@ -190,11 +190,9 @@ class GenericThermostat(ClimateDevice):
|
||||||
"""Return the current state."""
|
"""Return the current state."""
|
||||||
if self._is_device_active:
|
if self._is_device_active:
|
||||||
return self.current_operation
|
return self.current_operation
|
||||||
else:
|
if self._enabled:
|
||||||
if self._enabled:
|
return STATE_IDLE
|
||||||
return STATE_IDLE
|
return STATE_OFF
|
||||||
else:
|
|
||||||
return STATE_OFF
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def should_poll(self):
|
def should_poll(self):
|
||||||
|
|
|
@ -146,10 +146,10 @@ class MelissaClimate(ClimateDevice):
|
||||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||||
self.send({self._api.TEMP: temp})
|
self.send({self._api.TEMP: temp})
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set fan mode."""
|
"""Set fan mode."""
|
||||||
fan_mode = self.hass_fan_to_melissa(fan)
|
melissa_fan_mode = self.hass_fan_to_melissa(fan_mode)
|
||||||
self.send({self._api.FAN: fan_mode})
|
self.send({self._api.FAN: melissa_fan_mode})
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set operation mode."""
|
"""Set operation mode."""
|
||||||
|
@ -174,8 +174,7 @@ class MelissaClimate(ClimateDevice):
|
||||||
if not self._api.send(self._serial_number, self._cur_settings):
|
if not self._api.send(self._serial_number, self._cur_settings):
|
||||||
self._cur_settings = old_value
|
self._cur_settings = old_value
|
||||||
return False
|
return False
|
||||||
else:
|
return True
|
||||||
return True
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Get latest data from Melissa."""
|
"""Get latest data from Melissa."""
|
||||||
|
@ -196,8 +195,7 @@ class MelissaClimate(ClimateDevice):
|
||||||
return STATE_OFF
|
return STATE_OFF
|
||||||
elif state == self._api.STATE_IDLE:
|
elif state == self._api.STATE_IDLE:
|
||||||
return STATE_IDLE
|
return STATE_IDLE
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def melissa_op_to_hass(self, mode):
|
def melissa_op_to_hass(self, mode):
|
||||||
"""Translate Melissa modes to hass states."""
|
"""Translate Melissa modes to hass states."""
|
||||||
|
@ -211,10 +209,9 @@ class MelissaClimate(ClimateDevice):
|
||||||
return STATE_DRY
|
return STATE_DRY
|
||||||
elif mode == self._api.MODE_FAN:
|
elif mode == self._api.MODE_FAN:
|
||||||
return STATE_FAN_ONLY
|
return STATE_FAN_ONLY
|
||||||
else:
|
_LOGGER.warning(
|
||||||
_LOGGER.warning(
|
"Operation mode %s could not be mapped to hass", mode)
|
||||||
"Operation mode %s could not be mapped to hass", mode)
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def melissa_fan_to_hass(self, fan):
|
def melissa_fan_to_hass(self, fan):
|
||||||
"""Translate Melissa fan modes to hass modes."""
|
"""Translate Melissa fan modes to hass modes."""
|
||||||
|
@ -226,9 +223,8 @@ class MelissaClimate(ClimateDevice):
|
||||||
return SPEED_MEDIUM
|
return SPEED_MEDIUM
|
||||||
elif fan == self._api.FAN_HIGH:
|
elif fan == self._api.FAN_HIGH:
|
||||||
return SPEED_HIGH
|
return SPEED_HIGH
|
||||||
else:
|
_LOGGER.warning("Fan mode %s could not be mapped to hass", fan)
|
||||||
_LOGGER.warning("Fan mode %s could not be mapped to hass", fan)
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def hass_mode_to_melissa(self, mode):
|
def hass_mode_to_melissa(self, mode):
|
||||||
"""Translate hass states to melissa modes."""
|
"""Translate hass states to melissa modes."""
|
||||||
|
|
|
@ -482,15 +482,15 @@ class MqttClimate(MqttAvailability, ClimateDevice):
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_fan_mode(self, fan):
|
def async_set_fan_mode(self, fan_mode):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if self._send_if_off or self._current_operation != STATE_OFF:
|
if self._send_if_off or self._current_operation != STATE_OFF:
|
||||||
mqtt.async_publish(
|
mqtt.async_publish(
|
||||||
self.hass, self._topic[CONF_FAN_MODE_COMMAND_TOPIC],
|
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:
|
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()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
@ -552,15 +552,15 @@ class MqttClimate(MqttAvailability, ClimateDevice):
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_hold_mode(self, hold):
|
def async_set_hold_mode(self, hold_mode):
|
||||||
"""Update hold mode on."""
|
"""Update hold mode on."""
|
||||||
if self._topic[CONF_HOLD_COMMAND_TOPIC] is not None:
|
if self._topic[CONF_HOLD_COMMAND_TOPIC] is not None:
|
||||||
mqtt.async_publish(self.hass,
|
mqtt.async_publish(self.hass,
|
||||||
self._topic[CONF_HOLD_COMMAND_TOPIC],
|
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:
|
if self._topic[CONF_HOLD_STATE_TOPIC] is None:
|
||||||
self._hold = hold
|
self._hold = hold_mode
|
||||||
self.async_schedule_update_ha_state()
|
self.async_schedule_update_ha_state()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
|
@ -143,14 +143,14 @@ class MySensorsHVAC(mysensors.MySensorsEntity, ClimateDevice):
|
||||||
self._values[value_type] = value
|
self._values[value_type] = value
|
||||||
self.schedule_update_ha_state()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
set_req = self.gateway.const.SetReq
|
set_req = self.gateway.const.SetReq
|
||||||
self.gateway.set_child_value(
|
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:
|
if self.gateway.optimistic:
|
||||||
# Optimistically assume that device has changed state
|
# 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()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
def set_operation_mode(self, operation_mode):
|
def set_operation_mode(self, operation_mode):
|
||||||
|
|
|
@ -207,9 +207,9 @@ class NestThermostat(ClimateDevice):
|
||||||
"""List of available fan modes."""
|
"""List of available fan modes."""
|
||||||
return self._fan_list
|
return self._fan_list
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Turn fan on/off."""
|
"""Turn fan on/off."""
|
||||||
self.device.fan = fan.lower()
|
self.device.fan = fan_mode.lower()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
|
@ -225,7 +225,7 @@ class NestThermostat(ClimateDevice):
|
||||||
"""Cache value from Python-nest."""
|
"""Cache value from Python-nest."""
|
||||||
self._location = self.device.where
|
self._location = self.device.where
|
||||||
self._name = self.device.name
|
self._name = self.device.name
|
||||||
self._humidity = self.device.humidity,
|
self._humidity = self.device.humidity
|
||||||
self._temperature = self.device.temperature
|
self._temperature = self.device.temperature
|
||||||
self._mode = self.device.mode
|
self._mode = self.device.mode
|
||||||
self._target_temperature = self.device.target
|
self._target_temperature = self.device.target
|
||||||
|
|
|
@ -185,7 +185,7 @@ class NuHeatThermostat(ClimateDevice):
|
||||||
self._thermostat.resume_schedule()
|
self._thermostat.resume_schedule()
|
||||||
self._force_update = True
|
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."""
|
"""Update the hold mode of the thermostat."""
|
||||||
if hold_mode == MODE_AUTO:
|
if hold_mode == MODE_AUTO:
|
||||||
schedule_mode = SCHEDULE_RUN
|
schedule_mode = SCHEDULE_RUN
|
||||||
|
|
|
@ -183,17 +183,16 @@ class RadioThermostat(ClimateDevice):
|
||||||
"""List of available fan modes."""
|
"""List of available fan modes."""
|
||||||
if self._is_model_ct80:
|
if self._is_model_ct80:
|
||||||
return CT80_FAN_OPERATION_LIST
|
return CT80_FAN_OPERATION_LIST
|
||||||
else:
|
return CT30_FAN_OPERATION_LIST
|
||||||
return CT30_FAN_OPERATION_LIST
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_fan_mode(self):
|
def current_fan_mode(self):
|
||||||
"""Return whether the fan is on."""
|
"""Return whether the fan is on."""
|
||||||
return self._fmode
|
return self._fmode
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Turn fan on/off."""
|
"""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:
|
if code is not None:
|
||||||
self.device.fmode = code
|
self.device.fmode = code
|
||||||
|
|
||||||
|
|
|
@ -240,13 +240,13 @@ class SensiboClimate(ClimateDevice):
|
||||||
def min_temp(self):
|
def min_temp(self):
|
||||||
"""Return the minimum temperature."""
|
"""Return the minimum temperature."""
|
||||||
return self._temperatures_list[0] \
|
return self._temperatures_list[0] \
|
||||||
if len(self._temperatures_list) else super().min_temp()
|
if self._temperatures_list else super().min_temp()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""Return the maximum temperature."""
|
"""Return the maximum temperature."""
|
||||||
return self._temperatures_list[-1] \
|
return self._temperatures_list[-1] \
|
||||||
if len(self._temperatures_list) else super().max_temp()
|
if self._temperatures_list else super().max_temp()
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_temperature(self, **kwargs):
|
def async_set_temperature(self, **kwargs):
|
||||||
|
@ -273,11 +273,11 @@ class SensiboClimate(ClimateDevice):
|
||||||
self._id, 'targetTemperature', temperature, self._ac_states)
|
self._id, 'targetTemperature', temperature, self._ac_states)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_fan_mode(self, fan):
|
def async_set_fan_mode(self, fan_mode):
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
with async_timeout.timeout(TIMEOUT):
|
with async_timeout.timeout(TIMEOUT):
|
||||||
yield from self._client.async_set_ac_state_property(
|
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
|
@asyncio.coroutine
|
||||||
def async_set_operation_mode(self, operation_mode):
|
def async_set_operation_mode(self, operation_mode):
|
||||||
|
|
|
@ -213,6 +213,7 @@ class TadoClimate(ClimateDevice):
|
||||||
self._target_temp = temperature
|
self._target_temp = temperature
|
||||||
self._control_heating()
|
self._control_heating()
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
def set_operation_mode(self, readable_operation_mode):
|
def set_operation_mode(self, readable_operation_mode):
|
||||||
"""Set new operation mode."""
|
"""Set new operation mode."""
|
||||||
operation_mode = CONST_MODE_SMART_SCHEDULE
|
operation_mode = CONST_MODE_SMART_SCHEDULE
|
||||||
|
|
|
@ -51,8 +51,7 @@ class TeslaThermostat(TeslaDevice, ClimateDevice):
|
||||||
mode = self.tesla_device.is_hvac_enabled()
|
mode = self.tesla_device.is_hvac_enabled()
|
||||||
if mode:
|
if mode:
|
||||||
return OPERATION_LIST[0] # On
|
return OPERATION_LIST[0] # On
|
||||||
else:
|
return OPERATION_LIST[1] # Off
|
||||||
return OPERATION_LIST[1] # Off
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def operation_list(self):
|
def operation_list(self):
|
||||||
|
|
|
@ -111,8 +111,7 @@ class VenstarThermostat(ClimateDevice):
|
||||||
"""Return the unit of measurement, as defined by the API."""
|
"""Return the unit of measurement, as defined by the API."""
|
||||||
if self._client.tempunits == self._client.TEMPUNITS_F:
|
if self._client.tempunits == self._client.TEMPUNITS_F:
|
||||||
return TEMP_FAHRENHEIT
|
return TEMP_FAHRENHEIT
|
||||||
else:
|
return TEMP_CELSIUS
|
||||||
return TEMP_CELSIUS
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
|
@ -143,16 +142,14 @@ class VenstarThermostat(ClimateDevice):
|
||||||
return STATE_COOL
|
return STATE_COOL
|
||||||
elif self._client.mode == self._client.MODE_AUTO:
|
elif self._client.mode == self._client.MODE_AUTO:
|
||||||
return STATE_AUTO
|
return STATE_AUTO
|
||||||
else:
|
return STATE_OFF
|
||||||
return STATE_OFF
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_fan_mode(self):
|
def current_fan_mode(self):
|
||||||
"""Return the fan setting."""
|
"""Return the fan setting."""
|
||||||
if self._client.fan == self._client.FAN_AUTO:
|
if self._client.fan == self._client.FAN_AUTO:
|
||||||
return STATE_AUTO
|
return STATE_AUTO
|
||||||
else:
|
return STATE_ON
|
||||||
return STATE_ON
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
@ -169,24 +166,21 @@ class VenstarThermostat(ClimateDevice):
|
||||||
return self._client.heattemp
|
return self._client.heattemp
|
||||||
elif self._client.mode == self._client.MODE_COOL:
|
elif self._client.mode == self._client.MODE_COOL:
|
||||||
return self._client.cooltemp
|
return self._client.cooltemp
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self):
|
||||||
"""Return the lower bound temp if auto mode is on."""
|
"""Return the lower bound temp if auto mode is on."""
|
||||||
if self._client.mode == self._client.MODE_AUTO:
|
if self._client.mode == self._client.MODE_AUTO:
|
||||||
return self._client.heattemp
|
return self._client.heattemp
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self):
|
||||||
"""Return the upper bound temp if auto mode is on."""
|
"""Return the upper bound temp if auto mode is on."""
|
||||||
if self._client.mode == self._client.MODE_AUTO:
|
if self._client.mode == self._client.MODE_AUTO:
|
||||||
return self._client.cooltemp
|
return self._client.cooltemp
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_humidity(self):
|
def target_humidity(self):
|
||||||
|
@ -245,9 +239,9 @@ class VenstarThermostat(ClimateDevice):
|
||||||
if not success:
|
if not success:
|
||||||
_LOGGER.error("Failed to change the temperature")
|
_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."""
|
"""Set new target fan mode."""
|
||||||
if fan == STATE_ON:
|
if fan_mode == STATE_ON:
|
||||||
success = self._client.set_fan(self._client.FAN_ON)
|
success = self._client.set_fan(self._client.FAN_ON)
|
||||||
else:
|
else:
|
||||||
success = self._client.set_fan(self._client.FAN_AUTO)
|
success = self._client.set_fan(self._client.FAN_AUTO)
|
||||||
|
|
|
@ -85,13 +85,13 @@ class VeraThermostat(VeraDevice, ClimateDevice):
|
||||||
"""Return a list of available fan modes."""
|
"""Return a list of available fan modes."""
|
||||||
return FAN_OPERATION_LIST
|
return FAN_OPERATION_LIST
|
||||||
|
|
||||||
def set_fan_mode(self, mode):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
if mode == FAN_OPERATION_LIST[0]:
|
if fan_mode == FAN_OPERATION_LIST[0]:
|
||||||
self.vera_device.fan_on()
|
self.vera_device.fan_on()
|
||||||
elif mode == FAN_OPERATION_LIST[1]:
|
elif fan_mode == FAN_OPERATION_LIST[1]:
|
||||||
self.vera_device.fan_auto()
|
self.vera_device.fan_auto()
|
||||||
elif mode == FAN_OPERATION_LIST[2]:
|
elif fan_mode == FAN_OPERATION_LIST[2]:
|
||||||
return self.vera_device.fan_cycle()
|
return self.vera_device.fan_cycle()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -324,9 +324,9 @@ class WinkThermostat(WinkDevice, ClimateDevice):
|
||||||
return self.wink.fan_modes()
|
return self.wink.fan_modes()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Turn fan on/off."""
|
"""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):
|
def turn_aux_heat_on(self):
|
||||||
"""Turn auxiliary heater on."""
|
"""Turn auxiliary heater on."""
|
||||||
|
@ -486,26 +486,25 @@ class WinkAC(WinkDevice, ClimateDevice):
|
||||||
return SPEED_LOW
|
return SPEED_LOW
|
||||||
elif speed <= 0.66:
|
elif speed <= 0.66:
|
||||||
return SPEED_MEDIUM
|
return SPEED_MEDIUM
|
||||||
else:
|
return SPEED_HIGH
|
||||||
return SPEED_HIGH
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
"""Return a list of available fan modes."""
|
"""Return a list of available fan modes."""
|
||||||
return [SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
return [SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""
|
"""
|
||||||
Set fan speed.
|
Set fan speed.
|
||||||
|
|
||||||
The official Wink app only supports 3 modes [low, medium, high]
|
The official Wink app only supports 3 modes [low, medium, high]
|
||||||
which are equal to [0.33, 0.66, 1.0] respectively.
|
which are equal to [0.33, 0.66, 1.0] respectively.
|
||||||
"""
|
"""
|
||||||
if fan == SPEED_LOW:
|
if fan_mode == SPEED_LOW:
|
||||||
speed = 0.33
|
speed = 0.33
|
||||||
elif fan == SPEED_MEDIUM:
|
elif fan_mode == SPEED_MEDIUM:
|
||||||
speed = 0.66
|
speed = 0.66
|
||||||
elif fan == SPEED_HIGH:
|
elif fan_mode == SPEED_HIGH:
|
||||||
speed = 1.0
|
speed = 1.0
|
||||||
self.wink.set_ac_fan_speed(speed)
|
self.wink.set_ac_fan_speed(speed)
|
||||||
|
|
||||||
|
|
|
@ -198,10 +198,10 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
|
||||||
|
|
||||||
self.values.primary.data = temperature
|
self.values.primary.data = temperature
|
||||||
|
|
||||||
def set_fan_mode(self, fan):
|
def set_fan_mode(self, fan_mode):
|
||||||
"""Set new target fan mode."""
|
"""Set new target fan mode."""
|
||||||
if self.values.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):
|
def set_operation_mode(self, operation_mode):
|
||||||
"""Set new target operation mode."""
|
"""Set new target operation mode."""
|
||||||
|
|
|
@ -31,6 +31,8 @@ class InvalidCode(CloudError):
|
||||||
class PasswordChangeRequired(CloudError):
|
class PasswordChangeRequired(CloudError):
|
||||||
"""Raised when a password change is required."""
|
"""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.'):
|
def __init__(self, message='Password change required.'):
|
||||||
"""Initialize a password change required error."""
|
"""Initialize a password change required error."""
|
||||||
super().__init__(message)
|
super().__init__(message)
|
||||||
|
|
|
@ -5,7 +5,8 @@ For more details about this platform, please refer to the documentation
|
||||||
https://home-assistant.io/components/demo/
|
https://home-assistant.io/components/demo/
|
||||||
"""
|
"""
|
||||||
from homeassistant.components.cover import (
|
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
|
from homeassistant.helpers.event import track_utc_time_change
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,8 +138,9 @@ class DemoCover(CoverDevice):
|
||||||
self._listen_cover_tilt()
|
self._listen_cover_tilt()
|
||||||
self._requested_closing_tilt = False
|
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."""
|
"""Move the cover to a specific position."""
|
||||||
|
position = kwargs.get(ATTR_POSITION)
|
||||||
self._set_position = round(position, -1)
|
self._set_position = round(position, -1)
|
||||||
if self._position == position:
|
if self._position == position:
|
||||||
return
|
return
|
||||||
|
@ -146,8 +148,9 @@ class DemoCover(CoverDevice):
|
||||||
self._listen_cover()
|
self._listen_cover()
|
||||||
self._requested_closing = position < self._position
|
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."""
|
"""Move the cover til to a specific position."""
|
||||||
|
tilt_position = kwargs.get(ATTR_TILT_POSITION)
|
||||||
self._set_tilt_position = round(tilt_position, -1)
|
self._set_tilt_position = round(tilt_position, -1)
|
||||||
if self._tilt_position == tilt_position:
|
if self._tilt_position == tilt_position:
|
||||||
return
|
return
|
||||||
|
|
|
@ -201,21 +201,21 @@ class GaradgetCover(CoverDevice):
|
||||||
"""Check the state of the service during an operation."""
|
"""Check the state of the service during an operation."""
|
||||||
self.schedule_update_ha_state(True)
|
self.schedule_update_ha_state(True)
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
if self._state not in ['close', 'closing']:
|
if self._state not in ['close', 'closing']:
|
||||||
ret = self._put_command('setState', 'close')
|
ret = self._put_command('setState', 'close')
|
||||||
self._start_watcher('close')
|
self._start_watcher('close')
|
||||||
return ret.get('return_value') == 1
|
return ret.get('return_value') == 1
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
if self._state not in ['open', 'opening']:
|
if self._state not in ['open', 'opening']:
|
||||||
ret = self._put_command('setState', 'open')
|
ret = self._put_command('setState', 'open')
|
||||||
self._start_watcher('open')
|
self._start_watcher('open')
|
||||||
return ret.get('return_value') == 1
|
return ret.get('return_value') == 1
|
||||||
|
|
||||||
def stop_cover(self):
|
def stop_cover(self, **kwargs):
|
||||||
"""Stop the door where it is."""
|
"""Stop the door where it is."""
|
||||||
if self._state not in ['stopped']:
|
if self._state not in ['stopped']:
|
||||||
ret = self._put_command('setState', 'stop')
|
ret = self._put_command('setState', 'stop')
|
||||||
|
|
|
@ -42,10 +42,6 @@ def setup_platform(hass, config: ConfigType,
|
||||||
class ISYCoverDevice(ISYDevice, CoverDevice):
|
class ISYCoverDevice(ISYDevice, CoverDevice):
|
||||||
"""Representation of an ISY994 cover device."""
|
"""Representation of an ISY994 cover device."""
|
||||||
|
|
||||||
def __init__(self, node: object) -> None:
|
|
||||||
"""Initialize the ISY994 cover device."""
|
|
||||||
super().__init__(node)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self) -> int:
|
def current_cover_position(self) -> int:
|
||||||
"""Return the current cover position."""
|
"""Return the current cover position."""
|
||||||
|
@ -61,8 +57,7 @@ class ISYCoverDevice(ISYDevice, CoverDevice):
|
||||||
"""Get the state of the ISY994 cover device."""
|
"""Get the state of the ISY994 cover device."""
|
||||||
if self.is_unknown():
|
if self.is_unknown():
|
||||||
return None
|
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:
|
def open_cover(self, **kwargs) -> None:
|
||||||
"""Send the open cover command to the ISY994 cover device."""
|
"""Send the open cover command to the ISY994 cover device."""
|
||||||
|
|
|
@ -84,11 +84,11 @@ class MyQDevice(CoverDevice):
|
||||||
"""Return true if cover is closed, else False."""
|
"""Return true if cover is closed, else False."""
|
||||||
return self._status == STATE_CLOSED
|
return self._status == STATE_CLOSED
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Issue close command to cover."""
|
"""Issue close command to cover."""
|
||||||
self.myq.close_device(self.device_id)
|
self.myq.close_device(self.device_id)
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Issue open command to cover."""
|
"""Issue open command to cover."""
|
||||||
self.myq.open_device(self.device_id)
|
self.myq.open_device(self.device_id)
|
||||||
|
|
||||||
|
|
|
@ -119,14 +119,14 @@ class OpenGarageCover(CoverDevice):
|
||||||
return None
|
return None
|
||||||
return self._state in [STATE_CLOSED, STATE_OPENING]
|
return self._state in [STATE_CLOSED, STATE_OPENING]
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
if self._state not in [STATE_CLOSED, STATE_CLOSING]:
|
if self._state not in [STATE_CLOSED, STATE_CLOSING]:
|
||||||
self._state_before_move = self._state
|
self._state_before_move = self._state
|
||||||
self._state = STATE_CLOSING
|
self._state = STATE_CLOSING
|
||||||
self._push_button()
|
self._push_button()
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
if self._state not in [STATE_OPEN, STATE_OPENING]:
|
if self._state not in [STATE_OPEN, STATE_OPENING]:
|
||||||
self._state_before_move = self._state
|
self._state_before_move = self._state
|
||||||
|
|
|
@ -109,12 +109,12 @@ class RPiGPIOCover(CoverDevice):
|
||||||
sleep(self._relay_time)
|
sleep(self._relay_time)
|
||||||
rpi_gpio.write_output(self._relay_pin, not self._invert_relay)
|
rpi_gpio.write_output(self._relay_pin, not self._invert_relay)
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
if not self.is_closed:
|
if not self.is_closed:
|
||||||
self._trigger()
|
self._trigger()
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
if self.is_closed:
|
if self.is_closed:
|
||||||
self._trigger()
|
self._trigger()
|
||||||
|
|
|
@ -6,7 +6,7 @@ https://home-assistant.io/components/cover.tahoma/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from homeassistant.components.cover import CoverDevice
|
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
|
||||||
from homeassistant.components.tahoma import (
|
from homeassistant.components.tahoma import (
|
||||||
DOMAIN as TAHOMA_DOMAIN, TahomaDevice)
|
DOMAIN as TAHOMA_DOMAIN, TahomaDevice)
|
||||||
|
|
||||||
|
@ -49,9 +49,9 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def set_cover_position(self, position, **kwargs):
|
def set_cover_position(self, **kwargs):
|
||||||
"""Move the cover to a specific position."""
|
"""Move the cover to a specific position."""
|
||||||
self.apply_action('setPosition', 100 - position)
|
self.apply_action('setPosition', 100 - kwargs.get(ATTR_POSITION))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
|
@ -64,8 +64,7 @@ class TahomaCover(TahomaDevice, CoverDevice):
|
||||||
"""Return the class of the device."""
|
"""Return the class of the device."""
|
||||||
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
|
if self.tahoma_device.type == 'io:WindowOpenerVeluxIOComponent':
|
||||||
return 'window'
|
return 'window'
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
def open_cover(self, **kwargs):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
|
|
|
@ -6,7 +6,8 @@ https://home-assistant.io/components/cover.vera/
|
||||||
"""
|
"""
|
||||||
import logging
|
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 (
|
from homeassistant.components.vera import (
|
||||||
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
|
VERA_CONTROLLER, VERA_DEVICES, VeraDevice)
|
||||||
|
|
||||||
|
@ -44,9 +45,9 @@ class VeraCover(VeraDevice, CoverDevice):
|
||||||
return 100
|
return 100
|
||||||
return position
|
return position
|
||||||
|
|
||||||
def set_cover_position(self, position, **kwargs):
|
def set_cover_position(self, **kwargs):
|
||||||
"""Move the cover to a specific position."""
|
"""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()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -6,7 +6,8 @@ https://home-assistant.io/components/cover.wink/
|
||||||
"""
|
"""
|
||||||
import asyncio
|
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
|
from homeassistant.components.wink import WinkDevice, DOMAIN
|
||||||
|
|
||||||
DEPENDENCIES = ['wink']
|
DEPENDENCIES = ['wink']
|
||||||
|
@ -42,17 +43,17 @@ class WinkCoverDevice(WinkDevice, CoverDevice):
|
||||||
"""Open the cover."""
|
"""Open the cover."""
|
||||||
self.wink.set_state(1)
|
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."""
|
"""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
|
@property
|
||||||
def current_cover_position(self):
|
def current_cover_position(self):
|
||||||
"""Return the current position of cover shutter."""
|
"""Return the current position of cover shutter."""
|
||||||
if self.wink.state() is not None:
|
if self.wink.state() is not None:
|
||||||
return int(self.wink.state()*100)
|
return int(self.wink.state()*100)
|
||||||
else:
|
return STATE_UNKNOWN
|
||||||
return STATE_UNKNOWN
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
"""Support for Xiaomi curtain."""
|
"""Support for Xiaomi curtain."""
|
||||||
import logging
|
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,
|
from homeassistant.components.xiaomi_aqara import (PY_XIAOMI_GATEWAY,
|
||||||
XiaomiDevice)
|
XiaomiDevice)
|
||||||
|
|
||||||
|
@ -55,8 +55,9 @@ class XiaomiGenericCover(XiaomiDevice, CoverDevice):
|
||||||
"""Stop the cover."""
|
"""Stop the cover."""
|
||||||
self._write_to_hub(self._sid, **{self._data_key['status']: 'stop'})
|
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."""
|
"""Move the cover to a specific position."""
|
||||||
|
position = kwargs.get(ATTR_POSITION)
|
||||||
self._write_to_hub(self._sid, **{self._data_key['pos']: str(position)})
|
self._write_to_hub(self._sid, **{self._data_key['pos']: str(position)})
|
||||||
|
|
||||||
def parse_data(self, data, raw_data):
|
def parse_data(self, data, raw_data):
|
||||||
|
|
|
@ -8,7 +8,7 @@ https://home-assistant.io/components/cover.zwave/
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.components.cover import (
|
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.zwave import ZWaveDeviceEntity
|
||||||
from homeassistant.components import zwave
|
from homeassistant.components import zwave
|
||||||
from homeassistant.components.zwave import async_setup_platform # noqa # pylint: disable=unused-import
|
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."""
|
"""Move the roller shutter down."""
|
||||||
self._network.manager.pressButton(self._close_id)
|
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."""
|
"""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):
|
def stop_cover(self, **kwargs):
|
||||||
"""Stop the roller shutter."""
|
"""Stop the roller shutter."""
|
||||||
|
@ -139,11 +140,11 @@ class ZwaveGarageDoorSwitch(ZwaveGarageDoorBase):
|
||||||
"""Return the current position of Zwave garage door."""
|
"""Return the current position of Zwave garage door."""
|
||||||
return not self._state
|
return not self._state
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the garage door."""
|
"""Close the garage door."""
|
||||||
self.values.primary.data = False
|
self.values.primary.data = False
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the garage door."""
|
"""Open the garage door."""
|
||||||
self.values.primary.data = True
|
self.values.primary.data = True
|
||||||
|
|
||||||
|
@ -166,10 +167,10 @@ class ZwaveGarageDoorBarrier(ZwaveGarageDoorBase):
|
||||||
"""Return the current position of Zwave garage door."""
|
"""Return the current position of Zwave garage door."""
|
||||||
return self._state == "Closed"
|
return self._state == "Closed"
|
||||||
|
|
||||||
def close_cover(self):
|
def close_cover(self, **kwargs):
|
||||||
"""Close the garage door."""
|
"""Close the garage door."""
|
||||||
self.values.primary.data = "Closed"
|
self.values.primary.data = "Closed"
|
||||||
|
|
||||||
def open_cover(self):
|
def open_cover(self, **kwargs):
|
||||||
"""Open the garage door."""
|
"""Open the garage door."""
|
||||||
self.values.primary.data = "Opened"
|
self.values.primary.data = "Opened"
|
||||||
|
|
|
@ -99,17 +99,17 @@ PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Return the state if any or a specified device is home."""
|
||||||
entity = entity_id or ENTITY_ID_ALL_DEVICES
|
entity = entity_id or ENTITY_ID_ALL_DEVICES
|
||||||
|
|
||||||
return hass.states.is_state(entity, STATE_HOME)
|
return hass.states.is_state(entity, STATE_HOME)
|
||||||
|
|
||||||
|
|
||||||
def see(hass: HomeAssistantType, mac: str=None, dev_id: str=None,
|
def see(hass: HomeAssistantType, mac: str = None, dev_id: str = None,
|
||||||
host_name: str=None, location_name: str=None,
|
host_name: str = None, location_name: str = None,
|
||||||
gps: GPSType=None, gps_accuracy=None,
|
gps: GPSType = None, gps_accuracy=None,
|
||||||
battery=None, attributes: dict=None):
|
battery=None, attributes: dict = None):
|
||||||
"""Call service to notify you see device."""
|
"""Call service to notify you see device."""
|
||||||
data = {key: value for key, value in
|
data = {key: value for key, value in
|
||||||
((ATTR_MAC, mac),
|
((ATTR_MAC, mac),
|
||||||
|
@ -239,11 +239,11 @@ class DeviceTracker(object):
|
||||||
_LOGGER.warning('Duplicate device MAC addresses detected %s',
|
_LOGGER.warning('Duplicate device MAC addresses detected %s',
|
||||||
dev.mac)
|
dev.mac)
|
||||||
|
|
||||||
def see(self, mac: str=None, dev_id: str=None, host_name: 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,
|
location_name: str = None, gps: GPSType = None, gps_accuracy=None,
|
||||||
battery: str=None, attributes: dict=None,
|
battery: str = None, attributes: dict = None,
|
||||||
source_type: str=SOURCE_TYPE_GPS, picture: str=None,
|
source_type: str = SOURCE_TYPE_GPS, picture: str = None,
|
||||||
icon: str=None):
|
icon: str = None):
|
||||||
"""Notify the device tracker that you see a device."""
|
"""Notify the device tracker that you see a device."""
|
||||||
self.hass.add_job(
|
self.hass.add_job(
|
||||||
self.async_see(mac, dev_id, host_name, location_name, gps,
|
self.async_see(mac, dev_id, host_name, location_name, gps,
|
||||||
|
@ -252,11 +252,11 @@ class DeviceTracker(object):
|
||||||
)
|
)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_see(self, mac: str=None, dev_id: str=None, host_name: str=None,
|
def async_see(self, mac: str = None, dev_id: str = None,
|
||||||
location_name: str=None, gps: GPSType=None,
|
host_name: str = None, location_name: str = None,
|
||||||
gps_accuracy=None, battery: str=None, attributes: dict=None,
|
gps: GPSType = None, gps_accuracy=None, battery: str = None,
|
||||||
source_type: str=SOURCE_TYPE_GPS, picture: str=None,
|
attributes: dict = None, source_type: str = SOURCE_TYPE_GPS,
|
||||||
icon: str=None):
|
picture: str = None, icon: str = None):
|
||||||
"""Notify the device tracker that you see a device.
|
"""Notify the device tracker that you see a device.
|
||||||
|
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
|
@ -396,9 +396,9 @@ class Device(Entity):
|
||||||
_state = STATE_NOT_HOME
|
_state = STATE_NOT_HOME
|
||||||
|
|
||||||
def __init__(self, hass: HomeAssistantType, consider_home: timedelta,
|
def __init__(self, hass: HomeAssistantType, consider_home: timedelta,
|
||||||
track: bool, dev_id: str, mac: str, name: str=None,
|
track: bool, dev_id: str, mac: str, name: str = None,
|
||||||
picture: str=None, gravatar: str=None, icon: str=None,
|
picture: str = None, gravatar: str = None, icon: str = None,
|
||||||
hide_if_away: bool=False, vendor: str=None) -> None:
|
hide_if_away: bool = False, vendor: str = None) -> None:
|
||||||
"""Initialize a device."""
|
"""Initialize a device."""
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(dev_id)
|
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
|
return self.away_hide and self.state != STATE_HOME
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_seen(self, host_name: str=None, location_name: str=None,
|
def async_seen(self, host_name: str = None, location_name: str = None,
|
||||||
gps: GPSType=None, gps_accuracy=0, battery: str=None,
|
gps: GPSType = None, gps_accuracy=0, battery: str = None,
|
||||||
attributes: dict=None, source_type: str=SOURCE_TYPE_GPS):
|
attributes: dict = None,
|
||||||
|
source_type: str = SOURCE_TYPE_GPS):
|
||||||
"""Mark the device as seen."""
|
"""Mark the device as seen."""
|
||||||
self.source_type = source_type
|
self.source_type = source_type
|
||||||
self.last_seen = dt_util.utcnow()
|
self.last_seen = dt_util.utcnow()
|
||||||
|
@ -504,7 +505,7 @@ class Device(Entity):
|
||||||
# pylint: disable=not-an-iterable
|
# pylint: disable=not-an-iterable
|
||||||
yield from self.async_update()
|
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.
|
"""Return if device state is stale.
|
||||||
|
|
||||||
Async friendly.
|
Async friendly.
|
||||||
|
@ -621,16 +622,16 @@ class DeviceScanner(object):
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.scan_devices)
|
return self.hass.async_add_job(self.scan_devices)
|
||||||
|
|
||||||
def get_device_name(self, mac: str) -> str:
|
def get_device_name(self, device: str) -> str:
|
||||||
"""Get device name from mac."""
|
"""Get the name of a device."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def async_get_device_name(self, mac: str) -> Any:
|
def async_get_device_name(self, device: str) -> Any:
|
||||||
"""Get device name from mac.
|
"""Get the name of a device.
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
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):
|
def load_config(path: str, hass: HomeAssistantType, consider_home: timedelta):
|
||||||
|
|
|
@ -177,10 +177,9 @@ class AutomaticAuthCallbackView(HomeAssistantView):
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Error authorizing Automatic: %s", params['error'])
|
"Error authorizing Automatic: %s", params['error'])
|
||||||
return response
|
return response
|
||||||
else:
|
_LOGGER.error(
|
||||||
_LOGGER.error(
|
"Error authorizing Automatic. Invalid response returned")
|
||||||
"Error authorizing Automatic. Invalid response returned")
|
return response
|
||||||
return response
|
|
||||||
|
|
||||||
if DATA_CONFIGURING not in hass.data or \
|
if DATA_CONFIGURING not in hass.data or \
|
||||||
params['state'] not in hass.data[DATA_CONFIGURING]:
|
params['state'] not in hass.data[DATA_CONFIGURING]:
|
||||||
|
|
|
@ -45,10 +45,10 @@ class BboxDeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return [device.mac for device in self.last_results]
|
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."""
|
"""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
|
filter_named = [result.name for result in self.last_results if
|
||||||
device.mac == mac]
|
result.mac == device]
|
||||||
|
|
||||||
if filter_named:
|
if filter_named:
|
||||||
return filter_named[0]
|
return filter_named[0]
|
||||||
|
|
|
@ -102,7 +102,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||||
"""Lookup Bluetooth LE devices and update status."""
|
"""Lookup Bluetooth LE devices and update status."""
|
||||||
devs = discover_ble_devices()
|
devs = discover_ble_devices()
|
||||||
for mac in devs_to_track:
|
for mac in devs_to_track:
|
||||||
_LOGGER.debug("Checking " + mac)
|
_LOGGER.debug("Checking %s", mac)
|
||||||
result = mac in devs
|
result = mac in devs
|
||||||
if not result:
|
if not result:
|
||||||
# Could not lookup device name
|
# Could not lookup device name
|
||||||
|
|
|
@ -41,7 +41,7 @@ def setup_scanner(hass, config, see, discovery_info=None):
|
||||||
result = bluetooth.discover_devices(
|
result = bluetooth.discover_devices(
|
||||||
duration=8, lookup_names=True, flush_cache=True,
|
duration=8, lookup_names=True, flush_cache=True,
|
||||||
lookup_class=False)
|
lookup_class=False)
|
||||||
_LOGGER.debug("Bluetooth devices discovered = " + str(len(result)))
|
_LOGGER.debug("Bluetooth devices discovered = %d", len(result))
|
||||||
return result
|
return result
|
||||||
|
|
||||||
yaml_path = hass.config.path(YAML_DEVICES)
|
yaml_path = hass.config.path(YAML_DEVICES)
|
||||||
|
|
|
@ -75,9 +75,9 @@ class FritzBoxScanner(DeviceScanner):
|
||||||
active_hosts.append(known_host['mac'])
|
active_hosts.append(known_host['mac'])
|
||||||
return active_hosts
|
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."""
|
"""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'
|
'NewHostName'
|
||||||
)
|
)
|
||||||
if ret == {}:
|
if ret == {}:
|
||||||
|
|
|
@ -120,8 +120,7 @@ class GeofencyView(HomeAssistantView):
|
||||||
"""Return name of device tracker."""
|
"""Return name of device tracker."""
|
||||||
if 'beaconUUID' in data:
|
if 'beaconUUID' in data:
|
||||||
return "{}_{}".format(BEACON_DEV_PREFIX, data['name'])
|
return "{}_{}".format(BEACON_DEV_PREFIX, data['name'])
|
||||||
else:
|
return data['device']
|
||||||
return data['device']
|
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _set_location(self, hass, data, location_name):
|
def _set_location(self, hass, data, location_name):
|
||||||
|
|
|
@ -60,11 +60,11 @@ class HitronCODADeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return [device.mac for device in self.last_results]
|
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."""
|
"""Return the name of the device with the given MAC address."""
|
||||||
name = next((
|
name = next((
|
||||||
device.name for device in self.last_results
|
result.name for result in self.last_results
|
||||||
if device.mac == mac), None)
|
if result.mac == device), None)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
def _login(self):
|
def _login(self):
|
||||||
|
|
|
@ -86,6 +86,7 @@ class HuaweiDeviceScanner(DeviceScanner):
|
||||||
active_clients = [client for client in data if client.state]
|
active_clients = [client for client in data if client.state]
|
||||||
self.last_results = active_clients
|
self.last_results = active_clients
|
||||||
|
|
||||||
|
# pylint: disable=logging-not-lazy
|
||||||
_LOGGER.debug("Active clients: " + "\n"
|
_LOGGER.debug("Active clients: " + "\n"
|
||||||
.join((client.mac + " " + client.name)
|
.join((client.mac + " " + client.name)
|
||||||
for client in active_clients))
|
for client in active_clients))
|
||||||
|
|
|
@ -67,10 +67,10 @@ class KeeneticNDMS2DeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return [device.mac for device in self.last_results]
|
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."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
filter_named = [device.name for device in self.last_results
|
filter_named = [result.name for result in self.last_results
|
||||||
if device.mac == mac]
|
if result.mac == device]
|
||||||
|
|
||||||
if filter_named:
|
if filter_named:
|
||||||
return filter_named[0]
|
return filter_named[0]
|
||||||
|
|
|
@ -62,7 +62,7 @@ class LinksysAPDeviceScanner(DeviceScanner):
|
||||||
return self.last_results
|
return self.last_results
|
||||||
|
|
||||||
# pylint: disable=no-self-use
|
# 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.
|
Return the name (if known) of the device.
|
||||||
|
|
||||||
|
|
|
@ -45,9 +45,9 @@ class LinksysSmartWifiDeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return self.last_results.keys()
|
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 the name (if known) of the device."""
|
||||||
return self.last_results.get(mac)
|
return self.last_results.get(device)
|
||||||
|
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
"""Check for connected devices."""
|
"""Check for connected devices."""
|
||||||
|
|
|
@ -85,7 +85,7 @@ class MerakiView(HomeAssistantView):
|
||||||
return self.json_message('Invalid device type',
|
return self.json_message('Invalid device type',
|
||||||
HTTP_UNPROCESSABLE_ENTITY)
|
HTTP_UNPROCESSABLE_ENTITY)
|
||||||
_LOGGER.debug("Processing %s", data['type'])
|
_LOGGER.debug("Processing %s", data['type'])
|
||||||
if len(data["data"]["observations"]) == 0:
|
if not data["data"]["observations"]:
|
||||||
_LOGGER.debug("No observations found")
|
_LOGGER.debug("No observations found")
|
||||||
return
|
return
|
||||||
self._handle(request.app['hass'], data)
|
self._handle(request.app['hass'], data)
|
||||||
|
@ -107,8 +107,7 @@ class MerakiView(HomeAssistantView):
|
||||||
|
|
||||||
if lat == "NaN" or lng == "NaN":
|
if lat == "NaN" or lng == "NaN":
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
"No coordinates received, skipping location for: " + mac
|
"No coordinates received, skipping location for: %s", mac)
|
||||||
)
|
|
||||||
gps_location = None
|
gps_location = None
|
||||||
accuracy = None
|
accuracy = None
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -137,9 +137,9 @@ class MikrotikScanner(DeviceScanner):
|
||||||
self._update_info()
|
self._update_info()
|
||||||
return [device for device in self.last_results]
|
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 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):
|
def _update_info(self):
|
||||||
"""Retrieve latest information from the Mikrotik box."""
|
"""Retrieve latest information from the Mikrotik box."""
|
||||||
|
|
|
@ -70,11 +70,11 @@ class NetgearDeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return (device.mac for device in self.last_results)
|
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."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
try:
|
try:
|
||||||
return next(device.name for device in self.last_results
|
return next(result.name for result in self.last_results
|
||||||
if device.mac == mac)
|
if result.mac == device)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -85,10 +85,10 @@ class NmapDeviceScanner(DeviceScanner):
|
||||||
|
|
||||||
return [device.mac for device in self.last_results]
|
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."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
filter_named = [device.name for device in self.last_results
|
filter_named = [result.name for result in self.last_results
|
||||||
if device.mac == mac]
|
if result.mac == device]
|
||||||
|
|
||||||
if filter_named:
|
if filter_named:
|
||||||
return filter_named[0]
|
return filter_named[0]
|
||||||
|
|
|
@ -83,10 +83,10 @@ class TadoDeviceScanner(DeviceScanner):
|
||||||
return [device.mac for device in self.last_results]
|
return [device.mac for device in self.last_results]
|
||||||
|
|
||||||
@asyncio.coroutine
|
@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."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
filter_named = [device.name for device in self.last_results
|
filter_named = [result.name for result in self.last_results
|
||||||
if device.mac == mac]
|
if result.mac == device]
|
||||||
|
|
||||||
if filter_named:
|
if filter_named:
|
||||||
return filter_named[0]
|
return filter_named[0]
|
||||||
|
|
|
@ -96,11 +96,11 @@ class UbusDeviceScanner(DeviceScanner):
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
@_refresh_on_access_denied
|
@_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."""
|
"""Return the name of the given device or None if we don't know."""
|
||||||
if self.mac2name is None:
|
if self.mac2name is None:
|
||||||
self._generate_mac2name()
|
self._generate_mac2name()
|
||||||
name = self.mac2name.get(mac.upper(), None)
|
name = self.mac2name.get(device.upper(), None)
|
||||||
return name
|
return name
|
||||||
|
|
||||||
@_refresh_on_access_denied
|
@_refresh_on_access_denied
|
||||||
|
|
|
@ -101,13 +101,13 @@ class UnifiScanner(DeviceScanner):
|
||||||
self._update()
|
self._update()
|
||||||
return self._clients.keys()
|
return self._clients.keys()
|
||||||
|
|
||||||
def get_device_name(self, mac):
|
def get_device_name(self, device):
|
||||||
"""Return the name (if known) of the device.
|
"""Return the name (if known) of the device.
|
||||||
|
|
||||||
If a name has been set in Unifi, then return that, else
|
If a name has been set in Unifi, then return that, else
|
||||||
return the hostname if it has been detected.
|
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')
|
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
|
return name
|
||||||
|
|
|
@ -140,21 +140,20 @@ class Dominos():
|
||||||
if self.closest_store is None:
|
if self.closest_store is None:
|
||||||
_LOGGER.warning('Cannot get menu. Store may be closed')
|
_LOGGER.warning('Cannot get menu. Store may be closed')
|
||||||
return []
|
return []
|
||||||
else:
|
menu = self.closest_store.get_menu()
|
||||||
menu = self.closest_store.get_menu()
|
product_entries = []
|
||||||
product_entries = []
|
|
||||||
|
|
||||||
for product in menu.products:
|
for product in menu.products:
|
||||||
item = {}
|
item = {}
|
||||||
if isinstance(product.menu_data['Variants'], list):
|
if isinstance(product.menu_data['Variants'], list):
|
||||||
variants = ', '.join(product.menu_data['Variants'])
|
variants = ', '.join(product.menu_data['Variants'])
|
||||||
else:
|
else:
|
||||||
variants = product.menu_data['Variants']
|
variants = product.menu_data['Variants']
|
||||||
item['name'] = product.name
|
item['name'] = product.name
|
||||||
item['variants'] = variants
|
item['variants'] = variants
|
||||||
product_entries.append(item)
|
product_entries.append(item)
|
||||||
|
|
||||||
return product_entries
|
return product_entries
|
||||||
|
|
||||||
|
|
||||||
class DominosProductListView(http.HomeAssistantView):
|
class DominosProductListView(http.HomeAssistantView):
|
||||||
|
@ -203,8 +202,7 @@ class DominosOrder(Entity):
|
||||||
"""Return the state either closed, orderable or unorderable."""
|
"""Return the state either closed, orderable or unorderable."""
|
||||||
if self.dominos.closest_store is None:
|
if self.dominos.closest_store is None:
|
||||||
return 'closed'
|
return 'closed'
|
||||||
else:
|
return 'orderable' if self._orderable else 'unorderable'
|
||||||
return 'orderable' if self._orderable else 'unorderable'
|
|
||||||
|
|
||||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||||
def update(self):
|
def update(self):
|
||||||
|
|
|
@ -118,7 +118,7 @@ SERVICE_TO_METHOD = {
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Return if the fans are on based on the statemachine."""
|
||||||
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
entity_id = entity_id or ENTITY_ID_ALL_FANS
|
||||||
state = hass.states.get(entity_id)
|
state = hass.states.get(entity_id)
|
||||||
|
@ -126,7 +126,7 @@ def is_on(hass, entity_id: str=None) -> bool:
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Turn all or specified fan on."""
|
||||||
data = {
|
data = {
|
||||||
key: value for key, value in [
|
key: value for key, value in [
|
||||||
|
@ -139,7 +139,7 @@ def turn_on(hass, entity_id: str=None, speed: str=None) -> None:
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Turn all or specified fan off."""
|
||||||
data = {ATTR_ENTITY_ID: entity_id} if entity_id else {}
|
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
|
@bind_hass
|
||||||
def toggle(hass, entity_id: str=None) -> None:
|
def toggle(hass, entity_id: str = None) -> None:
|
||||||
"""Toggle all or specified fans."""
|
"""Toggle all or specified fans."""
|
||||||
data = {
|
data = {
|
||||||
ATTR_ENTITY_ID: entity_id
|
ATTR_ENTITY_ID: entity_id
|
||||||
|
@ -157,7 +157,8 @@ def toggle(hass, entity_id: str=None) -> None:
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Set oscillation on all or specified fan."""
|
||||||
data = {
|
data = {
|
||||||
key: value for key, value in [
|
key: value for key, value in [
|
||||||
|
@ -170,7 +171,7 @@ def oscillate(hass, entity_id: str=None, should_oscillate: bool=True) -> None:
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Set speed for all or specified fan."""
|
||||||
data = {
|
data = {
|
||||||
key: value for key, value in [
|
key: value for key, value in [
|
||||||
|
@ -183,7 +184,7 @@ def set_speed(hass, entity_id: str=None, speed: str=None) -> None:
|
||||||
|
|
||||||
|
|
||||||
@bind_hass
|
@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."""
|
"""Set direction for all or specified fan."""
|
||||||
data = {
|
data = {
|
||||||
key: value for key, value in [
|
key: value for key, value in [
|
||||||
|
@ -258,11 +259,13 @@ class FanEntity(ToggleEntity):
|
||||||
"""
|
"""
|
||||||
return self.hass.async_add_job(self.set_direction, direction)
|
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."""
|
"""Turn on the fan."""
|
||||||
raise NotImplementedError()
|
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.
|
"""Turn on the fan.
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
|
|
|
@ -87,7 +87,7 @@ class ComfoConnectFan(FanEntity):
|
||||||
"""List of available fan modes."""
|
"""List of available fan modes."""
|
||||||
return [SPEED_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
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."""
|
"""Turn on the fan."""
|
||||||
if speed is None:
|
if speed is None:
|
||||||
speed = SPEED_LOW
|
speed = SPEED_LOW
|
||||||
|
@ -97,21 +97,21 @@ class ComfoConnectFan(FanEntity):
|
||||||
"""Turn off the fan (to away)."""
|
"""Turn off the fan (to away)."""
|
||||||
self.set_speed(SPEED_OFF)
|
self.set_speed(SPEED_OFF)
|
||||||
|
|
||||||
def set_speed(self, mode):
|
def set_speed(self, speed: str):
|
||||||
"""Set fan speed."""
|
"""Set fan speed."""
|
||||||
_LOGGER.debug('Changing fan mode to %s.', mode)
|
_LOGGER.debug('Changing fan speed to %s.', speed)
|
||||||
|
|
||||||
from pycomfoconnect import (
|
from pycomfoconnect import (
|
||||||
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
|
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
|
||||||
CMD_FAN_MODE_HIGH)
|
CMD_FAN_MODE_HIGH)
|
||||||
|
|
||||||
if mode == SPEED_OFF:
|
if speed == SPEED_OFF:
|
||||||
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)
|
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)
|
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)
|
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)
|
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_HIGH)
|
||||||
|
|
||||||
# Update current mode
|
# Update current mode
|
||||||
|
|
|
@ -59,13 +59,13 @@ class DemoFan(FanEntity):
|
||||||
"""Get the list of available speeds."""
|
"""Get the list of available speeds."""
|
||||||
return [STATE_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
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."""
|
"""Turn on the entity."""
|
||||||
if speed is None:
|
if speed is None:
|
||||||
speed = SPEED_MEDIUM
|
speed = SPEED_MEDIUM
|
||||||
self.set_speed(speed)
|
self.set_speed(speed)
|
||||||
|
|
||||||
def turn_off(self) -> None:
|
def turn_off(self, **kwargs) -> None:
|
||||||
"""Turn off the entity."""
|
"""Turn off the entity."""
|
||||||
self.oscillate(False)
|
self.oscillate(False)
|
||||||
self.set_speed(STATE_OFF)
|
self.set_speed(STATE_OFF)
|
||||||
|
|
|
@ -113,7 +113,7 @@ class DysonPureCoolLinkDevice(FanEntity):
|
||||||
self._device.set_configuration(
|
self._device.set_configuration(
|
||||||
fan_mode=FanMode.FAN, fan_speed=fan_speed)
|
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."""
|
"""Turn on the fan."""
|
||||||
from libpurecoollink.const import FanSpeed, FanMode
|
from libpurecoollink.const import FanSpeed, FanMode
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ class InsteonLocalFanDevice(FanEntity):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_INSTEON_LOCAL
|
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."""
|
"""Turn device on."""
|
||||||
if speed is None:
|
if speed is None:
|
||||||
if ATTR_SPEED in kwargs:
|
if ATTR_SPEED in kwargs:
|
||||||
|
|
|
@ -48,10 +48,6 @@ def setup_platform(hass, config: ConfigType,
|
||||||
class ISYFanDevice(ISYDevice, FanEntity):
|
class ISYFanDevice(ISYDevice, FanEntity):
|
||||||
"""Representation of an ISY994 fan device."""
|
"""Representation of an ISY994 fan device."""
|
||||||
|
|
||||||
def __init__(self, node) -> None:
|
|
||||||
"""Initialize the ISY994 fan device."""
|
|
||||||
super().__init__(node)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def speed(self) -> str:
|
def speed(self) -> str:
|
||||||
"""Return the current speed."""
|
"""Return the current speed."""
|
||||||
|
@ -66,7 +62,7 @@ class ISYFanDevice(ISYDevice, FanEntity):
|
||||||
"""Send the set speed command to the ISY994 fan device."""
|
"""Send the set speed command to the ISY994 fan device."""
|
||||||
self._node.on(val=STATE_TO_VALUE.get(speed, 255))
|
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."""
|
"""Send the turn on command to the ISY994 fan device."""
|
||||||
self.set_speed(speed)
|
self.set_speed(speed)
|
||||||
|
|
||||||
|
@ -99,7 +95,7 @@ class ISYFanProgram(ISYFanDevice):
|
||||||
if not self._actions.runThen():
|
if not self._actions.runThen():
|
||||||
_LOGGER.error("Unable to turn off the fan")
|
_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."""
|
"""Send the turn off command to ISY994 fan program."""
|
||||||
if not self._actions.runElse():
|
if not self._actions.runElse():
|
||||||
_LOGGER.error("Unable to turn on the fan")
|
_LOGGER.error("Unable to turn on the fan")
|
||||||
|
|
|
@ -252,7 +252,7 @@ class MqttFan(MqttAvailability, FanEntity):
|
||||||
return self._oscillation
|
return self._oscillation
|
||||||
|
|
||||||
@asyncio.coroutine
|
@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.
|
"""Turn on the entity.
|
||||||
|
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
|
@ -264,7 +264,7 @@ class MqttFan(MqttAvailability, FanEntity):
|
||||||
yield from self.async_set_speed(speed)
|
yield from self.async_set_speed(speed)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_turn_off(self) -> None:
|
def async_turn_off(self, **kwargs) -> None:
|
||||||
"""Turn off the entity.
|
"""Turn off the entity.
|
||||||
|
|
||||||
This method is a coroutine.
|
This method is a coroutine.
|
||||||
|
|
|
@ -128,13 +128,13 @@ class VelbusFan(FanEntity):
|
||||||
"""Get the list of available speeds."""
|
"""Get the list of available speeds."""
|
||||||
return [STATE_OFF, SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH]
|
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."""
|
"""Turn on the entity."""
|
||||||
if speed is None:
|
if speed is None:
|
||||||
speed = SPEED_MEDIUM
|
speed = SPEED_MEDIUM
|
||||||
self.set_speed(speed)
|
self.set_speed(speed)
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn off the entity."""
|
"""Turn off the entity."""
|
||||||
self.set_speed(STATE_OFF)
|
self.set_speed(STATE_OFF)
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ class WinkFanDevice(WinkDevice, FanEntity):
|
||||||
"""Set the speed of the fan."""
|
"""Set the speed of the fan."""
|
||||||
self.wink.set_state(True, speed)
|
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."""
|
"""Turn on the fan."""
|
||||||
self.wink.set_state(True, speed)
|
self.wink.set_state(True, speed)
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,7 @@ class XiaomiAirPurifier(FanEntity):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@asyncio.coroutine
|
@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."""
|
"""Turn the fan on."""
|
||||||
if speed:
|
if speed:
|
||||||
# If operation mode was set the device must not be turned on.
|
# If operation mode was set the device must not be turned on.
|
||||||
|
@ -283,7 +283,7 @@ class XiaomiAirPurifier(FanEntity):
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_speed(self: ToggleEntity, speed: str) -> None:
|
def async_set_speed(self: ToggleEntity, speed: str) -> None:
|
||||||
"""Set the speed of the fan."""
|
"""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
|
from miio.airpurifier import OperationMode
|
||||||
|
|
||||||
yield from self._try_command(
|
yield from self._try_command(
|
||||||
|
@ -333,7 +333,7 @@ class XiaomiAirPurifier(FanEntity):
|
||||||
self._air_purifier.set_child_lock, False)
|
self._air_purifier.set_child_lock, False)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_led_brightness(self, brightness: int=2):
|
def async_set_led_brightness(self, brightness: int = 2):
|
||||||
"""Set the led brightness."""
|
"""Set the led brightness."""
|
||||||
from miio.airpurifier import LedBrightness
|
from miio.airpurifier import LedBrightness
|
||||||
|
|
||||||
|
@ -342,7 +342,7 @@ class XiaomiAirPurifier(FanEntity):
|
||||||
self._air_purifier.set_led_brightness, LedBrightness(brightness))
|
self._air_purifier.set_led_brightness, LedBrightness(brightness))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_favorite_level(self, level: int=1):
|
def async_set_favorite_level(self, level: int = 1):
|
||||||
"""Set the favorite level."""
|
"""Set the favorite level."""
|
||||||
yield from self._try_command(
|
yield from self._try_command(
|
||||||
"Setting the favorite level of the air purifier failed.",
|
"Setting the favorite level of the air purifier failed.",
|
||||||
|
|
|
@ -103,7 +103,7 @@ def process_wrong_login(request):
|
||||||
class IpBan(object):
|
class IpBan(object):
|
||||||
"""Represents banned IP address."""
|
"""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."""
|
"""Initialize IP Ban object."""
|
||||||
self.ip_address = ip_address(ip_ban)
|
self.ip_address = ip_address(ip_ban)
|
||||||
self.banned_at = banned_at or datetime.utcnow()
|
self.banned_at = banned_at or datetime.utcnow()
|
||||||
|
|
|
@ -14,7 +14,7 @@ class IHCDevice(Entity):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
||||||
product: Element=None) -> None:
|
product: Element = None) -> None:
|
||||||
"""Initialize IHC attributes."""
|
"""Initialize IHC attributes."""
|
||||||
self.ihc_controller = ihc_controller
|
self.ihc_controller = ihc_controller
|
||||||
self._name = name
|
self._name = name
|
||||||
|
|
|
@ -135,7 +135,7 @@ WeatherNode = namedtuple('WeatherNode', ('status', 'name', 'uom'))
|
||||||
|
|
||||||
|
|
||||||
def _check_for_node_def(hass: HomeAssistant, node,
|
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.
|
"""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
|
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,
|
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.
|
"""Check if the node matches the Insteon type for any domains.
|
||||||
|
|
||||||
This is for (presumably) every version of the ISY firmware, but only
|
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,
|
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.
|
"""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
|
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,
|
def _check_for_states_in_uom(hass: HomeAssistant, node,
|
||||||
single_domain: str=None,
|
single_domain: str = None,
|
||||||
states_list: list=None) -> bool:
|
states_list: list = None) -> bool:
|
||||||
"""Check if a list of uoms matches two possible filters.
|
"""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
|
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
|
pass
|
||||||
else:
|
else:
|
||||||
for dtype, _, node_id in folder.children:
|
for dtype, _, node_id in folder.children:
|
||||||
if dtype == KEY_FOLDER:
|
if dtype != KEY_FOLDER:
|
||||||
entity_folder = folder[node_id]
|
continue
|
||||||
try:
|
entity_folder = folder[node_id]
|
||||||
status = entity_folder[KEY_STATUS]
|
try:
|
||||||
assert status.dtype == 'program', 'Not a program'
|
status = entity_folder[KEY_STATUS]
|
||||||
if domain != 'binary_sensor':
|
assert status.dtype == 'program', 'Not a program'
|
||||||
actions = entity_folder[KEY_ACTIONS]
|
if domain != 'binary_sensor':
|
||||||
assert actions.dtype == 'program', 'Not a program'
|
actions = entity_folder[KEY_ACTIONS]
|
||||||
else:
|
assert actions.dtype == 'program', 'Not a program'
|
||||||
actions = None
|
else:
|
||||||
except (AttributeError, KeyError, AssertionError):
|
actions = None
|
||||||
_LOGGER.warning("Program entity '%s' not loaded due "
|
except (AttributeError, KeyError, AssertionError):
|
||||||
"to invalid folder structure.",
|
_LOGGER.warning("Program entity '%s' not loaded due "
|
||||||
entity_folder.name)
|
"to invalid folder structure.",
|
||||||
continue
|
entity_folder.name)
|
||||||
|
continue
|
||||||
|
|
||||||
entity = (entity_folder.name, status, actions)
|
entity = (entity_folder.name, status, actions)
|
||||||
hass.data[ISY994_PROGRAMS][domain].append(entity)
|
hass.data[ISY994_PROGRAMS][domain].append(entity)
|
||||||
|
|
||||||
|
|
||||||
def _categorize_weather(hass: HomeAssistant, climate) -> None:
|
def _categorize_weather(hass: HomeAssistant, climate) -> None:
|
||||||
|
@ -461,8 +463,7 @@ class ISYDevice(Entity):
|
||||||
"""Return the state of the ISY device."""
|
"""Return the state of the ISY device."""
|
||||||
if self.is_unknown():
|
if self.is_unknown():
|
||||||
return None
|
return None
|
||||||
else:
|
return super().state
|
||||||
return super().state
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_state_attributes(self) -> Dict:
|
def device_state_attributes(self) -> Dict:
|
||||||
|
|
|
@ -37,7 +37,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up an Avion switch."""
|
"""Set up an Avion switch."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import avion
|
import avion
|
||||||
|
|
||||||
lights = []
|
lights = []
|
||||||
|
@ -70,7 +70,7 @@ class AvionLight(Light):
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import avion
|
import avion
|
||||||
|
|
||||||
self._name = device['name']
|
self._name = device['name']
|
||||||
|
@ -117,7 +117,7 @@ class AvionLight(Light):
|
||||||
|
|
||||||
def set_state(self, brightness):
|
def set_state(self, brightness):
|
||||||
"""Set the state of this lamp to the provided brightness."""
|
"""Set the state of this lamp to the provided brightness."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import avion
|
import avion
|
||||||
|
|
||||||
# Bluetooth LE is unreliable, and the connection may drop at any
|
# Bluetooth LE is unreliable, and the connection may drop at any
|
||||||
|
|
|
@ -29,7 +29,7 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the Blinkt Light platform."""
|
"""Set up the Blinkt Light platform."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import blinkt
|
import blinkt
|
||||||
|
|
||||||
# ensure that the lights are off when exiting
|
# ensure that the lights are off when exiting
|
||||||
|
|
|
@ -37,7 +37,7 @@ def retry(method):
|
||||||
@wraps(method)
|
@wraps(method)
|
||||||
def wrapper_retry(device, *args, **kwargs):
|
def wrapper_retry(device, *args, **kwargs):
|
||||||
"""Try send command and retry on error."""
|
"""Try send command and retry on error."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import decora
|
import decora
|
||||||
import bluepy
|
import bluepy
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ class DecoraLight(Light):
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, device):
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error, no-member
|
||||||
import decora
|
import decora
|
||||||
|
|
||||||
self._name = device['name']
|
self._name = device['name']
|
||||||
|
|
|
@ -36,7 +36,7 @@ NOTIFICATION_TITLE = 'myLeviton Decora Setup'
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
"""Set up the Decora WiFi platform."""
|
"""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 import DecoraWiFiSession
|
||||||
from decora_wifi.models.person import Person
|
from decora_wifi.models.person import Person
|
||||||
from decora_wifi.models.residential_account import ResidentialAccount
|
from decora_wifi.models.residential_account import ResidentialAccount
|
||||||
|
@ -93,8 +93,7 @@ class DecoraWifiLight(Light):
|
||||||
"""Return supported features."""
|
"""Return supported features."""
|
||||||
if self._switch.canSetLevel:
|
if self._switch.canSetLevel:
|
||||||
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
return SUPPORT_BRIGHTNESS | SUPPORT_TRANSITION
|
||||||
else:
|
return 0
|
||||||
return 0
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -116,7 +116,7 @@ class HiveDeviceLight(Light):
|
||||||
for entity in self.session.entities:
|
for entity in self.session.entities:
|
||||||
entity.handle_update(self.data_updatesource)
|
entity.handle_update(self.data_updatesource)
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self, **kwargs):
|
||||||
"""Instruct the light to turn off."""
|
"""Instruct the light to turn off."""
|
||||||
self.session.light.turn_off(self.node_id)
|
self.session.light.turn_off(self.node_id)
|
||||||
for entity in self.session.entities:
|
for entity in self.session.entities:
|
||||||
|
|
|
@ -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:
|
if discovery_info is None or 'bridge_id' not in discovery_info:
|
||||||
return
|
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
|
# Legacy configuration, will be removed in 0.60
|
||||||
config_str = yaml.dump([config])
|
config_str = yaml.dump([config])
|
||||||
# Indent so it renders in a fixed-width font
|
# Indent so it renders in a fixed-width font
|
||||||
|
|
|
@ -64,7 +64,7 @@ class IhcLight(IHCDevice, Light):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, ihc_controller, name, ihc_id: int, info: bool,
|
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."""
|
"""Initialize the light."""
|
||||||
super().__init__(ihc_controller, name, ihc_id, info, product)
|
super().__init__(ihc_controller, name, ihc_id, info, product)
|
||||||
self._brightness = 0
|
self._brightness = 0
|
||||||
|
|
|
@ -29,10 +29,6 @@ def setup_platform(hass, config: ConfigType,
|
||||||
class ISYLightDevice(ISYDevice, Light):
|
class ISYLightDevice(ISYDevice, Light):
|
||||||
"""Representation of an ISY994 light device."""
|
"""Representation of an ISY994 light device."""
|
||||||
|
|
||||||
def __init__(self, node: object) -> None:
|
|
||||||
"""Initialize the ISY994 light device."""
|
|
||||||
super().__init__(node)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_on(self) -> bool:
|
def is_on(self) -> bool:
|
||||||
"""Get whether the ISY994 light is on."""
|
"""Get whether the ISY994 light is on."""
|
||||||
|
@ -48,6 +44,7 @@ class ISYLightDevice(ISYDevice, Light):
|
||||||
if not self._node.off():
|
if not self._node.off():
|
||||||
_LOGGER.debug("Unable to turn off light")
|
_LOGGER.debug("Unable to turn off light")
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
def turn_on(self, brightness=None, **kwargs) -> None:
|
def turn_on(self, brightness=None, **kwargs) -> None:
|
||||||
"""Send the turn on command to the ISY994 light device."""
|
"""Send the turn on command to the ISY994 light device."""
|
||||||
if not self._node.on(val=brightness):
|
if not self._node.on(val=brightness):
|
||||||
|
|
|
@ -198,6 +198,7 @@ class LimitlessLEDGroup(Light):
|
||||||
"""Return the brightness property."""
|
"""Return the brightness property."""
|
||||||
return self._brightness
|
return self._brightness
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
@state(False)
|
@state(False)
|
||||||
def turn_off(self, transition_time, pipeline, **kwargs):
|
def turn_off(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn off a group."""
|
"""Turn off a group."""
|
||||||
|
@ -231,6 +232,7 @@ class LimitlessLEDWhiteGroup(LimitlessLEDGroup):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_LIMITLESSLED_WHITE
|
return SUPPORT_LIMITLESSLED_WHITE
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
@state(True)
|
@state(True)
|
||||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn on (or adjust property of) a group."""
|
"""Turn on (or adjust property of) a group."""
|
||||||
|
@ -271,6 +273,7 @@ class LimitlessLEDRGBWGroup(LimitlessLEDGroup):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_LIMITLESSLED_RGB
|
return SUPPORT_LIMITLESSLED_RGB
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
@state(True)
|
@state(True)
|
||||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn on (or adjust property of) a group."""
|
"""Turn on (or adjust property of) a group."""
|
||||||
|
@ -337,6 +340,7 @@ class LimitlessLEDRGBWWGroup(LimitlessLEDGroup):
|
||||||
"""Flag supported features."""
|
"""Flag supported features."""
|
||||||
return SUPPORT_LIMITLESSLED_RGBWW
|
return SUPPORT_LIMITLESSLED_RGBWW
|
||||||
|
|
||||||
|
# pylint: disable=arguments-differ
|
||||||
@state(True)
|
@state(True)
|
||||||
def turn_on(self, transition_time, pipeline, **kwargs):
|
def turn_on(self, transition_time, pipeline, **kwargs):
|
||||||
"""Turn on (or adjust property of) a group."""
|
"""Turn on (or adjust property of) a group."""
|
||||||
|
|
|
@ -130,7 +130,7 @@ class MySensorsLight(mysensors.MySensorsEntity, Light):
|
||||||
self._white = white
|
self._white = white
|
||||||
self._values[self.value_type] = hex_color
|
self._values[self.value_type] = hex_color
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the device off."""
|
"""Turn the device off."""
|
||||||
value_type = self.gateway.const.SetReq.V_LIGHT
|
value_type = self.gateway.const.SetReq.V_LIGHT
|
||||||
self.gateway.set_child_value(
|
self.gateway.set_child_value(
|
||||||
|
|
|
@ -118,7 +118,7 @@ class TPLinkSmartBulb(Light):
|
||||||
rgb = kwargs.get(ATTR_RGB_COLOR)
|
rgb = kwargs.get(ATTR_RGB_COLOR)
|
||||||
self.smartbulb.hsv = rgb_to_hsv(rgb)
|
self.smartbulb.hsv = rgb_to_hsv(rgb)
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the light off."""
|
"""Turn the light off."""
|
||||||
self.smartbulb.state = self.smartbulb.BULB_STATE_OFF
|
self.smartbulb.state = self.smartbulb.BULB_STATE_OFF
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,6 @@ class WinkLight(WinkDevice, Light):
|
||||||
|
|
||||||
self.wink.set_state(True, **state_kwargs)
|
self.wink.set_state(True, **state_kwargs)
|
||||||
|
|
||||||
def turn_off(self):
|
def turn_off(self, **kwargs):
|
||||||
"""Turn the switch off."""
|
"""Turn the switch off."""
|
||||||
self.wink.set_state(False)
|
self.wink.set_state(False)
|
||||||
|
|
|
@ -242,7 +242,7 @@ class XiaomiPhilipsGenericLight(Light):
|
||||||
_LOGGER.error("Got exception while fetching the state: %s", ex)
|
_LOGGER.error("Got exception while fetching the state: %s", ex)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_scene(self, scene: int=1):
|
def async_set_scene(self, scene: int = 1):
|
||||||
"""Set the fixed scene."""
|
"""Set the fixed scene."""
|
||||||
yield from self._try_command(
|
yield from self._try_command(
|
||||||
"Setting a fixed scene failed.",
|
"Setting a fixed scene failed.",
|
||||||
|
@ -260,10 +260,6 @@ class XiaomiPhilipsGenericLight(Light):
|
||||||
class XiaomiPhilipsLightBall(XiaomiPhilipsGenericLight, Light):
|
class XiaomiPhilipsLightBall(XiaomiPhilipsGenericLight, Light):
|
||||||
"""Representation of a Xiaomi Philips Light Ball."""
|
"""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
|
@property
|
||||||
def color_temp(self):
|
def color_temp(self):
|
||||||
"""Return the color temperature."""
|
"""Return the color temperature."""
|
||||||
|
@ -345,10 +341,6 @@ class XiaomiPhilipsLightBall(XiaomiPhilipsGenericLight, Light):
|
||||||
class XiaomiPhilipsCeilingLamp(XiaomiPhilipsLightBall, Light):
|
class XiaomiPhilipsCeilingLamp(XiaomiPhilipsLightBall, Light):
|
||||||
"""Representation of a Xiaomi Philips Ceiling Lamp."""
|
"""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
|
@property
|
||||||
def min_mireds(self):
|
def min_mireds(self):
|
||||||
"""Return the coldest color_temp that this light supports."""
|
"""Return the coldest color_temp that this light supports."""
|
||||||
|
@ -363,6 +355,4 @@ class XiaomiPhilipsCeilingLamp(XiaomiPhilipsLightBall, Light):
|
||||||
class XiaomiPhilipsEyecareLamp(XiaomiPhilipsGenericLight, Light):
|
class XiaomiPhilipsEyecareLamp(XiaomiPhilipsGenericLight, Light):
|
||||||
"""Representation of a Xiaomi Philips Eyecare Lamp 2."""
|
"""Representation of a Xiaomi Philips Eyecare Lamp 2."""
|
||||||
|
|
||||||
def __init__(self, name, light, device_info):
|
pass
|
||||||
"""Initialize the light device."""
|
|
||||||
super().__init__(name, light, device_info)
|
|
||||||
|
|
|
@ -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
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/lirc/
|
https://home-assistant.io/components/lirc/
|
||||||
"""
|
"""
|
||||||
# pylint: disable=import-error
|
# pylint: disable=import-error,no-member
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
|
|
@ -53,8 +53,7 @@ class ISYLockDevice(ISYDevice, LockDevice):
|
||||||
"""Get the state of the lock."""
|
"""Get the state of the lock."""
|
||||||
if self.is_unknown():
|
if self.is_unknown():
|
||||||
return None
|
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:
|
def lock(self, **kwargs) -> None:
|
||||||
"""Send the lock command to the ISY994 device."""
|
"""Send the lock command to the ISY994 device."""
|
||||||
|
|
|
@ -85,7 +85,7 @@ class MediaExtractor(object):
|
||||||
else:
|
else:
|
||||||
entities = self.get_entities()
|
entities = self.get_entities()
|
||||||
|
|
||||||
if len(entities) == 0:
|
if not entities:
|
||||||
self.call_media_player_service(stream_selector, None)
|
self.call_media_player_service(stream_selector, None)
|
||||||
|
|
||||||
for entity_id in entities:
|
for entity_id in entities:
|
||||||
|
@ -108,7 +108,7 @@ class MediaExtractor(object):
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Playlists are not supported, looking for the first video")
|
"Playlists are not supported, looking for the first video")
|
||||||
entries = list(all_media['entries'])
|
entries = list(all_media['entries'])
|
||||||
if len(entries) > 0:
|
if entries:
|
||||||
selected_media = entries[0]
|
selected_media = entries[0]
|
||||||
else:
|
else:
|
||||||
_LOGGER.error("Playlist is empty")
|
_LOGGER.error("Playlist is empty")
|
||||||
|
|
|
@ -201,9 +201,9 @@ class SharpAquosTVDevice(MediaPlayerDevice):
|
||||||
self._remote.volume(int(self._volume * 60) - 2)
|
self._remote.volume(int(self._volume * 60) - 2)
|
||||||
|
|
||||||
@_retry
|
@_retry
|
||||||
def set_volume_level(self, level):
|
def set_volume_level(self, volume):
|
||||||
"""Set Volume media player."""
|
"""Set Volume media player."""
|
||||||
self._remote.volume(int(level * 60))
|
self._remote.volume(int(volume * 60))
|
||||||
|
|
||||||
@_retry
|
@_retry
|
||||||
def mute_volume(self, mute):
|
def mute_volume(self, mute):
|
||||||
|
|
|
@ -440,8 +440,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
||||||
return STATE_PAUSED
|
return STATE_PAUSED
|
||||||
elif status == 'stream' or status == 'play':
|
elif status == 'stream' or status == 'play':
|
||||||
return STATE_PLAYING
|
return STATE_PLAYING
|
||||||
else:
|
return STATE_IDLE
|
||||||
return STATE_IDLE
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
@ -595,7 +594,7 @@ class BluesoundPlayer(MediaPlayerDevice):
|
||||||
# But it works with radio service_items will catch playlists.
|
# But it works with radio service_items will catch playlists.
|
||||||
items = [x for x in self._preset_items if 'url2' in x and
|
items = [x for x in self._preset_items if 'url2' in x and
|
||||||
parse.unquote(x['url2']) == stream_url]
|
parse.unquote(x['url2']) == stream_url]
|
||||||
if len(items) > 0:
|
if items:
|
||||||
return items[0]['title']
|
return items[0]['title']
|
||||||
|
|
||||||
# This could be a bit difficult to detect. Bluetooth could be named
|
# 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':
|
if title == 'bluetooth' or stream_url == 'Capture:hw:2,0/44100/16/2':
|
||||||
items = [x for x in self._capture_items
|
items = [x for x in self._capture_items
|
||||||
if x['url'] == "Capture%3Abluez%3Abluetooth"]
|
if x['url'] == "Capture%3Abluez%3Abluetooth"]
|
||||||
if len(items) > 0:
|
if items:
|
||||||
return items[0]['title']
|
return items[0]['title']
|
||||||
|
|
||||||
items = [x for x in self._capture_items if x['url'] == stream_url]
|
items = [x for x in self._capture_items if x['url'] == stream_url]
|
||||||
if len(items) > 0:
|
if items:
|
||||||
return items[0]['title']
|
return items[0]['title']
|
||||||
|
|
||||||
if stream_url[:8] == 'Capture:':
|
if stream_url[:8] == 'Capture:':
|
||||||
|
@ -631,12 +630,12 @@ class BluesoundPlayer(MediaPlayerDevice):
|
||||||
|
|
||||||
items = [x for x in self._capture_items
|
items = [x for x in self._capture_items
|
||||||
if x['name'] == current_service]
|
if x['name'] == current_service]
|
||||||
if len(items) > 0:
|
if items:
|
||||||
return items[0]['title']
|
return items[0]['title']
|
||||||
|
|
||||||
items = [x for x in self._services_items
|
items = [x for x in self._services_items
|
||||||
if x['name'] == current_service]
|
if x['name'] == current_service]
|
||||||
if len(items) > 0:
|
if items:
|
||||||
return items[0]['title']
|
return items[0]['title']
|
||||||
|
|
||||||
if self._status.get('streamUrl', '') != '':
|
if self._status.get('streamUrl', '') != '':
|
||||||
|
|
|
@ -87,7 +87,7 @@ class CecPlayerDevice(CecDevice, MediaPlayerDevice):
|
||||||
self.send_keypress(KEY_STOP)
|
self.send_keypress(KEY_STOP)
|
||||||
self._state = STATE_IDLE
|
self._state = STATE_IDLE
|
||||||
|
|
||||||
def play_media(self, media_type, media_id):
|
def play_media(self, media_type, media_id, **kwargs):
|
||||||
"""Not supported."""
|
"""Not supported."""
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
|
|
|
@ -182,8 +182,7 @@ class MpdDevice(MediaPlayerDevice):
|
||||||
if name is None and title is None:
|
if name is None and title is None:
|
||||||
if file_name is None:
|
if file_name is None:
|
||||||
return "None"
|
return "None"
|
||||||
else:
|
return os.path.basename(file_name)
|
||||||
return os.path.basename(file_name)
|
|
||||||
elif name is None:
|
elif name is None:
|
||||||
return title
|
return title
|
||||||
elif title is None:
|
elif title is None:
|
||||||
|
|
|
@ -296,7 +296,7 @@ class SoundTouchDevice(MediaPlayerDevice):
|
||||||
|
|
||||||
def play_media(self, media_type, media_id, **kwargs):
|
def play_media(self, media_type, media_id, **kwargs):
|
||||||
"""Play a piece of media."""
|
"""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)):
|
if re.match(r'http://', str(media_id)):
|
||||||
# URL
|
# URL
|
||||||
_LOGGER.debug("Playing URL %s", str(media_id))
|
_LOGGER.debug("Playing URL %s", str(media_id))
|
||||||
|
@ -307,11 +307,10 @@ class SoundTouchDevice(MediaPlayerDevice):
|
||||||
preset = next([preset for preset in presets if
|
preset = next([preset for preset in presets if
|
||||||
preset.preset_id == str(media_id)].__iter__(), None)
|
preset.preset_id == str(media_id)].__iter__(), None)
|
||||||
if preset is not None:
|
if preset is not None:
|
||||||
_LOGGER.debug("Playing preset: " + preset.name)
|
_LOGGER.debug("Playing preset: %s", preset.name)
|
||||||
self._device.select_preset(preset)
|
self._device.select_preset(preset)
|
||||||
else:
|
else:
|
||||||
_LOGGER.warning(
|
_LOGGER.warning("Unable to find preset with id %s", media_id)
|
||||||
"Unable to find preset with id " + str(media_id))
|
|
||||||
|
|
||||||
def create_zone(self, slaves):
|
def create_zone(self, slaves):
|
||||||
"""
|
"""
|
||||||
|
@ -323,8 +322,8 @@ class SoundTouchDevice(MediaPlayerDevice):
|
||||||
if not slaves:
|
if not slaves:
|
||||||
_LOGGER.warning("Unable to create zone without slaves")
|
_LOGGER.warning("Unable to create zone without slaves")
|
||||||
else:
|
else:
|
||||||
_LOGGER.info(
|
_LOGGER.info("Creating zone with master %s",
|
||||||
"Creating zone with master " + str(self.device.config.name))
|
self.device.config.name)
|
||||||
self.device.create_zone([slave.device for slave in slaves])
|
self.device.create_zone([slave.device for slave in slaves])
|
||||||
|
|
||||||
def remove_zone_slave(self, slaves):
|
def remove_zone_slave(self, slaves):
|
||||||
|
@ -341,8 +340,8 @@ class SoundTouchDevice(MediaPlayerDevice):
|
||||||
if not slaves:
|
if not slaves:
|
||||||
_LOGGER.warning("Unable to find slaves to remove")
|
_LOGGER.warning("Unable to find slaves to remove")
|
||||||
else:
|
else:
|
||||||
_LOGGER.info("Removing slaves from zone with master " +
|
_LOGGER.info("Removing slaves from zone with master %s",
|
||||||
str(self.device.config.name))
|
self.device.config.name)
|
||||||
self.device.remove_zone_slave([slave.device for slave in slaves])
|
self.device.remove_zone_slave([slave.device for slave in slaves])
|
||||||
|
|
||||||
def add_zone_slave(self, slaves):
|
def add_zone_slave(self, slaves):
|
||||||
|
@ -357,7 +356,6 @@ class SoundTouchDevice(MediaPlayerDevice):
|
||||||
if not slaves:
|
if not slaves:
|
||||||
_LOGGER.warning("Unable to find slaves to add")
|
_LOGGER.warning("Unable to find slaves to add")
|
||||||
else:
|
else:
|
||||||
_LOGGER.info(
|
_LOGGER.info("Adding slaves to zone with master %s",
|
||||||
"Adding slaves to zone with master " + str(
|
self.device.config.name)
|
||||||
self.device.config.name))
|
|
||||||
self.device.add_zone_slave([slave.device for slave in slaves])
|
self.device.add_zone_slave([slave.device for slave in slaves])
|
||||||
|
|
|
@ -270,8 +270,7 @@ class LgWebOSDevice(MediaPlayerDevice):
|
||||||
"""Title of current playing media."""
|
"""Title of current playing media."""
|
||||||
if (self._channel is not None) and ('channelName' in self._channel):
|
if (self._channel is not None) and ('channelName' in self._channel):
|
||||||
return self._channel['channelName']
|
return self._channel['channelName']
|
||||||
else:
|
return None
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_image_url(self):
|
def media_image_url(self):
|
||||||
|
|
|
@ -136,7 +136,7 @@ def _load_config(filename):
|
||||||
class JSONBytesDecoder(json.JSONEncoder):
|
class JSONBytesDecoder(json.JSONEncoder):
|
||||||
"""JSONEncoder to decode bytes objects to unicode."""
|
"""JSONEncoder to decode bytes objects to unicode."""
|
||||||
|
|
||||||
# pylint: disable=method-hidden
|
# pylint: disable=method-hidden, arguments-differ
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
"""Decode object if it's a bytes object, else defer to base class."""
|
"""Decode object if it's a bytes object, else defer to base class."""
|
||||||
if isinstance(obj, bytes):
|
if isinstance(obj, bytes):
|
||||||
|
|
|
@ -56,4 +56,4 @@ class AutomateNotificationService(BaseNotificationService):
|
||||||
|
|
||||||
response = requests.post(_RESOURCE, json=data)
|
response = requests.post(_RESOURCE, json=data)
|
||||||
if response.status_code != 200:
|
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
Loading…
Add table
Add a link
Reference in a new issue