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
|
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
|
||||||
def async_alarm_disarm(self, code=None):
|
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."""
|
"""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
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -99,8 +99,7 @@ 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
|
||||||
|
|
||||||
|
|
|
@ -80,8 +80,7 @@ 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
|
||||||
def code_format(self):
|
def code_format(self):
|
||||||
|
|
|
@ -199,11 +199,10 @@ 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)
|
return False
|
||||||
return False
|
|
||||||
|
|
||||||
def _on_up_down(self, channel, click_type, was_queued, time_diff):
|
def _on_up_down(self, channel, click_type, was_queued, time_diff):
|
||||||
"""Update device state, if event was not queued."""
|
"""Update device state, if event was not queued."""
|
||||||
|
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -156,8 +156,7 @@ 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
|
||||||
def is_on(self):
|
def is_on(self):
|
||||||
|
|
|
@ -126,14 +126,14 @@ 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 {
|
||||||
'min': rtt_min,
|
'min': rtt_min,
|
||||||
'avg': rtt_avg,
|
'avg': rtt_avg,
|
||||||
'max': rtt_max,
|
'max': rtt_max,
|
||||||
'mdev': rtt_mdev}
|
'mdev': rtt_mdev}
|
||||||
except (subprocess.CalledProcessError, AttributeError):
|
except (subprocess.CalledProcessError, AttributeError):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ 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
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
|
|
|
@ -148,8 +148,7 @@ 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'])
|
||||||
end = _get_date(self.data.event['end'])
|
end = _get_date(self.data.event['end'])
|
||||||
|
|
|
@ -266,8 +266,7 @@ 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):
|
||||||
"""Enable motion detection in the camera."""
|
"""Enable motion detection in the camera."""
|
||||||
|
|
|
@ -113,8 +113,7 @@ 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
|
||||||
def unique_id(self):
|
def unique_id(self):
|
||||||
|
|
|
@ -398,16 +398,14 @@ 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
|
||||||
def precision(self):
|
def precision(self):
|
||||||
"""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
|
||||||
def state_attributes(self):
|
def state_attributes(self):
|
||||||
|
@ -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)
|
|
||||||
|
|
|
@ -151,16 +151,14 @@ 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
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self):
|
||||||
"""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
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
|
@ -171,8 +169,7 @@ 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
|
||||||
def desired_fan_mode(self):
|
def desired_fan_mode(self):
|
||||||
|
@ -184,8 +181,7 @@ 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
|
||||||
def current_hold_mode(self):
|
def current_hold_mode(self):
|
||||||
|
@ -199,15 +195,13 @@ 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'):
|
||||||
# All auto modes are treated as holds
|
# All auto modes are treated as holds
|
||||||
return event['type'][4:].lower()
|
return event['type'][4:].lower()
|
||||||
|
@ -222,8 +216,7 @@ 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
|
||||||
def operation_list(self):
|
def operation_list(self):
|
||||||
|
@ -384,8 +377,7 @@ 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
|
||||||
def climate_list(self):
|
def climate_list(self):
|
||||||
|
|
|
@ -134,9 +134,9 @@ 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
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
|
@ -159,9 +159,9 @@ 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)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
|
@ -169,9 +169,9 @@ 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)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def _async_sensor_changed(self, entity_id, old_state, new_state):
|
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':
|
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)
|
||||||
|
|
||||||
|
|
||||||
def _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."""
|
"""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
|
||||||
def current_operation(self: ClimateDevice) -> str:
|
def current_operation(self: ClimateDevice) -> str:
|
||||||
|
|
|
@ -109,16 +109,14 @@ 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
|
||||||
def target_temperature(self):
|
def target_temperature(self):
|
||||||
"""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
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self):
|
||||||
|
@ -129,8 +127,7 @@ 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
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self):
|
||||||
|
@ -141,8 +138,7 @@ 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
|
||||||
def is_away_mode_on(self):
|
def is_away_mode_on(self):
|
||||||
|
@ -188,9 +184,8 @@ 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
|
|
|
@ -92,8 +92,7 @@ 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
|
||||||
def current_temperature(self):
|
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
|
# 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_operation(self):
|
def current_operation(self):
|
||||||
|
|
|
@ -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,8 +147,7 @@ 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
|
||||||
def operation_list(self):
|
def operation_list(self):
|
||||||
|
@ -163,16 +159,14 @@ 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
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
"""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
|
||||||
def temperature_unit(self):
|
def temperature_unit(self):
|
||||||
|
@ -218,18 +212,16 @@ 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def max_temp(self):
|
def max_temp(self):
|
||||||
"""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
|
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
"""Update the state of this climate device."""
|
"""Update the state of this climate device."""
|
||||||
|
|
|
@ -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,10 +175,7 @@ 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
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self):
|
||||||
|
@ -206,8 +203,7 @@ 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):
|
||||||
"""Set new target temperature."""
|
"""Set new target temperature."""
|
||||||
|
@ -270,9 +266,8 @@ 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
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
|
@ -451,8 +446,7 @@ 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
|
||||||
def fan_list(self):
|
def fan_list(self):
|
||||||
|
|
|
@ -154,8 +154,7 @@ 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
|
||||||
def current_temperature(self):
|
def current_temperature(self):
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -79,8 +79,7 @@ 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):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
|
|
|
@ -159,8 +159,7 @@ 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
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -361,8 +361,7 @@ 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):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -53,8 +53,7 @@ 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
|
||||||
def current_cover_position(self):
|
def current_cover_position(self):
|
||||||
|
|
|
@ -117,8 +117,7 @@ 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):
|
||||||
"""Close the cover."""
|
"""Close the cover."""
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -73,8 +73,7 @@ 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
|
||||||
def current_cover_position(self):
|
def current_cover_position(self):
|
||||||
|
@ -86,8 +85,7 @@ 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):
|
||||||
"""Move the roller shutter up."""
|
"""Move the roller shutter up."""
|
||||||
|
|
|
@ -52,8 +52,7 @@ 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)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
|
|
|
@ -94,21 +94,20 @@ 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
|
||||||
# be sent first, then the exit message will be sent second.
|
# be sent first, then the exit message will be sent second.
|
||||||
return 'Ignoring exit from {} (already in {})'.format(
|
return 'Ignoring exit from {} (already in {})'.format(
|
||||||
location_name, current_state)
|
location_name, current_state)
|
||||||
|
|
||||||
elif direction == 'test':
|
elif direction == 'test':
|
||||||
# In the app, a test message can be sent. Just return something to
|
# In the app, a test message can be sent. Just return something to
|
||||||
# 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),
|
HTTP_UNPROCESSABLE_ENTITY)
|
||||||
HTTP_UNPROCESSABLE_ENTITY)
|
|
||||||
|
|
|
@ -95,8 +95,7 @@ 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)
|
||||||
def _update_info(self):
|
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'])
|
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:
|
||||||
_LOGGER.debug("Skipping %s update for following data "
|
_LOGGER.debug("Skipping %s update for following data "
|
||||||
|
|
|
@ -90,8 +90,7 @@ 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)
|
||||||
def _update_info(self):
|
def _update_info(self):
|
||||||
|
|
|
@ -73,8 +73,8 @@ 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)
|
||||||
def _update_tomato_info(self):
|
def _update_tomato_info(self):
|
||||||
|
|
|
@ -234,10 +234,9 @@ 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
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
_LOGGER.error("Router didn't respond with JSON. "
|
_LOGGER.error("Router didn't respond with JSON. "
|
||||||
"Check if credentials are correct")
|
"Check if credentials are correct")
|
||||||
|
|
|
@ -101,10 +101,10 @@ 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)
|
||||||
|
|
||||||
def _store_result(self, result):
|
def _store_result(self, result):
|
||||||
"""Extract and store the device list in self.last_results."""
|
"""Extract and store the device list in self.last_results."""
|
||||||
|
|
|
@ -157,8 +157,7 @@ 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
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -60,8 +60,7 @@ 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):
|
||||||
"""Update the device entity state to match the arguments."""
|
"""Update the device entity state to match the arguments."""
|
||||||
|
|
|
@ -50,8 +50,7 @@ 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):
|
||||||
"""Turn the light on."""
|
"""Turn the light on."""
|
||||||
|
|
|
@ -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,8 +48,7 @@ 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
|
||||||
def rgb_color(self):
|
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):
|
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)
|
|
||||||
|
|
||||||
|
|
||||||
def brightness_state(value):
|
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
|
|
||||||
|
|
||||||
|
|
||||||
def ct_to_rgb(temp):
|
def ct_to_rgb(temp):
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -102,8 +102,7 @@ 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
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
|
|
|
@ -106,8 +106,7 @@ 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
|
||||||
def playstatus_update(self, updater, playing):
|
def playstatus_update(self, updater, playing):
|
||||||
|
|
|
@ -59,8 +59,7 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
def _config_from_file(filename, config=None):
|
def _config_from_file(filename, config=None):
|
||||||
|
@ -307,8 +306,7 @@ 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
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
|
|
|
@ -94,8 +94,7 @@ 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
|
||||||
def media_content_id(self):
|
def media_content_id(self):
|
||||||
|
|
|
@ -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,8 +194,7 @@ 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
|
||||||
def source(self):
|
def source(self):
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -306,8 +306,7 @@ 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):
|
||||||
"""Play media.
|
"""Play media.
|
||||||
|
|
|
@ -60,8 +60,8 @@ 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):
|
||||||
"""Make the actual request and return the parsed response."""
|
"""Make the actual request and return the parsed response."""
|
||||||
|
@ -225,8 +225,8 @@ 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):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
|
@ -281,9 +281,9 @@ 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'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
@ -400,16 +400,16 @@ 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
|
||||||
def state(self):
|
def state(self):
|
||||||
"""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):
|
||||||
"""Retrieve latest state."""
|
"""Retrieve latest state."""
|
||||||
|
|
|
@ -334,8 +334,8 @@ 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
|
||||||
def async_ws_connect(self):
|
def async_ws_connect(self):
|
||||||
|
@ -407,8 +407,8 @@ 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
|
||||||
def name(self):
|
def name(self):
|
||||||
|
@ -503,8 +503,8 @@ 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
|
||||||
def media_album_artist(self):
|
def media_album_artist(self):
|
||||||
|
@ -512,8 +512,8 @@ 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
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
@ -678,9 +678,9 @@ 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)}})
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_set_shuffle(self, shuffle):
|
def async_set_shuffle(self, shuffle):
|
||||||
|
@ -794,9 +794,9 @@ 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)}}))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_find_artist(self, artist_name):
|
def async_find_artist(self, artist_name):
|
||||||
|
@ -815,9 +815,9 @@ 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)}}))
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
def async_find_song(self, song_name, artist_name=''):
|
def async_find_song(self, song_name, artist_name=''):
|
||||||
|
|
|
@ -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."""
|
||||||
|
|
|
@ -97,8 +97,8 @@ 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
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
|
|
@ -133,8 +133,8 @@ 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
|
||||||
def media_content_id(self):
|
def media_content_id(self):
|
||||||
|
@ -164,8 +164,8 @@ 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
|
||||||
def media_artist(self):
|
def media_artist(self):
|
||||||
|
|
|
@ -358,9 +358,9 @@ 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 "
|
||||||
"https://home-assistant.io/components/media_player.pandora/")
|
"https://home-assistant.io/components/media_player.pandora/")
|
||||||
return False
|
return False
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -531,16 +531,16 @@ 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
|
||||||
def _active_media_plexapi_type(self):
|
def _active_media_plexapi_type(self):
|
||||||
"""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
|
||||||
def media_content_id(self):
|
def media_content_id(self):
|
||||||
|
@ -560,8 +560,8 @@ 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
|
||||||
def media_artist(self):
|
def media_artist(self):
|
||||||
|
@ -657,8 +657,8 @@ 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):
|
||||||
"""Detect if local client and adjust url to allow control."""
|
"""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."""
|
"""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(':'))))
|
||||||
|
|
||||||
|
|
||||||
class _ProcessSonosEventQueue():
|
class _ProcessSonosEventQueue():
|
||||||
|
@ -765,8 +765,8 @@ 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
|
||||||
def media_content_type(self):
|
def media_content_type(self):
|
||||||
|
@ -778,16 +778,16 @@ 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
|
||||||
def media_position(self):
|
def media_position(self):
|
||||||
"""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
|
||||||
def media_position_updated_at(self):
|
def media_position_updated_at(self):
|
||||||
|
@ -797,40 +797,40 @@ 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
|
||||||
def media_image_url(self):
|
def media_image_url(self):
|
||||||
"""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
|
||||||
def media_artist(self):
|
def media_artist(self):
|
||||||
"""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
|
||||||
def media_album_name(self):
|
def media_album_name(self):
|
||||||
"""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
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
"""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
|
||||||
def supported_features(self):
|
def supported_features(self):
|
||||||
|
@ -919,8 +919,8 @@ 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
|
||||||
def turn_off(self):
|
def turn_off(self):
|
||||||
|
|
|
@ -200,8 +200,8 @@ 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
|
||||||
def is_volume_muted(self):
|
def is_volume_muted(self):
|
||||||
|
@ -280,8 +280,8 @@ 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
|
||||||
def media_duration(self):
|
def media_duration(self):
|
||||||
|
|
|
@ -215,8 +215,8 @@ 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
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -113,8 +113,8 @@ 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
|
||||||
def media_title(self):
|
def media_title(self):
|
||||||
|
@ -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})
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -42,8 +42,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
class MailgunNotificationService(BaseNotificationService):
|
class MailgunNotificationService(BaseNotificationService):
|
||||||
|
|
|
@ -74,8 +74,8 @@ 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
|
||||||
|
|
||||||
|
|
||||||
class MailNotificationService(BaseNotificationService):
|
class MailNotificationService(BaseNotificationService):
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -62,9 +62,9 @@ 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
|
||||||
|
|
||||||
|
|
||||||
class LifxCloudScene(Scene):
|
class LifxCloudScene(Scene):
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
|
@ -139,17 +139,17 @@ 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])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
"""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
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -167,8 +167,8 @@ 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
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -187,9 +187,9 @@ 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)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
@ -214,8 +214,8 @@ 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):
|
||||||
"""Update units based on unit system."""
|
"""Update units based on unit system."""
|
||||||
|
|
|
@ -207,11 +207,11 @@ 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
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
@ -227,8 +227,8 @@ class DSMREntity(Entity):
|
||||||
return 'normal'
|
return 'normal'
|
||||||
elif value == '0001':
|
elif value == '0001':
|
||||||
return 'low'
|
return 'low'
|
||||||
else:
|
|
||||||
return STATE_UNKNOWN
|
return STATE_UNKNOWN
|
||||||
|
|
||||||
|
|
||||||
class DerivativeDSMREntity(DSMREntity):
|
class DerivativeDSMREntity(DSMREntity):
|
||||||
|
|
|
@ -59,8 +59,7 @@ 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
|
||||||
def name(self):
|
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 "
|
_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
|
|
||||||
|
|
||||||
|
|
||||||
class EddystoneTemp(Entity):
|
class EddystoneTemp(Entity):
|
||||||
|
|
|
@ -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,8 +264,7 @@ 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
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
|
|
@ -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,8 +136,7 @@ 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):
|
||||||
"""Update the phonebook if it is defined."""
|
"""Update the phonebook if it is defined."""
|
||||||
|
|
|
@ -89,8 +89,7 @@ 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
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
|
|
@ -94,8 +94,7 @@ 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
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -77,8 +77,7 @@ 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
|
||||||
def device_state_attributes(self):
|
def device_state_attributes(self):
|
||||||
|
|
|
@ -296,8 +296,7 @@ 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
|
||||||
def pretty_ratio(value, period):
|
def pretty_ratio(value, period):
|
||||||
|
|
|
@ -121,8 +121,7 @@ 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):
|
||||||
"""Get the latest state of the sensor."""
|
"""Get the latest state of the sensor."""
|
||||||
|
|
|
@ -310,8 +310,7 @@ 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
|
|
||||||
|
|
||||||
|
|
||||||
class ISYWeatherDevice(isy.ISYDevice):
|
class ISYWeatherDevice(isy.ISYDevice):
|
||||||
|
|
|
@ -105,8 +105,7 @@ 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
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
|
|
@ -124,10 +124,8 @@ 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
|
return STATE_UNKNOWN
|
||||||
else:
|
|
||||||
return STATE_UNKNOWN
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def unit_of_measurement(self):
|
def unit_of_measurement(self):
|
||||||
|
|
|
@ -64,8 +64,7 @@ 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
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
|
|
@ -91,8 +91,7 @@ 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
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -60,8 +60,7 @@ 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
|
||||||
def device_state_attributes(self):
|
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 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):
|
||||||
|
|
|
@ -232,8 +232,7 @@ 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
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
|
|
@ -90,8 +90,7 @@ 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
|
||||||
def state(self):
|
def state(self):
|
||||||
|
|
|
@ -177,8 +177,7 @@ 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
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
@ -191,8 +190,7 @@ 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):
|
||||||
"""Get the latest data for the states."""
|
"""Get the latest data for the states."""
|
||||||
|
@ -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)
|
||||||
|
|
|
@ -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):
|
||||||
|
|
|
@ -92,8 +92,7 @@ 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
|
||||||
def quantity_name(self):
|
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