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:
parent
5779d64e98
commit
46e030662d
111 changed files with 305 additions and 455 deletions
|
@ -92,8 +92,7 @@ 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
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_alarm_disarm(self, code=None):
|
||||
|
|
|
@ -113,8 +113,7 @@ 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}$'
|
||||
return '^\\d{4,6}$'
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
|
|
@ -99,8 +99,7 @@ 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._pre_trigger_state
|
||||
|
||||
return self._state
|
||||
|
||||
|
|
|
@ -80,8 +80,7 @@ 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())
|
||||
return 'Alarm {}'.format(self.simplisafe.location_id())
|
||||
|
||||
@property
|
||||
def code_format(self):
|
||||
|
|
|
@ -199,11 +199,10 @@ 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)
|
||||
return False
|
||||
_LOGGER.info(
|
||||
"Queued %s allowed for %s. Time in queue was %s",
|
||||
click_type, self.address, time_string)
|
||||
return False
|
||||
|
||||
def _on_up_down(self, channel, click_type, was_queued, time_diff):
|
||||
"""Update device state, if event was not queued."""
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -156,8 +156,7 @@ 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)
|
||||
return TAG_SENSOR_TYPES.get(self._sensor_name)
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
|
|
|
@ -126,14 +126,14 @@ 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 {
|
||||
'min': rtt_min,
|
||||
'avg': rtt_avg,
|
||||
'max': rtt_max,
|
||||
'mdev': rtt_mdev}
|
||||
|
||||
match = PING_MATCHER.search(str(out).split('\n')[-1])
|
||||
rtt_min, rtt_avg, rtt_max, rtt_mdev = match.groups()
|
||||
return {
|
||||
'min': rtt_min,
|
||||
'avg': rtt_avg,
|
||||
'max': rtt_max,
|
||||
'mdev': rtt_mdev}
|
||||
except (subprocess.CalledProcessError, AttributeError):
|
||||
return False
|
||||
|
||||
|
|
|
@ -30,8 +30,7 @@ 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'
|
||||
return val != 'Normal'
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
|
|
@ -148,8 +148,7 @@ 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']))
|
||||
return dt.as_local(dt.parse_datetime(date['dateTime']))
|
||||
|
||||
start = _get_date(self.data.event['start'])
|
||||
end = _get_date(self.data.event['end'])
|
||||
|
|
|
@ -266,8 +266,7 @@ class Camera(Entity):
|
|||
return STATE_RECORDING
|
||||
elif self.is_streaming:
|
||||
return STATE_STREAMING
|
||||
else:
|
||||
return STATE_IDLE
|
||||
return STATE_IDLE
|
||||
|
||||
def enable_motion_detection(self):
|
||||
"""Enable motion detection in the camera."""
|
||||
|
|
|
@ -113,8 +113,7 @@ class NetatmoCamera(Camera):
|
|||
return "Presence"
|
||||
elif self._cameratype == "NACamera":
|
||||
return "Welcome"
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def unique_id(self):
|
||||
|
|
|
@ -398,16 +398,14 @@ class ClimateDevice(Entity):
|
|||
"""Return the current state."""
|
||||
if self.current_operation:
|
||||
return self.current_operation
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def precision(self):
|
||||
"""Return the precision of the system."""
|
||||
if self.unit_of_measurement == TEMP_CELSIUS:
|
||||
return PRECISION_TENTHS
|
||||
else:
|
||||
return PRECISION_WHOLE
|
||||
return PRECISION_WHOLE
|
||||
|
||||
@property
|
||||
def state_attributes(self):
|
||||
|
@ -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)
|
||||
# PRECISION_WHOLE as a fall back
|
||||
return round(temp)
|
||||
|
|
|
@ -151,16 +151,14 @@ 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
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature_high(self):
|
||||
"""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
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
|
@ -171,8 +169,7 @@ 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
|
||||
return None
|
||||
|
||||
@property
|
||||
def desired_fan_mode(self):
|
||||
|
@ -184,8 +181,7 @@ class Thermostat(ClimateDevice):
|
|||
"""Return the current fan state."""
|
||||
if 'fan' in self.thermostat['equipmentStatus']:
|
||||
return STATE_ON
|
||||
else:
|
||||
return STATE_OFF
|
||||
return STATE_OFF
|
||||
|
||||
@property
|
||||
def current_hold_mode(self):
|
||||
|
@ -199,15 +195,13 @@ 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
|
||||
# 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
|
||||
# Any hold not based on a climate is a temp hold
|
||||
return TEMPERATURE_HOLD
|
||||
elif event['type'].startswith('auto'):
|
||||
# All auto modes are treated as holds
|
||||
return event['type'][4:].lower()
|
||||
|
@ -222,8 +216,7 @@ class Thermostat(ClimateDevice):
|
|||
if self.operation_mode == 'auxHeatOnly' or \
|
||||
self.operation_mode == 'heatPump':
|
||||
return STATE_HEAT
|
||||
else:
|
||||
return self.operation_mode
|
||||
return self.operation_mode
|
||||
|
||||
@property
|
||||
def operation_list(self):
|
||||
|
@ -384,8 +377,7 @@ 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'
|
||||
return 'nextTransition'
|
||||
|
||||
@property
|
||||
def climate_list(self):
|
||||
|
|
|
@ -134,9 +134,9 @@ 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
|
||||
|
||||
heating = self._active and self._is_device_active
|
||||
return STATE_HEAT if heating else STATE_IDLE
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
|
@ -159,9 +159,9 @@ 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)
|
||||
|
||||
# get default temp from super class
|
||||
return ClimateDevice.min_temp.fget(self)
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
|
@ -169,9 +169,9 @@ 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)
|
||||
|
||||
# Get default temp from super class
|
||||
return ClimateDevice.max_temp.fget(self)
|
||||
|
||||
@asyncio.coroutine
|
||||
def _async_sensor_changed(self, entity_id, old_state, new_state):
|
||||
|
|
|
@ -60,8 +60,8 @@ 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)
|
||||
|
||||
return _setup_round(username, password, config, add_devices)
|
||||
|
||||
|
||||
def _setup_round(username, password, config, add_devices):
|
||||
|
@ -251,8 +251,7 @@ 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
|
||||
return self._device.setpoint_heat
|
||||
|
||||
@property
|
||||
def current_operation(self: ClimateDevice) -> str:
|
||||
|
|
|
@ -109,16 +109,14 @@ class NestThermostat(ClimateDevice):
|
|||
return self._mode
|
||||
elif self._mode == STATE_HEAT_COOL:
|
||||
return STATE_AUTO
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
"""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
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature_low(self):
|
||||
|
@ -129,8 +127,7 @@ class NestThermostat(ClimateDevice):
|
|||
return self._eco_temperature[0]
|
||||
if self._mode == STATE_HEAT_COOL:
|
||||
return self._target_temperature[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature_high(self):
|
||||
|
@ -141,8 +138,7 @@ class NestThermostat(ClimateDevice):
|
|||
return self._eco_temperature[1]
|
||||
if self._mode == STATE_HEAT_COOL:
|
||||
return self._target_temperature[1]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_away_mode_on(self):
|
||||
|
@ -188,9 +184,8 @@ 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
|
||||
# No Fan available so disable slider
|
||||
return None
|
||||
|
||||
@property
|
||||
def fan_list(self):
|
||||
|
|
|
@ -92,8 +92,7 @@ class ThermostatDevice(ClimateDevice):
|
|||
"""Return current operation i.e. heat, cool, idle."""
|
||||
if self._state:
|
||||
return STATE_HEAT
|
||||
else:
|
||||
return STATE_IDLE
|
||||
return STATE_IDLE
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
|
|
|
@ -117,9 +117,8 @@ 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
|
||||
# Unit conversion is going on. No point to stick to specific steps.
|
||||
return None
|
||||
|
||||
@property
|
||||
def current_operation(self):
|
||||
|
|
|
@ -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,8 +147,7 @@ class TadoClimate(ClimateDevice):
|
|||
"""Return current readable operation mode."""
|
||||
if self._cooling:
|
||||
return "Cooling"
|
||||
else:
|
||||
return OPERATION_LIST.get(self._current_operation)
|
||||
return OPERATION_LIST.get(self._current_operation)
|
||||
|
||||
@property
|
||||
def operation_list(self):
|
||||
|
@ -163,16 +159,14 @@ class TadoClimate(ClimateDevice):
|
|||
"""Return the fan setting."""
|
||||
if self.ac_mode:
|
||||
return FAN_MODES_LIST.get(self._current_fan)
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def fan_list(self):
|
||||
"""List of available fan modes."""
|
||||
if self.ac_mode:
|
||||
return list(FAN_MODES_LIST.values())
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def temperature_unit(self):
|
||||
|
@ -218,18 +212,16 @@ 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
|
||||
# get default temp from super class
|
||||
return super().min_temp
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
"""Return the maximum temperature."""
|
||||
if self._max_temp:
|
||||
return self._max_temp
|
||||
else:
|
||||
# Get default temp from super class
|
||||
return super().max_temp
|
||||
# Get default temp from super class
|
||||
return super().max_temp
|
||||
|
||||
def update(self):
|
||||
"""Update the state of this climate device."""
|
||||
|
|
|
@ -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 self.wink.current_humidity()
|
||||
return None
|
||||
|
||||
@property
|
||||
def external_temperature(self):
|
||||
|
@ -175,10 +175,7 @@ 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
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature_low(self):
|
||||
|
@ -206,8 +203,7 @@ class WinkThermostat(WinkDevice, ClimateDevice):
|
|||
return True
|
||||
elif self.wink.current_hvac_mode() == 'aux' and not self.wink.is_on():
|
||||
return False
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
"""Set new target temperature."""
|
||||
|
@ -270,9 +266,8 @@ 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
|
||||
# No Fan available so disable slider
|
||||
return None
|
||||
|
||||
@property
|
||||
def fan_list(self):
|
||||
|
@ -451,8 +446,7 @@ class WinkAC(WinkDevice, ClimateDevice):
|
|||
return SPEED_MEDIUM
|
||||
elif speed <= 1.0 and speed > 0.8:
|
||||
return SPEED_HIGH
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def fan_list(self):
|
||||
|
|
|
@ -154,8 +154,7 @@ class ZWaveClimate(ZWaveDeviceEntity, ClimateDevice):
|
|||
return TEMP_CELSIUS
|
||||
elif self._unit == 'F':
|
||||
return TEMP_FAHRENHEIT
|
||||
else:
|
||||
return self._unit
|
||||
return self._unit
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -79,8 +79,7 @@ class DemoCover(CoverDevice):
|
|||
"""Flag supported features."""
|
||||
if self._supported_features is not None:
|
||||
return self._supported_features
|
||||
else:
|
||||
return super().supported_features
|
||||
return super().supported_features
|
||||
|
||||
def close_cover(self, **kwargs):
|
||||
"""Close the cover."""
|
||||
|
|
|
@ -159,8 +159,7 @@ class GaradgetCover(CoverDevice):
|
|||
"""Return if the cover is closed."""
|
||||
if self._state == STATE_UNKNOWN:
|
||||
return None
|
||||
else:
|
||||
return self._state == STATE_CLOSED
|
||||
return self._state == STATE_CLOSED
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -361,8 +361,7 @@ class MqttCover(CoverDevice):
|
|||
position_percentage = float(offset_position) / tilt_range * 100.0
|
||||
if self._tilt_invert:
|
||||
return 100 - position_percentage
|
||||
else:
|
||||
return position_percentage
|
||||
return position_percentage
|
||||
|
||||
def find_in_range_from_percent(self, percentage):
|
||||
"""
|
||||
|
|
|
@ -53,8 +53,7 @@ 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
|
||||
return self._values.get(set_req.V_LIGHT) == STATE_OFF
|
||||
|
||||
@property
|
||||
def current_cover_position(self):
|
||||
|
|
|
@ -117,8 +117,7 @@ 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]
|
||||
return self._state in [STATE_CLOSED, STATE_OPENING]
|
||||
|
||||
def close_cover(self):
|
||||
"""Close the cover."""
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -73,8 +73,7 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
|
|||
return None
|
||||
if self.current_cover_position > 0:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
return True
|
||||
|
||||
@property
|
||||
def current_cover_position(self):
|
||||
|
@ -86,8 +85,7 @@ class ZwaveRollershutter(zwave.ZWaveDeviceEntity, CoverDevice):
|
|||
return 0
|
||||
elif self._current_position >= 95:
|
||||
return 100
|
||||
else:
|
||||
return self._current_position
|
||||
return self._current_position
|
||||
|
||||
def open_cover(self, **kwargs):
|
||||
"""Move the roller shutter up."""
|
||||
|
|
|
@ -52,8 +52,7 @@ class BboxDeviceScanner(DeviceScanner):
|
|||
|
||||
if filter_named:
|
||||
return filter_named[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
def _update_info(self):
|
||||
|
|
|
@ -94,21 +94,20 @@ 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
|
||||
# be sent first, then the exit message will be sent second.
|
||||
return 'Ignoring exit from {} (already in {})'.format(
|
||||
location_name, current_state)
|
||||
|
||||
# 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
|
||||
# be sent first, then the exit message will be sent second.
|
||||
return 'Ignoring exit from {} (already in {})'.format(
|
||||
location_name, current_state)
|
||||
|
||||
elif direction == 'test':
|
||||
# In the app, a test message can be sent. Just return something to
|
||||
# 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),
|
||||
HTTP_UNPROCESSABLE_ENTITY)
|
||||
_LOGGER.error('Received unidentified message from Locative: %s',
|
||||
direction)
|
||||
return ('Received unidentified message: {}'.format(direction),
|
||||
HTTP_UNPROCESSABLE_ENTITY)
|
||||
|
|
|
@ -95,8 +95,7 @@ class NmapDeviceScanner(DeviceScanner):
|
|||
|
||||
if filter_named:
|
||||
return filter_named[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
def _update_info(self):
|
||||
|
|
|
@ -131,8 +131,7 @@ 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)
|
||||
return validate_payload(topic, plaintext_payload, data_type)
|
||||
|
||||
if not isinstance(data, dict) or data.get('_type') != data_type:
|
||||
_LOGGER.debug("Skipping %s update for following data "
|
||||
|
|
|
@ -90,8 +90,7 @@ class TadoDeviceScanner(DeviceScanner):
|
|||
|
||||
if filter_named:
|
||||
return filter_named[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
def _update_info(self):
|
||||
|
|
|
@ -73,8 +73,8 @@ class TomatoDeviceScanner(DeviceScanner):
|
|||
|
||||
if not filter_named or not filter_named[0]:
|
||||
return None
|
||||
else:
|
||||
return filter_named[0]
|
||||
|
||||
return filter_named[0]
|
||||
|
||||
@Throttle(MIN_TIME_BETWEEN_SCANS)
|
||||
def _update_tomato_info(self):
|
||||
|
|
|
@ -234,10 +234,9 @@ class Tplink3DeviceScanner(TplinkDeviceScanner):
|
|||
self.stok = ''
|
||||
self.sysauth = ''
|
||||
return False
|
||||
else:
|
||||
_LOGGER.error(
|
||||
"An unknown error happened while fetching data")
|
||||
return False
|
||||
_LOGGER.error(
|
||||
"An unknown error happened while fetching data")
|
||||
return False
|
||||
except ValueError:
|
||||
_LOGGER.error("Router didn't respond with JSON. "
|
||||
"Check if credentials are correct")
|
||||
|
|
|
@ -101,10 +101,10 @@ 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)
|
||||
|
||||
_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)
|
||||
|
||||
def _store_result(self, result):
|
||||
"""Extract and store the device list in self.last_results."""
|
||||
|
|
|
@ -157,8 +157,7 @@ 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 int(self._device.state.speed)
|
||||
return None
|
||||
|
||||
@property
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -60,8 +60,7 @@ class TellstickLight(TellstickDevice, Light):
|
|||
if tellcore_data is not None:
|
||||
brightness = int(tellcore_data)
|
||||
return brightness
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def _update_model(self, new_state, data):
|
||||
"""Update the device entity state to match the arguments."""
|
||||
|
|
|
@ -50,8 +50,7 @@ class VeraLight(VeraDevice, Light):
|
|||
"""Flag supported features."""
|
||||
if self._color:
|
||||
return SUPPORT_BRIGHTNESS | SUPPORT_RGB_COLOR
|
||||
else:
|
||||
return SUPPORT_BRIGHTNESS
|
||||
return SUPPORT_BRIGHTNESS
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
"""Turn the light on."""
|
||||
|
|
|
@ -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,8 +48,7 @@ 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
|
||||
return None
|
||||
|
||||
@property
|
||||
def rgb_color(self):
|
||||
|
|
|
@ -55,16 +55,14 @@ 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)
|
||||
return ZwaveDimmer(values, refresh, delay)
|
||||
|
||||
|
||||
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
|
||||
return 0, STATE_OFF
|
||||
|
||||
|
||||
def ct_to_rgb(temp):
|
||||
|
|
|
@ -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
|
||||
|
||||
_LOGGER.error("Error setting lock state: %s\n%s",
|
||||
requested_state, response.text)
|
||||
return self._state
|
||||
|
|
|
@ -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."""
|
||||
|
|
|
@ -102,8 +102,7 @@ class AnthemAVR(MediaPlayerDevice):
|
|||
return STATE_ON
|
||||
elif pwrstate is False:
|
||||
return STATE_OFF
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def is_volume_muted(self):
|
||||
|
|
|
@ -106,8 +106,7 @@ 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?
|
||||
return STATE_STANDBY # Bad or unknown state?
|
||||
|
||||
@callback
|
||||
def playstatus_update(self, updater, playing):
|
||||
|
|
|
@ -59,8 +59,7 @@ def _get_mac_address(ip_address):
|
|||
pid_component)
|
||||
if match is not None:
|
||||
return match.groups()[0]
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def _config_from_file(filename, config=None):
|
||||
|
@ -307,8 +306,7 @@ class BraviaTVDevice(MediaPlayerDevice):
|
|||
"""Volume level of the media player (0..1)."""
|
||||
if self._volume is not None:
|
||||
return self._volume / 100
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
@property
|
||||
def is_volume_muted(self):
|
||||
|
|
|
@ -94,8 +94,7 @@ class CmusDevice(MediaPlayerDevice):
|
|||
return STATE_PLAYING
|
||||
elif self.status.get('status') == 'paused':
|
||||
return STATE_PAUSED
|
||||
else:
|
||||
return STATE_OFF
|
||||
return STATE_OFF
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
|
|
|
@ -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,8 +194,7 @@ 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
|
||||
return SUPPORT_DENON
|
||||
|
||||
@property
|
||||
def source(self):
|
||||
|
|
|
@ -144,10 +144,9 @@ class DirecTvDevice(MediaPlayerDevice):
|
|||
"""Return the channel current playing media."""
|
||||
if self._is_standby:
|
||||
return None
|
||||
else:
|
||||
chan = "{} ({})".format(
|
||||
self._current['callsign'], self._current['major'])
|
||||
return chan
|
||||
|
||||
return "{} ({})".format(
|
||||
self._current['callsign'], self._current['major'])
|
||||
|
||||
def turn_on(self):
|
||||
"""Turn on the receiver."""
|
||||
|
|
|
@ -306,8 +306,7 @@ class EmbyDevice(MediaPlayerDevice):
|
|||
"""Flag media player features that are supported."""
|
||||
if self.supports_remote_control:
|
||||
return SUPPORT_EMBY
|
||||
else:
|
||||
return None
|
||||
return None
|
||||
|
||||
def async_media_play(self):
|
||||
"""Play media.
|
||||
|
|
|
@ -60,8 +60,8 @@ class Itunes(object):
|
|||
|
||||
if 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):
|
||||
"""Make the actual request and return the parsed response."""
|
||||
|
@ -225,8 +225,8 @@ class ItunesDevice(MediaPlayerDevice):
|
|||
|
||||
if self.player_state == 'paused':
|
||||
return STATE_PAUSED
|
||||
else:
|
||||
return STATE_PLAYING
|
||||
|
||||
return STATE_PLAYING
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
|
@ -281,9 +281,9 @@ 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'
|
||||
|
||||
return 'https://cloud.githubusercontent.com/assets/260/9829355' \
|
||||
'/33fab972-58cf-11e5-8ea2-2ca74bdaae40.png'
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
|
@ -400,16 +400,16 @@ 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'
|
||||
|
||||
return 'mdi:volume-off'
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""Return the state of the device."""
|
||||
if self.selected is True:
|
||||
return STATE_ON
|
||||
else:
|
||||
return STATE_OFF
|
||||
|
||||
return STATE_OFF
|
||||
|
||||
def update(self):
|
||||
"""Retrieve latest state."""
|
||||
|
|
|
@ -334,8 +334,8 @@ class KodiDevice(MediaPlayerDevice):
|
|||
|
||||
if self._properties['speed'] == 0 and not self._properties['live']:
|
||||
return STATE_PAUSED
|
||||
else:
|
||||
return STATE_PLAYING
|
||||
|
||||
return STATE_PLAYING
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_ws_connect(self):
|
||||
|
@ -407,8 +407,8 @@ 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
|
||||
|
||||
return self._http_server
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
@ -503,8 +503,8 @@ class KodiDevice(MediaPlayerDevice):
|
|||
artists = self._item.get('artist', [])
|
||||
if artists:
|
||||
return artists[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def media_album_artist(self):
|
||||
|
@ -512,8 +512,8 @@ class KodiDevice(MediaPlayerDevice):
|
|||
artists = self._item.get('albumartist', [])
|
||||
if artists:
|
||||
return artists[0]
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -678,9 +678,9 @@ 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)}})
|
||||
|
||||
return self.server.Player.Open(
|
||||
{"item": {"file": str(media_id)}})
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_set_shuffle(self, shuffle):
|
||||
|
@ -794,9 +794,9 @@ 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)}}))
|
||||
|
||||
return (yield from self.server.AudioLibrary.GetAlbums(
|
||||
{"filter": {"artistid": int(artist_id)}}))
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_find_artist(self, artist_name):
|
||||
|
@ -815,9 +815,9 @@ 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)}}))
|
||||
|
||||
return (yield from self.server.AudioLibrary.GetSongs(
|
||||
{"filter": {"artistid": int(artist_id)}}))
|
||||
|
||||
@asyncio.coroutine
|
||||
def async_find_song(self, song_name, artist_name=''):
|
||||
|
|
|
@ -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
|
||||
|
||||
return STATE_ON if self._client.is_on else STATE_OFF
|
||||
|
||||
def turn_off(self):
|
||||
"""Turn off media player."""
|
||||
|
|
|
@ -97,8 +97,8 @@ class MpcHcDevice(MediaPlayerDevice):
|
|||
return STATE_PLAYING
|
||||
elif state == 'paused':
|
||||
return STATE_PAUSED
|
||||
else:
|
||||
return STATE_IDLE
|
||||
|
||||
return STATE_IDLE
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
|
|
|
@ -133,8 +133,8 @@ class MpdDevice(MediaPlayerDevice):
|
|||
return STATE_PLAYING
|
||||
elif self.status['state'] == 'pause':
|
||||
return STATE_PAUSED
|
||||
else:
|
||||
return STATE_OFF
|
||||
|
||||
return STATE_OFF
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
|
@ -164,8 +164,8 @@ class MpdDevice(MediaPlayerDevice):
|
|||
return title
|
||||
elif title is None:
|
||||
return name
|
||||
else:
|
||||
return '{}: {}'.format(name, title)
|
||||
|
||||
return '{}: {}'.format(name, title)
|
||||
|
||||
@property
|
||||
def media_artist(self):
|
||||
|
|
|
@ -358,9 +358,9 @@ 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 "
|
||||
"https://home-assistant.io/components/media_player.pandora/")
|
||||
return False
|
||||
|
||||
_LOGGER.warning(
|
||||
"The Pandora component depends on the Pianobar client, which "
|
||||
"cannot be found. Please install using instructions at "
|
||||
"https://home-assistant.io/components/media_player.pandora/")
|
||||
return False
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -531,16 +531,16 @@ 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
|
||||
|
||||
return value
|
||||
|
||||
@property
|
||||
def _active_media_plexapi_type(self):
|
||||
"""Get the active media type required by PlexAPI commands."""
|
||||
if self.media_content_type is MEDIA_TYPE_MUSIC:
|
||||
return 'music'
|
||||
else:
|
||||
return 'video'
|
||||
|
||||
return 'video'
|
||||
|
||||
@property
|
||||
def media_content_id(self):
|
||||
|
@ -560,8 +560,8 @@ class PlexClient(MediaPlayerDevice):
|
|||
return MEDIA_TYPE_VIDEO
|
||||
elif self._session_type == 'track':
|
||||
return MEDIA_TYPE_MUSIC
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def media_artist(self):
|
||||
|
@ -657,8 +657,8 @@ class PlexClient(MediaPlayerDevice):
|
|||
SUPPORT_NEXT_TRACK | SUPPORT_STOP |
|
||||
SUPPORT_VOLUME_SET | SUPPORT_PLAY |
|
||||
SUPPORT_TURN_OFF | SUPPORT_VOLUME_MUTE)
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
def _local_client_control_fix(self):
|
||||
"""Detect if local client and adjust url to allow control."""
|
||||
|
|
|
@ -220,9 +220,9 @@ 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(':'))))
|
||||
|
||||
return sum(60 ** x[0] * int(x[1]) for x in enumerate(
|
||||
reversed(timespan.split(':'))))
|
||||
|
||||
|
||||
class _ProcessSonosEventQueue():
|
||||
|
@ -765,8 +765,8 @@ class SonosDevice(MediaPlayerDevice):
|
|||
"""Content ID of current playing media."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_content_id
|
||||
else:
|
||||
return self._media_content_id
|
||||
|
||||
return self._media_content_id
|
||||
|
||||
@property
|
||||
def media_content_type(self):
|
||||
|
@ -778,16 +778,16 @@ class SonosDevice(MediaPlayerDevice):
|
|||
"""Duration of current playing media in seconds."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_duration
|
||||
else:
|
||||
return self._media_duration
|
||||
|
||||
return self._media_duration
|
||||
|
||||
@property
|
||||
def media_position(self):
|
||||
"""Position of current playing media in seconds."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_position
|
||||
else:
|
||||
return self._media_position
|
||||
|
||||
return self._media_position
|
||||
|
||||
@property
|
||||
def media_position_updated_at(self):
|
||||
|
@ -797,40 +797,40 @@ class SonosDevice(MediaPlayerDevice):
|
|||
"""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_position_updated_at
|
||||
else:
|
||||
return self._media_position_updated_at
|
||||
|
||||
return self._media_position_updated_at
|
||||
|
||||
@property
|
||||
def media_image_url(self):
|
||||
"""Image url of current playing media."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_image_url
|
||||
else:
|
||||
return self._media_image_url
|
||||
|
||||
return self._media_image_url
|
||||
|
||||
@property
|
||||
def media_artist(self):
|
||||
"""Artist of current playing media, music track only."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_artist
|
||||
else:
|
||||
return self._media_artist
|
||||
|
||||
return self._media_artist
|
||||
|
||||
@property
|
||||
def media_album_name(self):
|
||||
"""Album name of current playing media, music track only."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_album_name
|
||||
else:
|
||||
return self._media_album_name
|
||||
|
||||
return self._media_album_name
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
"""Title of current playing media."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.media_title
|
||||
else:
|
||||
return self._media_title
|
||||
|
||||
return self._media_title
|
||||
|
||||
@property
|
||||
def supported_features(self):
|
||||
|
@ -919,8 +919,8 @@ class SonosDevice(MediaPlayerDevice):
|
|||
"""Name of the current input source."""
|
||||
if self._coordinator:
|
||||
return self._coordinator.source
|
||||
else:
|
||||
return self._source_name
|
||||
|
||||
return self._source_name
|
||||
|
||||
@soco_error
|
||||
def turn_off(self):
|
||||
|
|
|
@ -200,8 +200,8 @@ 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)
|
||||
|
||||
return MAP_STATUS.get(self._status.play_status, STATE_UNAVAILABLE)
|
||||
|
||||
@property
|
||||
def is_volume_muted(self):
|
||||
|
@ -280,8 +280,8 @@ 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
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def media_duration(self):
|
||||
|
|
|
@ -215,8 +215,8 @@ 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
|
||||
|
||||
return None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -113,8 +113,8 @@ class Volumio(MediaPlayerDevice):
|
|||
return STATE_PAUSED
|
||||
elif status == 'play':
|
||||
return STATE_PLAYING
|
||||
else:
|
||||
return STATE_IDLE
|
||||
|
||||
return STATE_IDLE
|
||||
|
||||
@property
|
||||
def media_title(self):
|
||||
|
@ -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})
|
||||
|
||||
return self.send_volumio_msg(
|
||||
'commands', params={'cmd': 'volume', 'volume': self._lastvol})
|
||||
|
|
|
@ -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
|
||||
|
||||
return song or station
|
||||
|
|
|
@ -42,8 +42,8 @@ def get_service(hass, config, discovery_info=None):
|
|||
config.get(CONF_RECIPIENT))
|
||||
if mailgun_service.connection_is_valid():
|
||||
return mailgun_service
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class MailgunNotificationService(BaseNotificationService):
|
||||
|
|
|
@ -74,8 +74,8 @@ def get_service(hass, config, discovery_info=None):
|
|||
|
||||
if mail_service.connection_is_valid():
|
||||
return mail_service
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
|
||||
class MailNotificationService(BaseNotificationService):
|
||||
|
|
|
@ -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)
|
||||
|
||||
return dt_util.as_utc(ts)
|
||||
|
|
|
@ -62,9 +62,9 @@ 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
|
||||
|
||||
_LOGGER.error("HTTP error %d on %s", scenes_resp.status, url)
|
||||
return False
|
||||
|
||||
|
||||
class LifxCloudScene(Scene):
|
||||
|
|
|
@ -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
|
||||
return self._icon
|
||||
|
|
|
@ -139,17 +139,17 @@ 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])
|
||||
|
||||
return 'BOM {} {}'.format(
|
||||
self.stationname, SENSOR_TYPES[self._condition][0])
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
"""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
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -167,8 +167,8 @@ class BrSensor(Entity):
|
|||
|
||||
if self.type != SYMBOL:
|
||||
return None
|
||||
else:
|
||||
return self._entity_picture
|
||||
|
||||
return self._entity_picture
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -187,9 +187,9 @@ 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)
|
||||
|
||||
return '{} {} {}'.format(
|
||||
self.client_name, self._name, self.forecast_day)
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
@ -214,8 +214,8 @@ class DarkSkySensor(Entity):
|
|||
|
||||
if self._icon in CONDITION_PICTURES:
|
||||
return CONDITION_PICTURES[self._icon]
|
||||
else:
|
||||
return None
|
||||
|
||||
return None
|
||||
|
||||
def update_unit_of_measurement(self):
|
||||
"""Update units based on unit system."""
|
||||
|
|
|
@ -207,11 +207,11 @@ 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
|
||||
|
||||
if value is not None:
|
||||
return value
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
@ -227,8 +227,8 @@ class DSMREntity(Entity):
|
|||
return 'normal'
|
||||
elif value == '0001':
|
||||
return 'low'
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
|
||||
return STATE_UNKNOWN
|
||||
|
||||
|
||||
class DerivativeDSMREntity(DSMREntity):
|
||||
|
|
|
@ -59,8 +59,7 @@ class DysonFilterLifeSensor(Entity):
|
|||
"""Return filter life in hours.."""
|
||||
if self._device.state:
|
||||
return self._device.state.filter_life
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
|
|
|
@ -86,8 +86,7 @@ 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
|
||||
return string
|
||||
|
||||
|
||||
class EddystoneTemp(Entity):
|
||||
|
|
|
@ -155,8 +155,8 @@ class EightUserSensor(EightSleepUserEntity):
|
|||
elif 'bed_temp' in self._sensor:
|
||||
if self._units == 'si':
|
||||
return '°C'
|
||||
else:
|
||||
return '°F'
|
||||
return '°F'
|
||||
return None
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -264,8 +264,7 @@ class EightRoomSensor(EightSleepUserEntity):
|
|||
"""Return the unit the value is expressed in."""
|
||||
if self._units == 'si':
|
||||
return '°C'
|
||||
else:
|
||||
return '°F'
|
||||
return '°F'
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
|
|
@ -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,8 +136,7 @@ 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)
|
||||
return self.phonebook.get_name(number)
|
||||
|
||||
def update(self):
|
||||
"""Update the phonebook if it is defined."""
|
||||
|
|
|
@ -89,8 +89,7 @@ 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])
|
||||
return '{} {}'.format(self._name, SENSOR_TYPES[self.type][0])
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -94,8 +94,7 @@ class GpsdSensor(Entity):
|
|||
return "3D Fix"
|
||||
elif self.agps_thread.data_stream.mode == 2:
|
||||
return "2D Fix"
|
||||
else:
|
||||
return STATE_UNKNOWN
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -77,8 +77,7 @@ class HddTempSensor(Entity):
|
|||
"""Return the unit the value is expressed in."""
|
||||
if self._details[4] == 'C':
|
||||
return TEMP_CELSIUS
|
||||
else:
|
||||
return TEMP_FAHRENHEIT
|
||||
return TEMP_FAHRENHEIT
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -296,8 +296,7 @@ class HistoryStatsHelper:
|
|||
return '%dd %dh %dm' % (days, hours, minutes)
|
||||
elif hours > 0:
|
||||
return '%dh %dm' % (hours, minutes)
|
||||
else:
|
||||
return '%dm' % minutes
|
||||
return '%dm' % minutes
|
||||
|
||||
@staticmethod
|
||||
def pretty_ratio(value, period):
|
||||
|
|
|
@ -121,8 +121,7 @@ class IOSSensor(Entity):
|
|||
|
||||
if self.type == "state":
|
||||
return returning_icon_state
|
||||
else:
|
||||
return returning_icon_level
|
||||
return returning_icon_level
|
||||
|
||||
def update(self):
|
||||
"""Get the latest state of the sensor."""
|
||||
|
|
|
@ -310,8 +310,7 @@ 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
|
||||
return raw_units
|
||||
|
||||
|
||||
class ISYWeatherDevice(isy.ISYDevice):
|
||||
|
|
|
@ -105,8 +105,7 @@ 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
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -124,10 +124,8 @@ 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
|
||||
return variable.value
|
||||
return STATE_UNKNOWN
|
||||
|
||||
@property
|
||||
def unit_of_measurement(self):
|
||||
|
|
|
@ -64,8 +64,7 @@ class MoonSensor(Entity):
|
|||
return 'Waning gibbous'
|
||||
elif self._state == 21:
|
||||
return 'Last quarter'
|
||||
else:
|
||||
return 'Waning crescent'
|
||||
return 'Waning crescent'
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
|
|
@ -91,8 +91,7 @@ class MVGLiveSensor(Entity):
|
|||
"""Return the name of the sensor."""
|
||||
if self._name:
|
||||
return self._name
|
||||
else:
|
||||
return self._station
|
||||
return self._station
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -60,8 +60,7 @@ class OhmconnectSensor(Entity):
|
|||
"""Return the state of the sensor."""
|
||||
if self._data.get("active") == "True":
|
||||
return "Active"
|
||||
else:
|
||||
return "Inactive"
|
||||
return "Inactive"
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -232,8 +232,7 @@ 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)
|
||||
return "{} {}".format(server_name, self.var_name)
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
|
|
@ -90,8 +90,7 @@ 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
|
||||
return None
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
|
|
@ -177,8 +177,7 @@ 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
|
||||
return self.var_name
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
|
@ -191,8 +190,7 @@ 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
|
||||
return self.var_units
|
||||
|
||||
def update(self):
|
||||
"""Get the latest data for the states."""
|
||||
|
@ -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)
|
||||
|
||||
return round(attr * 1.8 + 32.0, 1)
|
||||
|
||||
return getattr(self._api.storage,
|
||||
self.var_id)(self.monitor_device)
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -92,8 +92,7 @@ class TelldusLiveSensor(TelldusLiveEntity):
|
|||
return self._value_as_humidity
|
||||
elif self._type == SENSOR_TYPE_LUMINANCE:
|
||||
return self._value_as_luminance
|
||||
else:
|
||||
return self._value
|
||||
return self._value
|
||||
|
||||
@property
|
||||
def quantity_name(self):
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue