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 return STATE_ALARM_ARMED_HOME
elif self._alarm.state.lower() == 'armed away': elif self._alarm.state.lower() == 'armed away':
return STATE_ALARM_ARMED_AWAY return STATE_ALARM_ARMED_AWAY
else:
return STATE_UNKNOWN return STATE_UNKNOWN
@asyncio.coroutine @asyncio.coroutine

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -134,7 +134,7 @@ class GenericThermostat(ClimateDevice):
if self.ac_mode: if self.ac_mode:
cooling = self._active and self._is_device_active cooling = self._active and self._is_device_active
return STATE_COOL if cooling else STATE_IDLE return STATE_COOL if cooling else STATE_IDLE
else:
heating = self._active and self._is_device_active heating = self._active and self._is_device_active
return STATE_HEAT if heating else STATE_IDLE return STATE_HEAT if heating else STATE_IDLE
@ -159,7 +159,7 @@ class GenericThermostat(ClimateDevice):
# pylint: disable=no-member # pylint: disable=no-member
if self._min_temp: if self._min_temp:
return self._min_temp return self._min_temp
else:
# get default temp from super class # get default temp from super class
return ClimateDevice.min_temp.fget(self) return ClimateDevice.min_temp.fget(self)
@ -169,7 +169,7 @@ class GenericThermostat(ClimateDevice):
# pylint: disable=no-member # pylint: disable=no-member
if self._max_temp: if self._max_temp:
return self._max_temp return self._max_temp
else:
# Get default temp from super class # Get default temp from super class
return ClimateDevice.max_temp.fget(self) 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': if region == 'us':
return _setup_us(username, password, config, add_devices) return _setup_us(username, password, config, add_devices)
else:
return _setup_round(username, password, config, add_devices) return _setup_round(username, password, config, add_devices)
@ -251,7 +251,6 @@ class HoneywellUSThermostat(ClimateDevice):
"""Return the temperature we try to reach.""" """Return the temperature we try to reach."""
if self._device.system_mode == 'cool': if self._device.system_mode == 'cool':
return self._device.setpoint_cool return self._device.setpoint_cool
else:
return self._device.setpoint_heat return self._device.setpoint_heat
@property @property

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -361,7 +361,6 @@ class MqttCover(CoverDevice):
position_percentage = float(offset_position) / tilt_range * 100.0 position_percentage = float(offset_position) / tilt_range * 100.0
if self._tilt_invert: if self._tilt_invert:
return 100 - position_percentage return 100 - position_percentage
else:
return position_percentage return position_percentage
def find_in_range_from_percent(self, 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 set_req = self.gateway.const.SetReq
if set_req.V_DIMMER in self._values: if set_req.V_DIMMER in self._values:
return self._values.get(set_req.V_DIMMER) == 0 return self._values.get(set_req.V_DIMMER) == 0
else:
return self._values.get(set_req.V_LIGHT) == STATE_OFF return self._values.get(set_req.V_LIGHT) == STATE_OFF
@property @property

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -95,7 +95,6 @@ class NmapDeviceScanner(DeviceScanner):
if filter_named: if filter_named:
return filter_named[0] return filter_named[0]
else:
return None return None
@Throttle(MIN_TIME_BETWEEN_SCANS) @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']) plaintext_payload = decrypt_payload(topic, data['data'])
if plaintext_payload is None: if plaintext_payload is None:
return None return None
else:
return validate_payload(topic, plaintext_payload, data_type) return validate_payload(topic, plaintext_payload, data_type)
if not isinstance(data, dict) or data.get('_type') != 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: if filter_named:
return filter_named[0] return filter_named[0]
else:
return None return None
@Throttle(MIN_TIME_BETWEEN_SCANS) @Throttle(MIN_TIME_BETWEEN_SCANS)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -57,9 +57,9 @@ class DlibFaceIdentifyEntity(ImageProcessingFaceEntity):
split_entity_id(camera_entity)[1]) split_entity_id(camera_entity)[1])
self._faces = {} 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) 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 @property
def camera_entity(self): def camera_entity(self):

View File

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

View File

@ -50,7 +50,6 @@ class VeraLight(VeraDevice, Light):
"""Flag supported features.""" """Flag supported features."""
if self._color: if self._color:
return SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR return SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
else:
return SUPPORT_BRIGHTNESS return SUPPORT_BRIGHTNESS
def turn_on(self, **kwargs): 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): class WinkLight(WinkDevice, Light):
"""Representation of a Wink light.""" """Representation of a Wink light."""
def __init__(self, wink, hass):
"""Initialize the Wink device."""
super().__init__(wink, hass)
@asyncio.coroutine @asyncio.coroutine
def async_added_to_hass(self): def async_added_to_hass(self):
"""Callback when entity is added to hass.""" """Callback when entity is added to hass."""
@ -52,7 +48,6 @@ class WinkLight(WinkDevice, Light):
"""Return the brightness of the light.""" """Return the brightness of the light."""
if self.wink.brightness() is not None: if self.wink.brightness() is not None:
return int(self.wink.brightness() * 255) return int(self.wink.brightness() * 255)
else:
return None return None
@property @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): if node.has_command_class(zwave.const.COMMAND_CLASS_SWITCH_COLOR):
return ZwaveColorLight(values, refresh, delay) return ZwaveColorLight(values, refresh, delay)
else:
return ZwaveDimmer(values, refresh, delay) return ZwaveDimmer(values, refresh, delay)
@ -63,7 +62,6 @@ def brightness_state(value):
"""Return the brightness and state.""" """Return the brightness and state."""
if value.data > 0: if value.data > 0:
return round((value.data / 99) * 255, 0), STATE_ON return round((value.data / 99) * 255, 0), STATE_ON
else:
return 0, STATE_OFF return 0, STATE_OFF

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -358,7 +358,7 @@ def _pianobar_exists():
pianobar_exe = shutil.which('pianobar') pianobar_exe = shutil.which('pianobar')
if pianobar_exe: if pianobar_exe:
return True return True
else:
_LOGGER.warning( _LOGGER.warning(
"The Pandora component depends on the Pianobar client, which " "The Pandora component depends on the Pianobar client, which "
"cannot be found. Please install using instructions at " "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(): if pioneer.update():
add_devices([pioneer]) add_devices([pioneer])
return True
else:
return False
class PioneerDevice(MediaPlayerDevice): 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 # type so that lower layers don't think it's a URL and choke on it
if value is self.na_type: if value is self.na_type:
return None return None
else:
return value return value
@property @property
@ -539,7 +539,7 @@ class PlexClient(MediaPlayerDevice):
"""Get the active media type required by PlexAPI commands.""" """Get the active media type required by PlexAPI commands."""
if self.media_content_type is MEDIA_TYPE_MUSIC: if self.media_content_type is MEDIA_TYPE_MUSIC:
return 'music' return 'music'
else:
return 'video' return 'video'
@property @property
@ -560,7 +560,7 @@ class PlexClient(MediaPlayerDevice):
return MEDIA_TYPE_VIDEO return MEDIA_TYPE_VIDEO
elif self._session_type == 'track': elif self._session_type == 'track':
return MEDIA_TYPE_MUSIC return MEDIA_TYPE_MUSIC
else:
return None return None
@property @property
@ -657,7 +657,7 @@ class PlexClient(MediaPlayerDevice):
SUPPORT_NEXT_TRACK | SUPPORT_STOP | SUPPORT_NEXT_TRACK | SUPPORT_STOP |
SUPPORT_VOLUME_SET | SUPPORT_PLAY | SUPPORT_VOLUME_SET | SUPPORT_PLAY |
SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE) SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE)
else:
return None return None
def _local_client_control_fix(self): def _local_client_control_fix(self):

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -173,5 +173,5 @@ def _process_timestamp(ts):
return None return None
elif ts.tzinfo is None: elif ts.tzinfo is None:
return dt_util.UTC.localize(ts) return dt_util.UTC.localize(ts)
else:
return dt_util.as_utc(ts) 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: elif status == 401:
_LOGGER.error("Unauthorized (bad token?) on %s", url) _LOGGER.error("Unauthorized (bad token?) on %s", url)
return False return False
else:
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url) _LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
return False return False

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -59,7 +59,6 @@ class DysonFilterLifeSensor(Entity):
"""Return filter life in hours..""" """Return filter life in hours.."""
if self._device.state: if self._device.state:
return self._device.state.filter_life return self._device.state.filter_life
else:
return STATE_UNKNOWN return STATE_UNKNOWN
@property @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 " _LOGGER.error("Error in config parameter %s: Must be exactly %d "
"bytes. Device will not be added", config_key, length/2) "bytes. Device will not be added", config_key, length/2)
return None return None
else:
return string return string

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -177,7 +177,6 @@ class SynoNasSensor(Entity):
"""Return the name of the sensor, if any.""" """Return the name of the sensor, if any."""
if self.monitor_device is not None: if self.monitor_device is not None:
return "{} ({})".format(self.var_name, self.monitor_device) return "{} ({})".format(self.var_name, self.monitor_device)
else:
return self.var_name return self.var_name
@property @property
@ -191,7 +190,6 @@ class SynoNasSensor(Entity):
if self.var_id in ['volume_disk_temp_avg', 'volume_disk_temp_max', if self.var_id in ['volume_disk_temp_avg', 'volume_disk_temp_max',
'disk_temp']: 'disk_temp']:
return self._api.temp_unit return self._api.temp_unit
else:
return self.var_units return self.var_units
def update(self): def update(self):
@ -238,8 +236,8 @@ class SynoNasStorageSensor(SynoNasSensor):
if self._api.temp_unit == TEMP_CELSIUS: if self._api.temp_unit == TEMP_CELSIUS:
return attr return attr
else:
return round(attr * 1.8 + 32.0, 1) return round(attr * 1.8 + 32.0, 1)
else:
return getattr(self._api.storage, return getattr(self._api.storage,
self.var_id)(self.monitor_device) 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() zones = tado.get_zones()
except RuntimeError: except RuntimeError:
_LOGGER.error("Unable to get zone info from mytado") _LOGGER.error("Unable to get zone info from mytado")
return False return
sensor_items = [] sensor_items = []
for zone in zones: for zone in zones:
@ -47,9 +47,6 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
if sensor_items: if sensor_items:
add_devices(sensor_items, True) add_devices(sensor_items, True)
return True
else:
return False
def create_zone_sensor(tado, zone, name, zone_id, variable): def create_zone_sensor(tado, zone, name, zone_id, variable):

View File

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

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