Fix pylint 1.7.2 no-else-return issues (#8361)

* Fix pylint 1.7.2 no-else-return issues

* Update tomato.py
This commit is contained in:
Paulus Schoutsen 2017-07-05 23:30:01 -07:00 committed by GitHub
parent 5779d64e98
commit 46e030662d
111 changed files with 305 additions and 455 deletions

View File

@ -92,7 +92,6 @@ class AlarmDotCom(alarm.AlarmControlPanel):
return STATE_ALARM_ARMED_HOME
elif self._alarm.state.lower() == 'armed away':
return STATE_ALARM_ARMED_AWAY
else:
return STATE_UNKNOWN
@asyncio.coroutine

View File

@ -113,7 +113,6 @@ class EnvisalinkAlarm(EnvisalinkDevice, alarm.AlarmControlPanel):
"""Regex for code format or None if no code is required."""
if self._code:
return None
else:
return '^\\d{4,6}$'
@property

View File

@ -99,7 +99,6 @@ class ManualAlarm(alarm.AlarmControlPanel):
self._trigger_time) < dt_util.utcnow():
if self._disarm_after_trigger:
return STATE_ALARM_DISARMED
else:
return self._pre_trigger_state
return self._state

View File

@ -80,7 +80,6 @@ class SimpliSafeAlarm(alarm.AlarmControlPanel):
"""Return the name of the device."""
if self._name is not None:
return self._name
else:
return 'Alarm {}'.format(self.simplisafe.location_id())
@property

View File

@ -199,7 +199,6 @@ class FlicButton(BinarySensorDevice):
"Queued %s dropped for %s. Time in queue was %s",
click_type, self.address, time_string)
return True
else:
_LOGGER.info(
"Queued %s allowed for %s. Time in queue was %s",
click_type, self.address, time_string)

View File

@ -34,8 +34,8 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return
devices = []
for config in discovery_info[ATTR_DISCOVER_DEVICES]:
new_device = HMBinarySensor(hass, config)
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
new_device = HMBinarySensor(hass, conf)
new_device.link_homematic()
devices.append(new_device)

View File

@ -156,7 +156,6 @@ class NetatmoBinarySensor(BinarySensorDevice):
return WELCOME_SENSOR_TYPES.get(self._sensor_name)
elif self._cameratype == 'NOC':
return PRESENCE_SENSOR_TYPES.get(self._sensor_name)
else:
return TAG_SENSOR_TYPES.get(self._sensor_name)
@property

View File

@ -126,7 +126,7 @@ class PingData(object):
'avg': rtt_avg,
'max': rtt_max,
'mdev': ''}
else:
match = PING_MATCHER.search(str(out).split('\n')[-1])
rtt_min, rtt_avg, rtt_max, rtt_mdev = match.groups()
return {

View File

@ -30,7 +30,6 @@ class VolvoSensor(VolvoEntity, BinarySensorDevice):
return bool(val)
elif self._attribute in ['doors', 'windows']:
return any([val[key] for key in val if 'Open' in key])
else:
return val != 'Normal'
@property

View File

@ -148,7 +148,6 @@ class CalendarEventDevice(Entity):
if 'date' in date:
return dt.start_of_local_day(dt.dt.datetime.combine(
dt.parse_date(date['date']), dt.dt.time.min))
else:
return dt.as_local(dt.parse_datetime(date['dateTime']))
start = _get_date(self.data.event['start'])

View File

@ -266,7 +266,6 @@ class Camera(Entity):
return STATE_RECORDING
elif self.is_streaming:
return STATE_STREAMING
else:
return STATE_IDLE
def enable_motion_detection(self):

View File

@ -113,7 +113,6 @@ class NetatmoCamera(Camera):
return "Presence"
elif self._cameratype == "NACamera":
return "Welcome"
else:
return None
@property

View File

@ -398,7 +398,6 @@ class ClimateDevice(Entity):
"""Return the current state."""
if self.current_operation:
return self.current_operation
else:
return STATE_UNKNOWN
@property
@ -406,7 +405,6 @@ class ClimateDevice(Entity):
"""Return the precision of the system."""
if self.unit_of_measurement == TEMP_CELSIUS:
return PRECISION_TENTHS
else:
return PRECISION_WHOLE
@property
@ -709,6 +707,5 @@ class ClimateDevice(Entity):
return round(temp * 2) / 2.0
elif self.precision == PRECISION_TENTHS:
return round(temp, 1)
else:
# PRECISION_WHOLE as a fall back
return round(temp)

View File

@ -151,7 +151,6 @@ class Thermostat(ClimateDevice):
"""Return the lower bound temperature we try to reach."""
if self.current_operation == STATE_AUTO:
return int(self.thermostat['runtime']['desiredHeat'] / 10)
else:
return None
@property
@ -159,7 +158,6 @@ class Thermostat(ClimateDevice):
"""Return the upper bound temperature we try to reach."""
if self.current_operation == STATE_AUTO:
return int(self.thermostat['runtime']['desiredCool'] / 10)
else:
return None
@property
@ -171,7 +169,6 @@ class Thermostat(ClimateDevice):
return int(self.thermostat['runtime']['desiredHeat'] / 10)
elif self.current_operation == STATE_COOL:
return int(self.thermostat['runtime']['desiredCool'] / 10)
else:
return None
@property
@ -184,7 +181,6 @@ class Thermostat(ClimateDevice):
"""Return the current fan state."""
if 'fan' in self.thermostat['equipmentStatus']:
return STATE_ON
else:
return STATE_OFF
@property
@ -199,13 +195,11 @@ class Thermostat(ClimateDevice):
int(event['startDate'][0:4]) <= 1:
# A temporary hold from away climate is a hold
return 'away'
else:
# A permanent hold from away climate is away_mode
return None
elif event['holdClimateRef'] != "":
# Any other hold based on climate
return event['holdClimateRef']
else:
# Any hold not based on a climate is a temp hold
return TEMPERATURE_HOLD
elif event['type'].startswith('auto'):
@ -222,7 +216,6 @@ class Thermostat(ClimateDevice):
if self.operation_mode == 'auxHeatOnly' or \
self.operation_mode == 'heatPump':
return STATE_HEAT
else:
return self.operation_mode
@property
@ -384,7 +377,6 @@ class Thermostat(ClimateDevice):
# add further conditions if other hold durations should be
# supported; note that this should not include 'indefinite'
# as an indefinite away hold is interpreted as away_mode
else:
return 'nextTransition'
@property

View File

@ -134,7 +134,7 @@ class GenericThermostat(ClimateDevice):
if self.ac_mode:
cooling = self._active and self._is_device_active
return STATE_COOL if cooling else STATE_IDLE
else:
heating = self._active and self._is_device_active
return STATE_HEAT if heating else STATE_IDLE
@ -159,7 +159,7 @@ class GenericThermostat(ClimateDevice):
# pylint: disable=no-member
if self._min_temp:
return self._min_temp
else:
# get default temp from super class
return ClimateDevice.min_temp.fget(self)
@ -169,7 +169,7 @@ class GenericThermostat(ClimateDevice):
# pylint: disable=no-member
if self._max_temp:
return self._max_temp
else:
# Get default temp from super class
return ClimateDevice.max_temp.fget(self)

View File

@ -60,7 +60,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if region == 'us':
return _setup_us(username, password, config, add_devices)
else:
return _setup_round(username, password, config, add_devices)
@ -251,7 +251,6 @@ class HoneywellUSThermostat(ClimateDevice):
"""Return the temperature we try to reach."""
if self._device.system_mode == 'cool':
return self._device.setpoint_cool
else:
return self._device.setpoint_heat
@property

View File

@ -109,7 +109,6 @@ class NestThermostat(ClimateDevice):
return self._mode
elif self._mode == STATE_HEAT_COOL:
return STATE_AUTO
else:
return STATE_UNKNOWN
@property
@ -117,7 +116,6 @@ class NestThermostat(ClimateDevice):
"""Return the temperature we try to reach."""
if self._mode != STATE_HEAT_COOL and not self.is_away_mode_on:
return self._target_temperature
else:
return None
@property
@ -129,7 +127,6 @@ class NestThermostat(ClimateDevice):
return self._eco_temperature[0]
if self._mode == STATE_HEAT_COOL:
return self._target_temperature[0]
else:
return None
@property
@ -141,7 +138,6 @@ class NestThermostat(ClimateDevice):
return self._eco_temperature[1]
if self._mode == STATE_HEAT_COOL:
return self._target_temperature[1]
else:
return None
@property
@ -188,7 +184,6 @@ class NestThermostat(ClimateDevice):
if self._has_fan:
# Return whether the fan is on
return STATE_ON if self._fan else STATE_AUTO
else:
# No Fan available so disable slider
return None

View File

@ -92,7 +92,6 @@ class ThermostatDevice(ClimateDevice):
"""Return current operation i.e. heat, cool, idle."""
if self._state:
return STATE_HEAT
else:
return STATE_IDLE
@property

View File

@ -117,7 +117,6 @@ class SensiboClimate(ClimateDevice):
# We are working in same units as the a/c unit. Use whole degrees
# like the API supports.
return 1
else:
# Unit conversion is going on. No point to stick to specific steps.
return None

View File

@ -52,7 +52,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
zones = tado.get_zones()
except RuntimeError:
_LOGGER.error("Unable to get zone info from mytado")
return False
return
climate_devices = []
for zone in zones:
@ -61,9 +61,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if climate_devices:
add_devices(climate_devices, True)
return True
else:
return False
def create_climate_device(tado, hass, zone, name, zone_id):
@ -150,7 +147,6 @@ class TadoClimate(ClimateDevice):
"""Return current readable operation mode."""
if self._cooling:
return "Cooling"
else:
return OPERATION_LIST.get(self._current_operation)
@property
@ -163,7 +159,6 @@ class TadoClimate(ClimateDevice):
"""Return the fan setting."""
if self.ac_mode:
return FAN_MODES_LIST.get(self._current_fan)
else:
return None
@property
@ -171,7 +166,6 @@ class TadoClimate(ClimateDevice):
"""List of available fan modes."""
if self.ac_mode:
return list(FAN_MODES_LIST.values())
else:
return None
@property
@ -218,7 +212,6 @@ class TadoClimate(ClimateDevice):
"""Return the minimum temperature."""
if self._min_temp:
return self._min_temp
else:
# get default temp from super class
return super().min_temp
@ -227,7 +220,6 @@ class TadoClimate(ClimateDevice):
"""Return the maximum temperature."""
if self._max_temp:
return self._max_temp
else:
# Get default temp from super class
return super().max_temp

View File

@ -111,8 +111,8 @@ class WinkThermostat(WinkDevice, ClimateDevice):
# This will address both possibilities
if self.wink.current_humidity() < 1:
return self.wink.current_humidity() * 100
else:
return self.wink.current_humidity()
return None
@property
def external_temperature(self):
@ -175,9 +175,6 @@ class WinkThermostat(WinkDevice, ClimateDevice):
return self.wink.current_max_set_point()
elif self.current_operation == STATE_HEAT:
return self.wink.current_min_set_point()
else:
return None
else:
return None
@property
@ -206,7 +203,6 @@ class WinkThermostat(WinkDevice, ClimateDevice):
return True
elif self.wink.current_hvac_mode() == 'aux' and not self.wink.is_on():
return False
else:
return None
def set_temperature(self, **kwargs):
@ -270,7 +266,6 @@ class WinkThermostat(WinkDevice, ClimateDevice):
return STATE_ON
elif self.wink.current_fan_mode() == 'auto':
return STATE_AUTO
else:
# No Fan available so disable slider
return None
@ -451,7 +446,6 @@ class WinkAC(WinkDevice, ClimateDevice):
return SPEED_MEDIUM
elif speed <= 1.0 and speed > 0.8:
return SPEED_HIGH
else:
return STATE_UNKNOWN
@property

View File

@ -154,7 +154,6 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
return TEMP_CELSIUS
elif self._unit == 'F':
return TEMP_FAHRENHEIT
else:
return self._unit
@property

View File

@ -112,10 +112,7 @@ class CommandCover(CoverDevice):
def is_closed(self):
"""Return if the cover is closed."""
if self.current_cover_position is not None:
if self.current_cover_position > 0:
return False
else:
return True
return self.current_cover_position == 0
@property
def current_cover_position(self):

View File

@ -79,7 +79,6 @@ class DemoCover(CoverDevice):
"""Flag supported features."""
if self._supported_features is not None:
return self._supported_features
else:
return super().supported_features
def close_cover(self, **kwargs):

View File

@ -159,7 +159,6 @@ class GaradgetCover(CoverDevice):
"""Return if the cover is closed."""
if self._state == STATE_UNKNOWN:
return None
else:
return self._state == STATE_CLOSED
@property

View File

@ -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 = HMCover(hass, config)
for conf in discovery_info[ATTR_DISCOVER_DEVICES]:
new_device = HMCover(hass, conf)
new_device.link_homematic()
devices.append(new_device)
@ -52,10 +52,7 @@ class HMCover(HMDevice, CoverDevice):
def is_closed(self):
"""Return if the cover is closed."""
if self.current_cover_position is not None:
if self.current_cover_position > 0:
return False
else:
return True
return self.current_cover_position == 0
def open_cover(self, **kwargs):
"""Open the cover."""

View File

@ -361,7 +361,6 @@ class MqttCover(CoverDevice):
position_percentage = float(offset_position) / tilt_range * 100.0
if self._tilt_invert:
return 100 - position_percentage
else:
return position_percentage
def find_in_range_from_percent(self, percentage):

View File

@ -53,7 +53,6 @@ class MySensorsCover(mysensors.MySensorsDeviceEntity, CoverDevice):
set_req = self.gateway.const.SetReq
if set_req.V_DIMMER in self._values:
return self._values.get(set_req.V_DIMMER) == 0
else:
return self._values.get(set_req.V_LIGHT) == STATE_OFF
@property

View File

@ -117,7 +117,6 @@ class OpenGarageCover(CoverDevice):
"""Return if the cover is closed."""
if self._state == STATE_UNKNOWN:
return None
else:
return self._state in [STATE_CLOSED, STATE_OPENING]
def close_cover(self):

View File

@ -53,10 +53,7 @@ class VeraCover(VeraDevice, CoverDevice):
def is_closed(self):
"""Return if the cover is closed."""
if self.current_cover_position is not None:
if self.current_cover_position > 0:
return False
else:
return True
return self.current_cover_position == 0
def open_cover(self, **kwargs):
"""Open the cover."""

View File

@ -73,7 +73,6 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
return None
if self.current_cover_position > 0:
return False
else:
return True
@property
@ -86,7 +85,6 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
return 0
elif self._current_position >= 95:
return 100
else:
return self._current_position
def open_cover(self, **kwargs):

View File

@ -52,7 +52,6 @@ class BboxDeviceScanner(DeviceScanner):
if filter_named:
return filter_named[0]
else:
return None
@Throttle(MIN_TIME_BETWEEN_SCANS)

View File

@ -94,7 +94,7 @@ class LocativeView(HomeAssistantView):
partial(self.see, dev_id=device,
location_name=location_name, gps=gps_location))
return 'Setting location to not home'
else:
# Ignore the message if it is telling us to exit a zone that we
# aren't currently in. This occurs when a zone is entered
# before the previous zone was exited. The enter message will
@ -107,7 +107,6 @@ class LocativeView(HomeAssistantView):
# the user to let them know that it works.
return 'Received test message.'
else:
_LOGGER.error('Received unidentified message from Locative: %s',
direction)
return ('Received unidentified message: {}'.format(direction),

View File

@ -95,7 +95,6 @@ class NmapDeviceScanner(DeviceScanner):
if filter_named:
return filter_named[0]
else:
return None
@Throttle(MIN_TIME_BETWEEN_SCANS)

View File

@ -131,7 +131,6 @@ def async_setup_scanner(hass, config, async_see, discovery_info=None):
plaintext_payload = decrypt_payload(topic, data['data'])
if plaintext_payload is None:
return None
else:
return validate_payload(topic, plaintext_payload, data_type)
if not isinstance(data, dict) or data.get('_type') != data_type:

View File

@ -90,7 +90,6 @@ class TadoDeviceScanner(DeviceScanner):
if filter_named:
return filter_named[0]
else:
return None
@Throttle(MIN_TIME_BETWEEN_SCANS)

View File

@ -73,7 +73,7 @@ class TomatoDeviceScanner(DeviceScanner):
if not filter_named or not filter_named[0]:
return None
else:
return filter_named[0]
@Throttle(MIN_TIME_BETWEEN_SCANS)

View File

@ -234,7 +234,6 @@ class Tplink3DeviceScanner(TplinkDeviceScanner):
self.stok = ''
self.sysauth = ''
return False
else:
_LOGGER.error(
"An unknown error happened while fetching data")
return False

View File

@ -101,7 +101,7 @@ class XiaomiDeviceScanner(DeviceScanner):
result = _retrieve_list(self.host, self.token)
if result:
return result
else:
_LOGGER.info("Refreshing token and retrying device list refresh")
self.token = _get_token(self.host, self.username, self.password)
return _retrieve_list(self.host, self.token)

View File

@ -157,7 +157,6 @@ class DysonPureCoolLinkDevice(FanEntity):
from libpurecoollink.const import FanSpeed
if self._device.state.speed == FanSpeed.FAN_SPEED_AUTO.value:
return self._device.state.speed
else:
return int(self._device.state.speed)
return None

View File

@ -33,10 +33,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class WinkFanDevice(WinkDevice, FanEntity):
"""Representation of a Wink fan."""
def __init__(self, wink, hass):
"""Initialize the fan."""
super().__init__(wink, hass)
@asyncio.coroutine
def async_added_to_hass(self):
"""Callback when entity is added to hass."""

View File

@ -57,9 +57,9 @@ class DlibFaceIdentifyEntity(ImageProcessingFaceEntity):
split_entity_id(camera_entity)[1])
self._faces = {}
for name, face_file in faces.items():
for face_name, face_file in faces.items():
image = face_recognition.load_image_file(face_file)
self._faces[name] = face_recognition.face_encodings(image)[0]
self._faces[face_name] = face_recognition.face_encodings(image)[0]
@property
def camera_entity(self):

View File

@ -60,7 +60,6 @@ class TellstickLight(TellstickDevice, Light):
if tellcore_data is not None:
brightness = int(tellcore_data)
return brightness
else:
return None
def _update_model(self, new_state, data):

View File

@ -50,7 +50,6 @@ class VeraLight(VeraDevice, Light):
"""Flag supported features."""
if self._color:
return SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
else:
return SUPPORT_BRIGHTNESS
def turn_on(self, **kwargs):

View File

@ -33,10 +33,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class WinkLight(WinkDevice, Light):
"""Representation of a Wink light."""
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."""
@ -52,7 +48,6 @@ class WinkLight(WinkDevice, Light):
"""Return the brightness of the light."""
if self.wink.brightness() is not None:
return int(self.wink.brightness() * 255)
else:
return None
@property

View File

@ -55,7 +55,6 @@ def get_device(node, values, node_config, **kwargs):
if node.has_command_class(zwave.const.COMMAND_CLASS_SWITCH_COLOR):
return ZwaveColorLight(values, refresh, delay)
else:
return ZwaveDimmer(values, refresh, delay)
@ -63,7 +62,6 @@ def brightness_state(value):
"""Return the brightness and state."""
if value.data > 0:
return round((value.data / 99) * 255, 0), STATE_ON
else:
return 0, STATE_OFF

View File

@ -86,7 +86,7 @@ class Lockitron(LockDevice):
self.device_id, self.access_token, requested_state), timeout=5)
if response.status_code == 200:
return response.json()['state']
else:
_LOGGER.error("Error setting lock state: %s\n%s",
requested_state, response.text)
return self._state

View File

@ -119,10 +119,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class WinkLockDevice(WinkDevice, LockDevice):
"""Representation of a Wink lock."""
def __init__(self, wink, hass):
"""Initialize the lock."""
super().__init__(wink, hass)
@asyncio.coroutine
def async_added_to_hass(self):
"""Callback when entity is added to hass."""

View File

@ -102,7 +102,6 @@ class AnthemAVR(MediaPlayerDevice):
return STATE_ON
elif pwrstate is False:
return STATE_OFF
else:
return STATE_UNKNOWN
@property

View File

@ -106,7 +106,6 @@ class AppleTvDevice(MediaPlayerDevice):
state == const.PLAY_STATE_FAST_BACKWARD:
# Catch fast forward/backward here so "play" is default action
return STATE_PAUSED
else:
return STATE_STANDBY # Bad or unknown state?
@callback

View File

@ -59,7 +59,6 @@ def _get_mac_address(ip_address):
pid_component)
if match is not None:
return match.groups()[0]
else:
return None
@ -307,7 +306,6 @@ class BraviaTVDevice(MediaPlayerDevice):
"""Volume level of the media player (0..1)."""
if self._volume is not None:
return self._volume / 100
else:
return None
@property

View File

@ -94,7 +94,6 @@ class CmusDevice(MediaPlayerDevice):
return STATE_PLAYING
elif self.status.get('status') == 'paused':
return STATE_PAUSED
else:
return STATE_OFF
@property

View File

@ -55,9 +55,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if denon.update():
add_devices([denon])
return True
else:
return False
class DenonDevice(MediaPlayerDevice):
@ -197,7 +194,6 @@ class DenonDevice(MediaPlayerDevice):
"""Flag media player features that are supported."""
if self._mediasource in MEDIA_MODES.values():
return SUPPORT_DENON | SUPPORT_MEDIA_MODES
else:
return SUPPORT_DENON
@property

View File

@ -144,10 +144,9 @@ class DirecTvDevice(MediaPlayerDevice):
"""Return the channel current playing media."""
if self._is_standby:
return None
else:
chan = "{} ({})".format(
return "{} ({})".format(
self._current['callsign'], self._current['major'])
return chan
def turn_on(self):
"""Turn on the receiver."""

View File

@ -306,7 +306,6 @@ class EmbyDevice(MediaPlayerDevice):
"""Flag media player features that are supported."""
if self.supports_remote_control:
return SUPPORT_EMBY
else:
return None
def async_media_play(self):

View File

@ -60,7 +60,7 @@ class Itunes(object):
if self.port:
return '{}{}:{}'.format(uri_scheme, self.host, self.port)
else:
return '{}{}'.format(uri_scheme, self.host)
def _request(self, method, path, params=None):
@ -225,7 +225,7 @@ class ItunesDevice(MediaPlayerDevice):
if self.player_state == 'paused':
return STATE_PAUSED
else:
return STATE_PLAYING
def update(self):
@ -281,7 +281,7 @@ class ItunesDevice(MediaPlayerDevice):
if self.player_state in (STATE_PLAYING, STATE_IDLE, STATE_PAUSED) and \
self.current_title is not None:
return self.client.artwork_url()
else:
return 'https://cloud.githubusercontent.com/assets/260/9829355' \
'/33fab972-58cf-11e5-8ea2-2ca74bdaae40.png'
@ -400,7 +400,7 @@ class AirPlayDevice(MediaPlayerDevice):
"""Return the icon to use in the frontend, if any."""
if self.selected is True:
return 'mdi:volume-high'
else:
return 'mdi:volume-off'
@property
@ -408,7 +408,7 @@ class AirPlayDevice(MediaPlayerDevice):
"""Return the state of the device."""
if self.selected is True:
return STATE_ON
else:
return STATE_OFF
def update(self):

View File

@ -334,7 +334,7 @@ class KodiDevice(MediaPlayerDevice):
if self._properties['speed'] == 0 and not self._properties['live']:
return STATE_PAUSED
else:
return STATE_PLAYING
@asyncio.coroutine
@ -407,7 +407,7 @@ class KodiDevice(MediaPlayerDevice):
"""Active server for json-rpc requests."""
if self._enable_websocket and self._ws_server.connected:
return self._ws_server
else:
return self._http_server
@property
@ -503,7 +503,7 @@ class KodiDevice(MediaPlayerDevice):
artists = self._item.get('artist', [])
if artists:
return artists[0]
else:
return None
@property
@ -512,7 +512,7 @@ class KodiDevice(MediaPlayerDevice):
artists = self._item.get('albumartist', [])
if artists:
return artists[0]
else:
return None
@property
@ -678,7 +678,7 @@ class KodiDevice(MediaPlayerDevice):
elif media_type == "PLAYLIST":
return self.server.Player.Open(
{"item": {"playlistid": int(media_id)}})
else:
return self.server.Player.Open(
{"item": {"file": str(media_id)}})
@ -794,7 +794,7 @@ class KodiDevice(MediaPlayerDevice):
"""Get albums list."""
if artist_id is None:
return (yield from self.server.AudioLibrary.GetAlbums())
else:
return (yield from self.server.AudioLibrary.GetAlbums(
{"filter": {"artistid": int(artist_id)}}))
@ -815,7 +815,7 @@ class KodiDevice(MediaPlayerDevice):
"""Get songs list."""
if artist_id is None:
return (yield from self.server.AudioLibrary.GetSongs())
else:
return (yield from self.server.AudioLibrary.GetSongs(
{"filter": {"artistid": int(artist_id)}}))

View File

@ -159,9 +159,8 @@ class LiveboxPlayTvDevice(MediaPlayerDevice):
return STATE_PLAYING
elif state == 'PAUSE':
return STATE_PAUSED
else:
return STATE_ON if self._client.is_on else STATE_OFF
return STATE_UNKNOWN
def turn_off(self):
"""Turn off media player."""

View File

@ -97,7 +97,7 @@ class MpcHcDevice(MediaPlayerDevice):
return STATE_PLAYING
elif state == 'paused':
return STATE_PAUSED
else:
return STATE_IDLE
@property

View File

@ -133,7 +133,7 @@ class MpdDevice(MediaPlayerDevice):
return STATE_PLAYING
elif self.status['state'] == 'pause':
return STATE_PAUSED
else:
return STATE_OFF
@property
@ -164,7 +164,7 @@ class MpdDevice(MediaPlayerDevice):
return title
elif title is None:
return name
else:
return '{}: {}'.format(name, title)
@property

View File

@ -358,7 +358,7 @@ def _pianobar_exists():
pianobar_exe = shutil.which('pianobar')
if pianobar_exe:
return True
else:
_LOGGER.warning(
"The Pandora component depends on the Pianobar client, which "
"cannot be found. Please install using instructions at "

View File

@ -47,9 +47,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if pioneer.update():
add_devices([pioneer])
return True
else:
return False
class PioneerDevice(MediaPlayerDevice):

View File

@ -531,7 +531,7 @@ class PlexClient(MediaPlayerDevice):
# type so that lower layers don't think it's a URL and choke on it
if value is self.na_type:
return None
else:
return value
@property
@ -539,7 +539,7 @@ class PlexClient(MediaPlayerDevice):
"""Get the active media type required by PlexAPI commands."""
if self.media_content_type is MEDIA_TYPE_MUSIC:
return 'music'
else:
return 'video'
@property
@ -560,7 +560,7 @@ class PlexClient(MediaPlayerDevice):
return MEDIA_TYPE_VIDEO
elif self._session_type == 'track':
return MEDIA_TYPE_MUSIC
else:
return None
@property
@ -657,7 +657,7 @@ class PlexClient(MediaPlayerDevice):
SUPPORT_NEXT_TRACK | SUPPORT_STOP |
SUPPORT_VOLUME_SET | SUPPORT_PLAY |
SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE)
else:
return None
def _local_client_control_fix(self):

View File

@ -220,7 +220,7 @@ def _parse_timespan(timespan):
"""Parse a time-span into number of seconds."""
if timespan in ('', 'NOT_IMPLEMENTED', None):
return None
else:
return sum(60 ** x[0] * int(x[1]) for x in enumerate(
reversed(timespan.split(':'))))
@ -765,7 +765,7 @@ class SonosDevice(MediaPlayerDevice):
"""Content ID of current playing media."""
if self._coordinator:
return self._coordinator.media_content_id
else:
return self._media_content_id
@property
@ -778,7 +778,7 @@ class SonosDevice(MediaPlayerDevice):
"""Duration of current playing media in seconds."""
if self._coordinator:
return self._coordinator.media_duration
else:
return self._media_duration
@property
@ -786,7 +786,7 @@ class SonosDevice(MediaPlayerDevice):
"""Position of current playing media in seconds."""
if self._coordinator:
return self._coordinator.media_position
else:
return self._media_position
@property
@ -797,7 +797,7 @@ class SonosDevice(MediaPlayerDevice):
"""
if self._coordinator:
return self._coordinator.media_position_updated_at
else:
return self._media_position_updated_at
@property
@ -805,7 +805,7 @@ class SonosDevice(MediaPlayerDevice):
"""Image url of current playing media."""
if self._coordinator:
return self._coordinator.media_image_url
else:
return self._media_image_url
@property
@ -813,7 +813,7 @@ class SonosDevice(MediaPlayerDevice):
"""Artist of current playing media, music track only."""
if self._coordinator:
return self._coordinator.media_artist
else:
return self._media_artist
@property
@ -821,7 +821,7 @@ class SonosDevice(MediaPlayerDevice):
"""Album name of current playing media, music track only."""
if self._coordinator:
return self._coordinator.media_album_name
else:
return self._media_album_name
@property
@ -829,7 +829,7 @@ class SonosDevice(MediaPlayerDevice):
"""Title of current playing media."""
if self._coordinator:
return self._coordinator.media_title
else:
return self._media_title
@property
@ -919,7 +919,7 @@ class SonosDevice(MediaPlayerDevice):
"""Name of the current input source."""
if self._coordinator:
return self._coordinator.source
else:
return self._source_name
@soco_error

View File

@ -200,7 +200,7 @@ class SoundTouchDevice(MediaPlayerDevice):
"""Return the state of the device."""
if self._status.source == 'STANDBY':
return STATE_OFF
else:
return MAP_STATUS.get(self._status.play_status, STATE_UNAVAILABLE)
@property
@ -280,7 +280,7 @@ class SoundTouchDevice(MediaPlayerDevice):
return self._status.station_name
elif self._status.artist is not None:
return self._status.artist + " - " + self._status.track
else:
return None
@property

View File

@ -215,7 +215,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
master_state = self._entity_lkp(
self._attrs[CONF_STATE][0], self._attrs[CONF_STATE][1])
return master_state if master_state else STATE_OFF
else:
return None
@property

View File

@ -113,7 +113,7 @@ class Volumio(MediaPlayerDevice):
return STATE_PAUSED
elif status == 'play':
return STATE_PLAYING
else:
return STATE_IDLE
@property
@ -207,6 +207,6 @@ class Volumio(MediaPlayerDevice):
self._lastvol = self._state['volume']
return self.send_volumio_msg(
'commands', params={'cmd': 'volume', 'volume': mutecmd})
else:
return self.send_volumio_msg(
'commands', params={'cmd': 'volume', 'volume': self._lastvol})

View File

@ -289,5 +289,5 @@ class YamahaDevice(MediaPlayerDevice):
# just the one we have.
if song and station:
return '{}: {}'.format(station, song)
else:
return song or station

View File

@ -42,7 +42,7 @@ def get_service(hass, config, discovery_info=None):
config.get(CONF_RECIPIENT))
if mailgun_service.connection_is_valid():
return mailgun_service
else:
return None

View File

@ -74,7 +74,7 @@ def get_service(hass, config, discovery_info=None):
if mail_service.connection_is_valid():
return mail_service
else:
return None

View File

@ -173,5 +173,5 @@ def _process_timestamp(ts):
return None
elif ts.tzinfo is None:
return dt_util.UTC.localize(ts)
else:
return dt_util.as_utc(ts)

View File

@ -62,7 +62,7 @@ def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
elif status == 401:
_LOGGER.error("Unauthorized (bad token?) on %s", url)
return False
else:
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
return False

View File

@ -146,7 +146,4 @@ class ArwnSensor(Entity):
@property
def icon(self):
"""Return the icon of device based on its type."""
if self._icon:
return self._icon
else:
return super().icon

View File

@ -139,7 +139,7 @@ class BOMCurrentSensor(Entity):
"""Return the name of the sensor."""
if self.stationname is None:
return 'BOM {}'.format(SENSOR_TYPES[self._condition][0])
else:
return 'BOM {} {}'.format(
self.stationname, SENSOR_TYPES[self._condition][0])
@ -148,7 +148,7 @@ class BOMCurrentSensor(Entity):
"""Return the state of the sensor."""
if self.rest.data and self._condition in self.rest.data:
return self.rest.data[self._condition]
else:
return STATE_UNKNOWN
@property

View File

@ -167,7 +167,7 @@ class BrSensor(Entity):
if self.type != SYMBOL:
return None
else:
return self._entity_picture
@property

View File

@ -187,7 +187,7 @@ class DarkSkySensor(Entity):
"""Return the name of the sensor."""
if self.forecast_day == 0:
return '{} {}'.format(self.client_name, self._name)
else:
return '{} {} {}'.format(
self.client_name, self._name, self.forecast_day)
@ -214,7 +214,7 @@ class DarkSkySensor(Entity):
if self._icon in CONDITION_PICTURES:
return CONDITION_PICTURES[self._icon]
else:
return None
def update_unit_of_measurement(self):

View File

@ -207,10 +207,10 @@ class DSMREntity(Entity):
if self._obis == obis.ELECTRICITY_ACTIVE_TARIFF:
return self.translate_tariff(value)
else:
if value is not None:
return value
else:
return STATE_UNKNOWN
@property
@ -227,7 +227,7 @@ class DSMREntity(Entity):
return 'normal'
elif value == '0001':
return 'low'
else:
return STATE_UNKNOWN

View File

@ -59,7 +59,6 @@ class DysonFilterLifeSensor(Entity):
"""Return filter life in hours.."""
if self._device.state:
return self._device.state.filter_life
else:
return STATE_UNKNOWN
@property

View File

@ -86,7 +86,6 @@ def get_from_conf(config, config_key, length):
_LOGGER.error("Error in config parameter %s: Must be exactly %d "
"bytes. Device will not be added", config_key, length/2)
return None
else:
return string

View File

@ -155,8 +155,8 @@ class EightUserSensor(EightSleepUserEntity):
elif 'bed_temp' in self._sensor:
if self._units == 'si':
return '°C'
else:
return '°F'
return None
@property
def icon(self):
@ -264,7 +264,6 @@ class EightRoomSensor(EightSleepUserEntity):
"""Return the unit the value is expressed in."""
if self._units == 'si':
return '°C'
else:
return '°F'
@property

View File

@ -91,10 +91,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
_stop_listener
)
if monitor.sock is None:
return False
else:
return True
return monitor.sock is not None
class FritzBoxCallSensor(Entity):
@ -118,10 +115,7 @@ class FritzBoxCallSensor(Entity):
@property
def should_poll(self):
"""Only poll to update phonebook, if defined."""
if self.phonebook is None:
return False
else:
return True
return self.phonebook is not None
@property
def state(self):
@ -142,7 +136,6 @@ class FritzBoxCallSensor(Entity):
"""Return a name for a given phone number."""
if self.phonebook is None:
return 'unknown'
else:
return self.phonebook.get_name(number)
def update(self):

View File

@ -89,7 +89,6 @@ class GlancesSensor(Entity):
"""Return the name of the sensor."""
if self._name is None:
return SENSOR_TYPES[self.type][0]
else:
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
@property

View File

@ -94,7 +94,6 @@ class GpsdSensor(Entity):
return "3D Fix"
elif self.agps_thread.data_stream.mode == 2:
return "2D Fix"
else:
return STATE_UNKNOWN
@property

View File

@ -77,7 +77,6 @@ class HddTempSensor(Entity):
"""Return the unit the value is expressed in."""
if self._details[4] == 'C':
return TEMP_CELSIUS
else:
return TEMP_FAHRENHEIT
@property

View File

@ -296,7 +296,6 @@ class HistoryStatsHelper:
return '%dd %dh %dm' % (days, hours, minutes)
elif hours > 0:
return '%dh %dm' % (hours, minutes)
else:
return '%dm' % minutes
@staticmethod

View File

@ -121,7 +121,6 @@ class IOSSensor(Entity):
if self.type == "state":
return returning_icon_state
else:
return returning_icon_level
def update(self):

View File

@ -310,7 +310,6 @@ class ISYSensorDevice(isy.ISYDevice):
raw_units = self.raw_unit_of_measurement
if raw_units in (TEMP_FAHRENHEIT, TEMP_CELSIUS):
return self.hass.config.units.temperature_unit
else:
return raw_units

View File

@ -105,7 +105,6 @@ class KWBSensor(Entity):
"""Return the state of value."""
if self._sensor.value is not None and self._sensor.available:
return self._sensor.value
else:
return STATE_UNKNOWN
@property

View File

@ -124,9 +124,7 @@ class MetOfficeCurrentSensor(Entity):
if self._condition == "weather":
return [k for k, v in CONDITION_CLASSES.items() if
self.data.data.weather.value in v][0]
else:
return variable.value
else:
return STATE_UNKNOWN
@property

View File

@ -64,7 +64,6 @@ class MoonSensor(Entity):
return 'Waning gibbous'
elif self._state == 21:
return 'Last quarter'
else:
return 'Waning crescent'
@property

View File

@ -91,7 +91,6 @@ class MVGLiveSensor(Entity):
"""Return the name of the sensor."""
if self._name:
return self._name
else:
return self._station
@property

View File

@ -136,10 +136,7 @@ class NeatoConnectedSensor(Entity):
@property
def available(self):
"""Return True if sensor data is available."""
if not self._state:
return False
else:
return True
return self._state
@property
def state(self):

View File

@ -14,7 +14,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.const import (
CONF_HOST, CONF_PORT, STATE_UNKNOWN, CONF_NAME, CONF_RESOURCES)
CONF_HOST, CONF_PORT, CONF_NAME, CONF_RESOURCES)
from homeassistant.helpers.entity import Entity
_LOGGER = logging.getLogger(__name__)
@ -110,8 +110,7 @@ class NetdataSensor(Entity):
netdata_id = SENSOR_TYPES[self.type][3]
if netdata_id in value:
return "{0:.{1}f}".format(value[netdata_id], self._precision)
else:
return STATE_UNKNOWN
return None
@property
def available(self):

View File

@ -60,7 +60,6 @@ class OhmconnectSensor(Entity):
"""Return the state of the sensor."""
if self._data.get("active") == "True":
return "Active"
else:
return "Inactive"
@property

View File

@ -15,8 +15,7 @@ from homeassistant.helpers.entity import Entity
from homeassistant.components.sensor import PLATFORM_SCHEMA
from homeassistant.components.sensor.rest import RestData
from homeassistant.const import (
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, STATE_UNKNOWN, ATTR_DATE,
ATTR_TIME)
ATTR_TEMPERATURE, CONF_API_KEY, CONF_NAME, ATTR_DATE, ATTR_TIME)
_LOGGER = logging.getLogger(__name__)
_ENDPOINT = 'http://pvoutput.org/service/r2/getstatus.jsp'
@ -90,8 +89,7 @@ class PvoutputSensor(Entity):
"""Return the state of the device."""
if self.pvcoutput is not None:
return self.pvcoutput.energy_generation
else:
return STATE_UNKNOWN
return None
@property
def device_state_attributes(self):

View File

@ -232,7 +232,6 @@ class QNAPSensor(Entity):
if self.monitor_device is not None:
return "{} {} ({})".format(
server_name, self.var_name, self.monitor_device)
else:
return "{} {}".format(server_name, self.var_name)
@property

View File

@ -90,7 +90,6 @@ class SwissHydrologicalDataSensor(Entity):
"""Return the unit of measurement of this entity, if any."""
if self._state is not STATE_UNKNOWN:
return self._unit_of_measurement
else:
return None
@property

View File

@ -177,7 +177,6 @@ class SynoNasSensor(Entity):
"""Return the name of the sensor, if any."""
if self.monitor_device is not None:
return "{} ({})".format(self.var_name, self.monitor_device)
else:
return self.var_name
@property
@ -191,7 +190,6 @@ class SynoNasSensor(Entity):
if self.var_id in ['volume_disk_temp_avg', 'volume_disk_temp_max',
'disk_temp']:
return self._api.temp_unit
else:
return self.var_units
def update(self):
@ -238,8 +236,8 @@ class SynoNasStorageSensor(SynoNasSensor):
if self._api.temp_unit == TEMP_CELSIUS:
return attr
else:
return round(attr * 1.8 + 32.0, 1)
else:
return getattr(self._api.storage,
self.var_id)(self.monitor_device)

View File

@ -30,7 +30,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
zones = tado.get_zones()
except RuntimeError:
_LOGGER.error("Unable to get zone info from mytado")
return False
return
sensor_items = []
for zone in zones:
@ -47,9 +47,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if sensor_items:
add_devices(sensor_items, True)
return True
else:
return False
def create_zone_sensor(tado, zone, name, zone_id, variable):

View File

@ -92,7 +92,6 @@ class TelldusLiveSensor(TelldusLiveEntity):
return self._value_as_humidity
elif self._type == SENSOR_TYPE_LUMINANCE:
return self._value_as_luminance
else:
return self._value
@property

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