Fix some issues for PyLint 1.7.2 (#8356)
* Fix some issues for PyLint 1.7.2 * More fixes * Revert position change for cover
This commit is contained in:
parent
83a5f932d1
commit
5779d64e98
66 changed files with 176 additions and 272 deletions
|
@ -229,8 +229,8 @@ def cmdline() -> List[str]:
|
|||
os.environ['PYTHONPATH'] = os.path.dirname(modulepath)
|
||||
return [sys.executable] + [arg for arg in sys.argv if
|
||||
arg != '--daemon']
|
||||
else:
|
||||
return [arg for arg in sys.argv if arg != '--daemon']
|
||||
|
||||
return [arg for arg in sys.argv if arg != '--daemon']
|
||||
|
||||
|
||||
def setup_and_run_hass(config_dir: str,
|
||||
|
|
|
@ -39,19 +39,19 @@ def is_on(hass, entity_id=None):
|
|||
else:
|
||||
entity_ids = hass.states.entity_ids()
|
||||
|
||||
for entity_id in entity_ids:
|
||||
domain = ha.split_entity_id(entity_id)[0]
|
||||
for ent_id in entity_ids:
|
||||
domain = ha.split_entity_id(ent_id)[0]
|
||||
|
||||
module = get_component(domain)
|
||||
|
||||
try:
|
||||
if module.is_on(hass, entity_id):
|
||||
if module.is_on(hass, ent_id):
|
||||
return True
|
||||
|
||||
except AttributeError:
|
||||
# module is None or method is_on does not exist
|
||||
_LOGGER.exception("Failed to call %s.is_on for %s",
|
||||
module, entity_id)
|
||||
module, ent_id)
|
||||
|
||||
return False
|
||||
|
||||
|
|
|
@ -39,10 +39,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class WinkCameraDevice(WinkDevice, alarm.AlarmControlPanel):
|
||||
"""Representation a Wink camera alarm."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink alarm."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Callback when entity is added to hass."""
|
||||
|
|
|
@ -271,14 +271,14 @@ class Alert(ToggleEntity):
|
|||
'notify', target, {'message': self._done_message})
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_on(self):
|
||||
def async_turn_on(self, **kwargs):
|
||||
"""Async Unacknowledge alert."""
|
||||
_LOGGER.debug("Reset Alert: %s", self._name)
|
||||
self._ack = False
|
||||
yield from self.async_update_ha_state()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_off(self):
|
||||
def async_turn_off(self, **kwargs):
|
||||
"""Async Acknowledge alert."""
|
||||
_LOGGER.debug("Acknowledged Alert: %s", self._name)
|
||||
self._ack = True
|
||||
|
|
|
@ -198,8 +198,7 @@ class APIEntityStateView(HomeAssistantView):
|
|||
state = request.app['hass'].states.get(entity_id)
|
||||
if state:
|
||||
return self.json(state)
|
||||
else:
|
||||
return self.json_message('Entity not found', HTTP_NOT_FOUND)
|
||||
return self.json_message('Entity not found', HTTP_NOT_FOUND)
|
||||
|
||||
@asyncio.coroutine
|
||||
def post(self, request, entity_id):
|
||||
|
@ -237,8 +236,7 @@ class APIEntityStateView(HomeAssistantView):
|
|||
"""Remove entity."""
|
||||
if request.app['hass'].states.async_remove(entity_id):
|
||||
return self.json_message('Entity removed')
|
||||
else:
|
||||
return self.json_message('Entity not found', HTTP_NOT_FOUND)
|
||||
return self.json_message('Entity not found', HTTP_NOT_FOUND)
|
||||
|
||||
|
||||
class APIEventListenersView(HomeAssistantView):
|
||||
|
|
|
@ -42,8 +42,6 @@ def async_trigger(hass, config, action):
|
|||
},
|
||||
})
|
||||
|
||||
# Do something to call action
|
||||
if event == SUN_EVENT_SUNRISE:
|
||||
return async_track_sunrise(hass, call_action, offset)
|
||||
else:
|
||||
return async_track_sunset(hass, call_action, offset)
|
||||
return async_track_sunset(hass, call_action, offset)
|
||||
|
|
|
@ -68,7 +68,7 @@ class ArestBinarySensor(BinarySensorDevice):
|
|||
if self._pin is not None:
|
||||
request = requests.get(
|
||||
'{}/mode/{}/i'.format(self._resource, self._pin), timeout=10)
|
||||
if request.status_code is not 200:
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode of %s", self._resource)
|
||||
|
||||
@property
|
||||
|
|
|
@ -121,10 +121,6 @@ class WinkBinarySensorDevice(WinkDevice, BinarySensorDevice, Entity):
|
|||
class WinkSmokeDetector(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Smoke detector."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
@ -136,10 +132,6 @@ class WinkSmokeDetector(WinkBinarySensorDevice):
|
|||
class WinkHub(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Hub."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
@ -152,10 +144,6 @@ class WinkHub(WinkBinarySensorDevice):
|
|||
class WinkRemote(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Lutron Connected bulb remote."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
@ -175,10 +163,6 @@ class WinkRemote(WinkBinarySensorDevice):
|
|||
class WinkButton(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Relay button."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
|
@ -191,10 +175,6 @@ class WinkButton(WinkBinarySensorDevice):
|
|||
class WinkGang(WinkBinarySensorDevice):
|
||||
"""Representation of a Wink Relay gang."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink binary sensor."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if the gang is connected."""
|
||||
|
|
|
@ -54,7 +54,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
_LOGGER.error("Unable to connect to NVR: %s", str(ex))
|
||||
return False
|
||||
|
||||
identifier = nvrconn.server_version >= (3, 2, 0) and 'id' or 'uuid'
|
||||
identifier = 'id' if nvrconn.server_version >= (3, 2, 0) else 'uuid'
|
||||
# Filter out airCam models, which are not supported in the latest
|
||||
# version of UnifiVideo and which are EOL by Ubiquiti
|
||||
cameras = [
|
||||
|
|
|
@ -46,8 +46,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
return
|
||||
|
||||
devices = []
|
||||
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMThermostat(hass, config)
|
||||
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMThermostat(hass, conf)
|
||||
new_device.link_homematic()
|
||||
devices.append(new_device)
|
||||
|
||||
|
|
|
@ -119,14 +119,14 @@ class NetatmoThermostat(ClimateDevice):
|
|||
self._data.thermostatdata.setthermpoint(mode, temp, endTimeOffset=None)
|
||||
self._away = False
|
||||
|
||||
def set_temperature(self, endTimeOffset=DEFAULT_TIME_OFFSET, **kwargs):
|
||||
def set_temperature(self, **kwargs):
|
||||
"""Set new target temperature for 2 hours."""
|
||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||
if temperature is None:
|
||||
return
|
||||
mode = "manual"
|
||||
self._data.thermostatdata.setthermpoint(
|
||||
mode, temperature, endTimeOffset)
|
||||
mode, temperature, DEFAULT_TIME_OFFSET)
|
||||
self._target_temperature = temperature
|
||||
self._away = False
|
||||
|
||||
|
|
|
@ -29,20 +29,16 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class WinkCoverDevice(WinkDevice, CoverDevice):
|
||||
"""Representation of a Wink cover device."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the cover."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Callback when entity is added to hass."""
|
||||
self.hass.data[DOMAIN]['entities']['cover'].append(self)
|
||||
|
||||
def close_cover(self):
|
||||
def close_cover(self, **kwargs):
|
||||
"""Close the shade."""
|
||||
self.wink.set_state(0)
|
||||
|
||||
def open_cover(self):
|
||||
def open_cover(self, **kwargs):
|
||||
"""Open the shade."""
|
||||
self.wink.set_state(1)
|
||||
|
||||
|
|
|
@ -87,21 +87,20 @@ class CiscoDeviceScanner(DeviceScanner):
|
|||
lines_result = lines_result[2:]
|
||||
|
||||
for line in lines_result:
|
||||
if len(line.split()) is 6:
|
||||
parts = line.split()
|
||||
if len(parts) != 6:
|
||||
continue
|
||||
parts = line.split()
|
||||
if len(parts) != 6:
|
||||
continue
|
||||
|
||||
# ['Internet', '10.10.11.1', '-', '0027.d32d.0123', 'ARPA',
|
||||
# 'GigabitEthernet0']
|
||||
age = parts[2]
|
||||
hw_addr = parts[3]
|
||||
# ['Internet', '10.10.11.1', '-', '0027.d32d.0123', 'ARPA',
|
||||
# 'GigabitEthernet0']
|
||||
age = parts[2]
|
||||
hw_addr = parts[3]
|
||||
|
||||
if age != "-":
|
||||
mac = _parse_cisco_mac_address(hw_addr)
|
||||
age = int(age)
|
||||
if age < 1:
|
||||
last_results.append(mac)
|
||||
if age != "-":
|
||||
mac = _parse_cisco_mac_address(hw_addr)
|
||||
age = int(age)
|
||||
if age < 1:
|
||||
last_results.append(mac)
|
||||
|
||||
self.last_results = last_results
|
||||
return True
|
||||
|
|
|
@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
insteonhub = hass.data['insteon_local']
|
||||
|
||||
conf_fans = config_from_file(hass.config.path(INSTEON_LOCAL_FANS_CONF))
|
||||
if len(conf_fans):
|
||||
if conf_fans:
|
||||
for device_id in conf_fans:
|
||||
setup_fan(device_id, conf_fans[device_id], insteonhub, hass,
|
||||
add_devices)
|
||||
|
|
|
@ -161,8 +161,8 @@ def states_to_json(hass, states, start_time, entity_id, filters=None):
|
|||
result[state.entity_id].append(state)
|
||||
|
||||
# Append all changes to it
|
||||
for entity_id, group in groupby(states, lambda state: state.entity_id):
|
||||
result[entity_id].extend(group)
|
||||
for ent_id, group in groupby(states, lambda state: state.entity_id):
|
||||
result[ent_id].extend(group)
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
@ -67,10 +67,9 @@ def setup(hass, config):
|
|||
except requests.exceptions.RequestException:
|
||||
if insteonhub.http_code == 401:
|
||||
_LOGGER.error("Bad user/pass for insteon_local hub")
|
||||
return False
|
||||
else:
|
||||
_LOGGER.error("Error on insteon_local hub check", exc_info=True)
|
||||
return False
|
||||
return False
|
||||
|
||||
hass.data['insteon_local'] = insteonhub
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ def setup(hass, config):
|
|||
host = config[DOMAIN].get(CONF_HOST)
|
||||
port = config[DOMAIN].get(CONF_PORT)
|
||||
|
||||
if host is '0.0.0.0':
|
||||
if host == '0.0.0.0':
|
||||
_LOGGER.debug("Will try to auto-detect KNX/IP gateway")
|
||||
|
||||
KNXTUNNEL = KNXIPTunnel(host, port)
|
||||
|
|
|
@ -23,8 +23,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
return
|
||||
|
||||
devices = []
|
||||
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMLight(hass, config)
|
||||
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMLight(hass, conf)
|
||||
new_device.link_homematic()
|
||||
devices.append(new_device)
|
||||
|
||||
|
@ -38,10 +38,9 @@ class HMLight(HMDevice, Light):
|
|||
def brightness(self):
|
||||
"""Return the brightness of this light between 0..255."""
|
||||
# Is dimmer?
|
||||
if self._state is "LEVEL":
|
||||
if self._state == "LEVEL":
|
||||
return int(self._hm_get_state() * 255)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
@ -58,7 +57,7 @@ class HMLight(HMDevice, Light):
|
|||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the light on."""
|
||||
if ATTR_BRIGHTNESS in kwargs and self._state is "LEVEL":
|
||||
if ATTR_BRIGHTNESS in kwargs and self._state == "LEVEL":
|
||||
percent_bright = float(kwargs[ATTR_BRIGHTNESS]) / 255
|
||||
self._hmdevice.set_level(percent_bright, self._channel)
|
||||
else:
|
||||
|
|
|
@ -330,36 +330,31 @@ class HueLight(Light):
|
|||
"""Return the brightness of this light between 0..255."""
|
||||
if self.is_group:
|
||||
return self.info['action'].get('bri')
|
||||
else:
|
||||
return self.info['state'].get('bri')
|
||||
return self.info['state'].get('bri')
|
||||
|
||||
@property
|
||||
def xy_color(self):
|
||||
"""Return the XY color value."""
|
||||
if self.is_group:
|
||||
return self.info['action'].get('xy')
|
||||
else:
|
||||
return self.info['state'].get('xy')
|
||||
return self.info['state'].get('xy')
|
||||
|
||||
@property
|
||||
def color_temp(self):
|
||||
"""Return the CT color value."""
|
||||
if self.is_group:
|
||||
return self.info['action'].get('ct')
|
||||
else:
|
||||
return self.info['state'].get('ct')
|
||||
return self.info['state'].get('ct')
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
"""Return true if device is on."""
|
||||
if self.is_group:
|
||||
return self.info['state']['any_on']
|
||||
else:
|
||||
if self.allow_unreachable:
|
||||
return self.info['state']['on']
|
||||
else:
|
||||
return self.info['state']['reachable'] and \
|
||||
self.info['state']['on']
|
||||
elif self.allow_unreachable:
|
||||
return self.info['state']['on']
|
||||
return self.info['state']['reachable'] and \
|
||||
self.info['state']['on']
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
|
|
@ -251,7 +251,7 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
|||
|
||||
if not alarm_type:
|
||||
return
|
||||
if alarm_type is 21:
|
||||
if alarm_type == 21:
|
||||
self._lock_status = '{}{}'.format(
|
||||
LOCK_ALARM_TYPE.get(str(alarm_type)),
|
||||
MANUAL_LOCK_ALARM_LEVEL.get(str(alarm_level)))
|
||||
|
@ -260,7 +260,7 @@ class ZwaveLock(zwave.ZWaveDeviceEntity, LockDevice):
|
|||
self._lock_status = '{}{}'.format(
|
||||
LOCK_ALARM_TYPE.get(str(alarm_type)), str(alarm_level))
|
||||
return
|
||||
if alarm_type is 161:
|
||||
if alarm_type == 161:
|
||||
self._lock_status = '{}{}'.format(
|
||||
LOCK_ALARM_TYPE.get(str(alarm_type)),
|
||||
TAMPER_ALARM_LEVEL.get(str(alarm_level)))
|
||||
|
|
|
@ -367,14 +367,12 @@ def _entry_message_from_state(domain, state):
|
|||
if domain == 'device_tracker':
|
||||
if state.state == STATE_NOT_HOME:
|
||||
return 'is away'
|
||||
else:
|
||||
return 'is at {}'.format(state.state)
|
||||
return 'is at {}'.format(state.state)
|
||||
|
||||
elif domain == 'sun':
|
||||
if state.state == sun.STATE_ABOVE_HORIZON:
|
||||
return 'has risen'
|
||||
else:
|
||||
return 'has set'
|
||||
return 'has set'
|
||||
|
||||
elif state.state == STATE_ON:
|
||||
# Future: combine groups and its entity entries ?
|
||||
|
|
|
@ -801,8 +801,7 @@ class MediaPlayerDevice(Entity):
|
|||
|
||||
if self.state in [STATE_OFF, STATE_IDLE]:
|
||||
return self.async_turn_on()
|
||||
else:
|
||||
return self.async_turn_off()
|
||||
return self.async_turn_off()
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_volume_up(self):
|
||||
|
@ -845,8 +844,7 @@ class MediaPlayerDevice(Entity):
|
|||
|
||||
if self.state == STATE_PLAYING:
|
||||
return self.async_media_pause()
|
||||
else:
|
||||
return self.async_media_play()
|
||||
return self.async_media_play()
|
||||
|
||||
@property
|
||||
def entity_picture(self):
|
||||
|
|
|
@ -131,8 +131,7 @@ class CastDevice(MediaPlayerDevice):
|
|||
return STATE_IDLE
|
||||
elif self.cast.is_idle:
|
||||
return STATE_OFF
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def volume_level(self):
|
||||
|
|
|
@ -197,8 +197,7 @@ class DenonDevice(MediaPlayerDevice):
|
|||
"""Flag media player features that are supported."""
|
||||
if self._current_source in self._receiver.netaudio_func_list:
|
||||
return SUPPORT_DENON | SUPPORT_MEDIA_MODES
|
||||
else:
|
||||
return SUPPORT_DENON
|
||||
return SUPPORT_DENON
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
|
@ -210,8 +209,7 @@ class DenonDevice(MediaPlayerDevice):
|
|||
"""Content type of current playing media."""
|
||||
if self._state == STATE_PLAYING or self._state == STATE_PAUSED:
|
||||
return MEDIA_TYPE_MUSIC
|
||||
else:
|
||||
return MEDIA_TYPE_CHANNEL
|
||||
return MEDIA_TYPE_CHANNEL
|
||||
|
||||
@property
|
||||
def media_duration(self):
|
||||
|
@ -223,8 +221,7 @@ class DenonDevice(MediaPlayerDevice):
|
|||
"""Image url of current playing media."""
|
||||
if self._current_source in self._receiver.playing_func_list:
|
||||
return self._media_image_url
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
|
@ -233,24 +230,21 @@ class DenonDevice(MediaPlayerDevice):
|
|||
return self._current_source
|
||||
elif self._title is not None:
|
||||
return self._title
|
||||
else:
|
||||
return self._frequency
|
||||
return self._frequency
|
||||
|
||||
@property
|
||||
def media_artist(self):
|
||||
"""Artist of current playing media, music track only."""
|
||||
if self._artist is not None:
|
||||
return self._artist
|
||||
else:
|
||||
return self._band
|
||||
return self._band
|
||||
|
||||
@property
|
||||
def media_album_name(self):
|
||||
"""Album name of current playing media, music track only."""
|
||||
if self._album is not None:
|
||||
return self._album
|
||||
else:
|
||||
return self._station
|
||||
return self._station
|
||||
|
||||
@property
|
||||
def media_album_artist(self):
|
||||
|
@ -297,17 +291,11 @@ class DenonDevice(MediaPlayerDevice):
|
|||
"""Turn on media player."""
|
||||
if self._receiver.power_on():
|
||||
self._state = STATE_ON
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn off media player."""
|
||||
if self._receiver.power_off():
|
||||
self._state = STATE_OFF
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def volume_up(self):
|
||||
"""Volume up the media player."""
|
||||
|
@ -327,11 +315,8 @@ class DenonDevice(MediaPlayerDevice):
|
|||
try:
|
||||
if self._receiver.set_volume(volume_denon):
|
||||
self._volume = volume_denon
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except ValueError:
|
||||
return False
|
||||
pass
|
||||
|
||||
def mute_volume(self, mute):
|
||||
"""Send mute command."""
|
||||
|
|
|
@ -95,43 +95,37 @@ class DirecTvDevice(MediaPlayerDevice):
|
|||
if self._is_standby:
|
||||
return STATE_OFF
|
||||
# Haven't determined a way to see if the content is paused
|
||||
else:
|
||||
return STATE_PLAYING
|
||||
return STATE_PLAYING
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
"""Return the content ID of current playing media."""
|
||||
if self._is_standby:
|
||||
return None
|
||||
else:
|
||||
return self._current['programId']
|
||||
return self._current['programId']
|
||||
|
||||
@property
|
||||
def media_duration(self):
|
||||
"""Return the duration of current playing media in seconds."""
|
||||
if self._is_standby:
|
||||
return None
|
||||
else:
|
||||
return self._current['duration']
|
||||
return self._current['duration']
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
"""Return the title of current playing media."""
|
||||
if self._is_standby:
|
||||
return None
|
||||
else:
|
||||
return self._current['title']
|
||||
return self._current['title']
|
||||
|
||||
@property
|
||||
def media_series_title(self):
|
||||
"""Return the title of current episode of TV show."""
|
||||
if self._is_standby:
|
||||
return None
|
||||
else:
|
||||
if 'episodeTitle' in self._current:
|
||||
return self._current['episodeTitle']
|
||||
else:
|
||||
return None
|
||||
elif 'episodeTitle' in self._current:
|
||||
return self._current['episodeTitle']
|
||||
return None
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -143,8 +137,7 @@ class DirecTvDevice(MediaPlayerDevice):
|
|||
"""Return the content type of current playing media."""
|
||||
if 'episodeTitle' in self._current:
|
||||
return MEDIA_TYPE_TVSHOW
|
||||
else:
|
||||
return MEDIA_TYPE_VIDEO
|
||||
return MEDIA_TYPE_VIDEO
|
||||
|
||||
@property
|
||||
def media_channel(self):
|
||||
|
|
|
@ -90,8 +90,7 @@ class PhilipsTV(MediaPlayerDevice):
|
|||
"""Flag media player features that are supported."""
|
||||
if self._watching_tv:
|
||||
return SUPPORT_PHILIPS_JS_TV
|
||||
else:
|
||||
return SUPPORT_PHILIPS_JS
|
||||
return SUPPORT_PHILIPS_JS
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -162,13 +161,9 @@ class PhilipsTV(MediaPlayerDevice):
|
|||
@property
|
||||
def media_title(self):
|
||||
"""Title of current playing media."""
|
||||
if self._watching_tv:
|
||||
if self._channel_name:
|
||||
return '{} - {}'.format(self._source, self._channel_name)
|
||||
else:
|
||||
return self._source
|
||||
else:
|
||||
return self._source
|
||||
if self._watching_tv and self._channel_name:
|
||||
return '{} - {}'.format(self._source, self._channel_name)
|
||||
return self._source
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_UPDATES)
|
||||
def update(self):
|
||||
|
|
|
@ -171,7 +171,7 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
|||
for device in devices}
|
||||
device_diff = {name: id for name, id in self._devices.items()
|
||||
if old_devices.get(name, None) is None}
|
||||
if len(device_diff) > 0:
|
||||
if device_diff:
|
||||
_LOGGER.info("New Devices: %s", str(device_diff))
|
||||
# Current playback state
|
||||
current = self._player.current_playback()
|
||||
|
@ -312,5 +312,4 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
|||
"""Return the media player features that are supported."""
|
||||
if self._user is not None and self._user['product'] == 'premium':
|
||||
return SUPPORT_SPOTIFY
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
|
|
@ -74,5 +74,5 @@ class SendgridNotificationService(BaseNotificationService):
|
|||
}
|
||||
|
||||
response = self._sg.client.mail.send.post(request_body=data)
|
||||
if response.status_code is not 202:
|
||||
if response.status_code != 202:
|
||||
_LOGGER.error("Unable to send notification")
|
||||
|
|
|
@ -100,12 +100,14 @@ class OctoPrintAPI(object):
|
|||
# pylint: disable=unused-variable
|
||||
def get_value_from_json(json_dict, sensor_type, group, tool):
|
||||
"""Return the value for sensor_type from the JSON."""
|
||||
if group in json_dict:
|
||||
if sensor_type in json_dict[group]:
|
||||
if sensor_type == "target" and json_dict[sensor_type] is None:
|
||||
return 0
|
||||
else:
|
||||
return json_dict[group][sensor_type]
|
||||
elif tool is not None:
|
||||
if sensor_type in json_dict[group][tool]:
|
||||
return json_dict[group][tool][sensor_type]
|
||||
if group not in json_dict:
|
||||
return None
|
||||
|
||||
if sensor_type in json_dict[group]:
|
||||
if sensor_type == "target" and json_dict[sensor_type] is None:
|
||||
return 0
|
||||
return json_dict[group][sensor_type]
|
||||
|
||||
elif tool is not None:
|
||||
if sensor_type in json_dict[group][tool]:
|
||||
return json_dict[group][tool][sensor_type]
|
||||
|
|
|
@ -204,13 +204,13 @@ class Plant(Entity):
|
|||
result.append('{} high'.format(sensor_name))
|
||||
self._icon = params['icon']
|
||||
|
||||
if len(result) == 0:
|
||||
if result:
|
||||
self._state = STATE_PROBLEM
|
||||
self._problems = ','.join(result)
|
||||
else:
|
||||
self._state = STATE_OK
|
||||
self._icon = 'mdi:thumb-up'
|
||||
self._problems = PROBLEM_NONE
|
||||
else:
|
||||
self._state = STATE_PROBLEM
|
||||
self._problems = ','.join(result)
|
||||
_LOGGER.debug("New data processed")
|
||||
self.hass.async_add_job(self.async_update_ha_state())
|
||||
|
||||
|
|
|
@ -183,10 +183,10 @@ def setup(hass, config):
|
|||
qsreply = qsusb.devices()
|
||||
if qsreply is False:
|
||||
return
|
||||
for item in qsreply:
|
||||
if item[QS_ID] in QSUSB:
|
||||
QSUSB[item[QS_ID]].update_value(
|
||||
round(min(item[PQS_VALUE], 100) * 2.55))
|
||||
for itm in qsreply:
|
||||
if itm[QS_ID] in QSUSB:
|
||||
QSUSB[itm[QS_ID]].update_value(
|
||||
round(min(itm[PQS_VALUE], 100) * 2.55))
|
||||
|
||||
def _start(event):
|
||||
"""Start listening."""
|
||||
|
|
|
@ -85,8 +85,7 @@ def identify_event_type(event):
|
|||
return EVENT_KEY_COMMAND
|
||||
elif EVENT_KEY_SENSOR in event:
|
||||
return EVENT_KEY_SENSOR
|
||||
else:
|
||||
return 'unknown'
|
||||
return 'unknown'
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
|
|
|
@ -123,7 +123,7 @@ class ArestSensor(Entity):
|
|||
if self._pin is not None:
|
||||
request = requests.get(
|
||||
'{}/mode/{}/i'.format(self._resource, self._pin), timeout=10)
|
||||
if request.status_code is not 200:
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode of %s", self._resource)
|
||||
|
||||
@property
|
||||
|
|
|
@ -141,7 +141,7 @@ class PublicTransportData(object):
|
|||
params = {}
|
||||
params['stopid'] = self.stop
|
||||
|
||||
if len(self.route) > 0:
|
||||
if self.route:
|
||||
params['routeid'] = self.route
|
||||
|
||||
params['maxresults'] = 2
|
||||
|
|
|
@ -56,8 +56,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
return
|
||||
|
||||
devices = []
|
||||
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMSensor(hass, config)
|
||||
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMSensor(hass, conf)
|
||||
new_device.link_homematic()
|
||||
devices.append(new_device)
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
password = config.get(CONF_PASSWORD)
|
||||
use_tls = config.get(CONF_SSL)
|
||||
verify_tls = config.get(CONF_VERIFY_SSL)
|
||||
default_port = use_tls and 6443 or 6080
|
||||
default_port = 6443 if use_tls else 6080
|
||||
port = int(config.get(CONF_PORT, default_port))
|
||||
|
||||
from mficlient.client import FailedToLogin, MFiClient
|
||||
|
@ -97,10 +97,9 @@ class MfiSensor(Entity):
|
|||
if tag is None:
|
||||
return STATE_OFF
|
||||
elif self._port.model == 'Input Digital':
|
||||
return self._port.value > 0 and STATE_ON or STATE_OFF
|
||||
else:
|
||||
digits = DIGITS.get(self._port.tag, 0)
|
||||
return round(self._port.value, digits)
|
||||
return STATE_ON if self._port.value > 0 else STATE_OFF
|
||||
digits = DIGITS.get(self._port.tag, 0)
|
||||
return round(self._port.value, digits)
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -242,10 +242,9 @@ class MoldIndicator(Entity):
|
|||
ATTR_DEWPOINT: self._dewpoint,
|
||||
ATTR_CRITICAL_TEMP: self._crit_temp,
|
||||
}
|
||||
else:
|
||||
return {
|
||||
ATTR_DEWPOINT:
|
||||
util.temperature.celsius_to_fahrenheit(self._dewpoint),
|
||||
ATTR_CRITICAL_TEMP:
|
||||
util.temperature.celsius_to_fahrenheit(self._crit_temp),
|
||||
}
|
||||
return {
|
||||
ATTR_DEWPOINT:
|
||||
util.temperature.celsius_to_fahrenheit(self._dewpoint),
|
||||
ATTR_CRITICAL_TEMP:
|
||||
util.temperature.celsius_to_fahrenheit(self._crit_temp),
|
||||
}
|
||||
|
|
|
@ -147,13 +147,13 @@ class OpenHardwareMonitorData(object):
|
|||
"""Recursively loop through child objects, finding the values."""
|
||||
result = devices.copy()
|
||||
|
||||
if len(json[OHM_CHILDREN]) > 0:
|
||||
if json[OHM_CHILDREN]:
|
||||
for child_index in range(0, len(json[OHM_CHILDREN])):
|
||||
child_path = path.copy()
|
||||
child_path.append(child_index)
|
||||
|
||||
child_names = names.copy()
|
||||
if len(path) > 0:
|
||||
if path:
|
||||
child_names.append(json[OHM_NAME])
|
||||
|
||||
obj = json[OHM_CHILDREN][child_index]
|
||||
|
|
|
@ -58,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
continue
|
||||
dev.append(UberSensor('time', timeandpriceest, product_id, product))
|
||||
if (product.get('price_details') is not None) and \
|
||||
product['price_details']['estimate'] is not 'Metered':
|
||||
product['price_details']['estimate'] != 'Metered':
|
||||
dev.append(UberSensor(
|
||||
'price', timeandpriceest, product_id, product))
|
||||
add_devices(dev)
|
||||
|
|
|
@ -57,10 +57,6 @@ class Sensor(zha.Entity):
|
|||
value_attribute = 0
|
||||
min_reportable_change = 1
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
"""Initialize ZHA sensor."""
|
||||
super().__init__(**kwargs)
|
||||
|
||||
@property
|
||||
def state(self) -> str:
|
||||
"""Return the state of the entity."""
|
||||
|
|
|
@ -102,7 +102,7 @@ class ArestSwitchFunction(ArestSwitchBase):
|
|||
request = requests.get(
|
||||
'{}/{}'.format(self._resource, self._func), timeout=10)
|
||||
|
||||
if request.status_code is not 200:
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't find function")
|
||||
return
|
||||
|
||||
|
@ -159,7 +159,7 @@ class ArestSwitchPin(ArestSwitchBase):
|
|||
|
||||
request = requests.get(
|
||||
'{}/mode/{}/o'.format(self._resource, self._pin), timeout=10)
|
||||
if request.status_code is not 200:
|
||||
if request.status_code != 200:
|
||||
_LOGGER.error("Can't set mode")
|
||||
self._available = False
|
||||
|
||||
|
|
|
@ -77,13 +77,13 @@ class BBBGPIOSwitch(ToggleEntity):
|
|||
"""Return true if device is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
bbb_gpio.write_output(self._pin, 0 if self._invert_logic else 1)
|
||||
self._state = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
bbb_gpio.write_output(self._pin, 1 if self._invert_logic else 0)
|
||||
self._state = False
|
||||
|
|
|
@ -244,10 +244,6 @@ class BroadlinkSP1Switch(BroadlinkRMSwitch):
|
|||
class BroadlinkSP2Switch(BroadlinkSP1Switch):
|
||||
"""Representation of an Broadlink switch."""
|
||||
|
||||
def __init__(self, friendly_name, device):
|
||||
"""Initialize the switch."""
|
||||
super().__init__(friendly_name, device)
|
||||
|
||||
@property
|
||||
def assumed_state(self):
|
||||
"""Return true if unable to access real state of entity."""
|
||||
|
|
|
@ -20,8 +20,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
return
|
||||
|
||||
devices = []
|
||||
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMSwitch(hass, config)
|
||||
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
|
||||
new_device = HMSwitch(hass, conf)
|
||||
new_device.link_homematic()
|
||||
devices.append(new_device)
|
||||
|
||||
|
|
|
@ -122,7 +122,7 @@ class HookSmartHome(SwitchDevice):
|
|||
return data['return_value'] == '1'
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_on(self):
|
||||
def async_turn_on(self, **kwargs):
|
||||
"""Turn the device on asynchronously."""
|
||||
_LOGGER.debug("Turning on: %s", self._name)
|
||||
url = '{}{}{}{}'.format(
|
||||
|
@ -131,7 +131,7 @@ class HookSmartHome(SwitchDevice):
|
|||
self._state = success
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_turn_off(self):
|
||||
def async_turn_off(self, **kwargs):
|
||||
"""Turn the device off asynchronously."""
|
||||
_LOGGER.debug("Turning off: %s", self._name)
|
||||
url = '{}{}{}{}'.format(
|
||||
|
|
|
@ -47,7 +47,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
password = config.get(CONF_PASSWORD)
|
||||
use_tls = config.get(CONF_SSL)
|
||||
verify_tls = config.get(CONF_VERIFY_SSL)
|
||||
default_port = use_tls and 6443 or 6080
|
||||
default_port = 6443 if use_tls else 6080
|
||||
port = int(config.get(CONF_PORT, default_port))
|
||||
|
||||
from mficlient.client import FailedToLogin, MFiClient
|
||||
|
@ -100,12 +100,12 @@ class MfiSwitch(SwitchDevice):
|
|||
self._port.data['output'] = float(self._target_state)
|
||||
self._target_state = None
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the switch on."""
|
||||
self._port.control(True)
|
||||
self._target_state = True
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
self._port.control(False)
|
||||
self._target_state = False
|
||||
|
|
|
@ -135,7 +135,7 @@ class MySensorsSwitch(mysensors.MySensorsDeviceEntity, SwitchDevice):
|
|||
return self._values[self.value_type] == STATE_ON
|
||||
return False
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the switch on."""
|
||||
self.gateway.set_child_value(
|
||||
self.node_id, self.child_id, self.value_type, 1)
|
||||
|
@ -144,7 +144,7 @@ class MySensorsSwitch(mysensors.MySensorsDeviceEntity, SwitchDevice):
|
|||
self._values[self.value_type] = STATE_ON
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
self.gateway.set_child_value(
|
||||
self.node_id, self.child_id, self.value_type, 0)
|
||||
|
@ -191,7 +191,7 @@ class MySensorsIRSwitch(MySensorsSwitch):
|
|||
# turn off switch after switch was turned on
|
||||
self.turn_off()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the IR switch off."""
|
||||
set_req = self.gateway.const.SetReq
|
||||
if set_req.V_LIGHT not in self._values:
|
||||
|
|
|
@ -137,8 +137,7 @@ class PAServer():
|
|||
self._current_module_state)
|
||||
if result and result.group(1).isdigit():
|
||||
return int(result.group(1))
|
||||
else:
|
||||
return -1
|
||||
return -1
|
||||
|
||||
|
||||
class PALoopbackSwitch(SwitchDevice):
|
||||
|
|
|
@ -52,18 +52,18 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
|
||||
# Get and persist devices
|
||||
devices = _list_devices(rachio, manual_run_mins)
|
||||
if len(devices) == 0:
|
||||
if not devices:
|
||||
_LOGGER.error("No Rachio devices found in account " +
|
||||
person['username'])
|
||||
return False
|
||||
else:
|
||||
hass.data[DATA_RACHIO] = devices[0]
|
||||
|
||||
if len(devices) > 1:
|
||||
_LOGGER.warning("Multiple Rachio devices found in account, "
|
||||
"using " + hass.data[DATA_RACHIO].device_id)
|
||||
else:
|
||||
_LOGGER.info("Found Rachio device")
|
||||
hass.data[DATA_RACHIO] = devices[0]
|
||||
|
||||
if len(devices) > 1:
|
||||
_LOGGER.warning("Multiple Rachio devices found in account, "
|
||||
"using " + hass.data[DATA_RACHIO].device_id)
|
||||
else:
|
||||
_LOGGER.info("Found Rachio device")
|
||||
|
||||
hass.data[DATA_RACHIO].update()
|
||||
add_devices(hass.data[DATA_RACHIO].list_zones())
|
||||
|
|
|
@ -73,13 +73,13 @@ class RPiGPIOSwitch(ToggleEntity):
|
|||
"""Return true if device is on."""
|
||||
return self._state
|
||||
|
||||
def turn_on(self):
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the device on."""
|
||||
rpi_gpio.write_output(self._port, 0 if self._invert_logic else 1)
|
||||
self._state = True
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the device off."""
|
||||
rpi_gpio.write_output(self._port, 1 if self._invert_logic else 0)
|
||||
self._state = False
|
||||
|
|
|
@ -195,7 +195,7 @@ class WemoSwitch(SwitchDevice):
|
|||
self.wemo.on()
|
||||
self.schedule_update_ha_state()
|
||||
|
||||
def turn_off(self):
|
||||
def turn_off(self, **kwargs):
|
||||
"""Turn the switch off."""
|
||||
self._state = WEMO_OFF
|
||||
self.wemo.off()
|
||||
|
|
|
@ -37,10 +37,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||
class WinkToggleDevice(WinkDevice, ToggleEntity):
|
||||
"""Representation of a Wink toggle device."""
|
||||
|
||||
def __init__(self, wink, hass):
|
||||
"""Initialize the Wink device."""
|
||||
super().__init__(wink, hass)
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_added_to_hass(self):
|
||||
"""Callback when entity is added to hass."""
|
||||
|
|
|
@ -116,10 +116,9 @@ class TelldusLiveClient(object):
|
|||
return 'cover'
|
||||
elif device.methods & TURNON:
|
||||
return 'switch'
|
||||
else:
|
||||
_LOGGER.warning(
|
||||
"Unidentified device type (methods: %d)", device.methods)
|
||||
return 'switch'
|
||||
_LOGGER.warning(
|
||||
"Unidentified device type (methods: %d)", device.methods)
|
||||
return 'switch'
|
||||
|
||||
def discover(device_id, component):
|
||||
"""Discover the component."""
|
||||
|
|
|
@ -122,8 +122,7 @@ def map_vera_device(vera_device, remap):
|
|||
if isinstance(vera_device, veraApi.VeraSwitch):
|
||||
if vera_device.device_id in remap:
|
||||
return 'light'
|
||||
else:
|
||||
return 'switch'
|
||||
return 'switch'
|
||||
return None
|
||||
|
||||
|
||||
|
|
|
@ -165,6 +165,5 @@ class WeatherEntity(Entity):
|
|||
|
||||
if hass_unit == TEMP_CELSIUS:
|
||||
return round(value, 1)
|
||||
else:
|
||||
# Users of fahrenheit generally expect integer units.
|
||||
return round(value)
|
||||
# Users of fahrenheit generally expect integer units.
|
||||
return round(value)
|
||||
|
|
|
@ -29,7 +29,7 @@ from homeassistant.components.http.ban import process_wrong_login
|
|||
DOMAIN = 'websocket_api'
|
||||
|
||||
URL = '/api/websocket'
|
||||
DEPENDENCIES = 'http',
|
||||
DEPENDENCIES = ('http',)
|
||||
|
||||
MAX_PENDING_MSG = 512
|
||||
|
||||
|
|
|
@ -277,5 +277,4 @@ class WinkDevice(Entity):
|
|||
"""Return the devices tamper status."""
|
||||
if hasattr(self.wink, 'tamper_detected'):
|
||||
return self.wink.tamper_detected()
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
|
|
@ -450,12 +450,11 @@ def setup(hass, config):
|
|||
"with selection %s", param, node_id,
|
||||
selection)
|
||||
return
|
||||
else:
|
||||
value.data = int(selection)
|
||||
_LOGGER.info("Setting config parameter %s on Node %s "
|
||||
"with selection %s", param, node_id,
|
||||
selection)
|
||||
return
|
||||
value.data = int(selection)
|
||||
_LOGGER.info("Setting config parameter %s on Node %s "
|
||||
"with selection %s", param, node_id,
|
||||
selection)
|
||||
return
|
||||
node.set_config_param(param, selection, size)
|
||||
_LOGGER.info("Setting unknown config parameter %s on Node %s "
|
||||
"with selection %s", param, node_id,
|
||||
|
|
|
@ -335,9 +335,9 @@ class Event(object):
|
|||
return "<Event {}[{}]: {}>".format(
|
||||
self.event_type, str(self.origin)[0],
|
||||
util.repr_helper(self.data))
|
||||
else:
|
||||
return "<Event {}[{}]>".format(self.event_type,
|
||||
str(self.origin)[0])
|
||||
|
||||
return "<Event {}[{}]>".format(self.event_type,
|
||||
str(self.origin)[0])
|
||||
|
||||
def __eq__(self, other):
|
||||
"""Return the comparison."""
|
||||
|
@ -783,8 +783,8 @@ class ServiceCall(object):
|
|||
if self.data:
|
||||
return "<ServiceCall {}.{}: {}>".format(
|
||||
self.domain, self.service, util.repr_helper(self.data))
|
||||
else:
|
||||
return "<ServiceCall {}.{}>".format(self.domain, self.service)
|
||||
|
||||
return "<ServiceCall {}.{}>".format(self.domain, self.service)
|
||||
|
||||
|
||||
class ServiceRegistry(object):
|
||||
|
|
|
@ -172,6 +172,7 @@ class Entity(object):
|
|||
if async_update is None:
|
||||
return
|
||||
|
||||
# pylint: disable=not-callable
|
||||
run_coroutine_threadsafe(async_update(), self.hass.loop).result()
|
||||
|
||||
# DO NOT OVERWRITE
|
||||
|
@ -391,5 +392,4 @@ class ToggleEntity(Entity):
|
|||
"""
|
||||
if self.is_on:
|
||||
return self.async_turn_off()
|
||||
else:
|
||||
return self.async_turn_on()
|
||||
return self.async_turn_on()
|
||||
|
|
|
@ -312,8 +312,7 @@ def _process_state_match(parameter):
|
|||
return MATCH_ALL
|
||||
elif isinstance(parameter, str) or not hasattr(parameter, '__iter__'):
|
||||
return (parameter,)
|
||||
else:
|
||||
return tuple(parameter)
|
||||
return tuple(parameter)
|
||||
|
||||
|
||||
def _process_time_match(parameter):
|
||||
|
@ -324,8 +323,7 @@ def _process_time_match(parameter):
|
|||
return parameter
|
||||
elif isinstance(parameter, str) or not hasattr(parameter, '__iter__'):
|
||||
return (parameter,)
|
||||
else:
|
||||
return tuple(parameter)
|
||||
return tuple(parameter)
|
||||
|
||||
|
||||
def _matcher(subject, pattern):
|
||||
|
|
|
@ -47,7 +47,7 @@ def extract_entities(template):
|
|||
return MATCH_ALL
|
||||
|
||||
extraction = _RE_GET_ENTITIES.findall(template)
|
||||
if len(extraction) > 0:
|
||||
if extraction:
|
||||
return list(set(extraction))
|
||||
return MATCH_ALL
|
||||
|
||||
|
|
|
@ -92,10 +92,10 @@ class API(object):
|
|||
if method == METHOD_GET:
|
||||
return requests.get(
|
||||
url, params=data, timeout=timeout, headers=self._headers)
|
||||
else:
|
||||
return requests.request(
|
||||
method, url, data=data, timeout=timeout,
|
||||
headers=self._headers)
|
||||
|
||||
return requests.request(
|
||||
method, url, data=data, timeout=timeout,
|
||||
headers=self._headers)
|
||||
|
||||
except requests.exceptions.ConnectionError:
|
||||
_LOGGER.exception("Error connecting to server")
|
||||
|
@ -152,8 +152,7 @@ def validate_api(api):
|
|||
elif req.status_code == 401:
|
||||
return APIStatus.INVALID_PASSWORD
|
||||
|
||||
else:
|
||||
return APIStatus.UNKNOWN
|
||||
return APIStatus.UNKNOWN
|
||||
|
||||
except HomeAssistantError:
|
||||
return APIStatus.CANNOT_CONNECT
|
||||
|
@ -259,8 +258,8 @@ def set_state(api, entity_id, new_state, attributes=None, force_update=False):
|
|||
_LOGGER.error("Error changing state: %d - %s",
|
||||
req.status_code, req.text)
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
||||
return True
|
||||
|
||||
except HomeAssistantError:
|
||||
_LOGGER.exception("Error setting state")
|
||||
|
|
|
@ -288,7 +288,7 @@ def dump_dict(layer, indent_count=3, listi=False, **kwargs):
|
|||
indent_str = indent_str[:-1] + '-'
|
||||
if isinstance(layer, Dict):
|
||||
for key, value in sorted(layer.items(), key=sort_dict_key):
|
||||
if isinstance(value, dict) or isinstance(value, list):
|
||||
if isinstance(value, (dict, list)):
|
||||
print(indent_str, key + ':', line_info(value, **kwargs))
|
||||
dump_dict(value, indent_count + 2)
|
||||
else:
|
||||
|
|
|
@ -56,8 +56,8 @@ def repr_helper(inp: Any) -> str:
|
|||
in inp.items())
|
||||
elif isinstance(inp, datetime):
|
||||
return as_local(inp).isoformat()
|
||||
else:
|
||||
return str(inp)
|
||||
|
||||
return str(inp)
|
||||
|
||||
|
||||
def convert(value: T, to_type: Callable[[T], U],
|
||||
|
@ -303,8 +303,8 @@ class Throttle(object):
|
|||
result = method(*args, **kwargs)
|
||||
throttle[1] = utcnow()
|
||||
return result
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
finally:
|
||||
throttle[0].release()
|
||||
|
||||
|
|
|
@ -26,5 +26,4 @@ def convert(temperature: float, from_unit: str, to_unit: str) -> float:
|
|||
return temperature
|
||||
elif from_unit == TEMP_CELSIUS:
|
||||
return celsius_to_fahrenheit(temperature)
|
||||
else:
|
||||
return fahrenheit_to_celsius(temperature)
|
||||
return fahrenheit_to_celsius(temperature)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue