From 68df3deee038daefdc3114fbaf3abaee4893fce7 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 24 Jun 2016 21:27:40 -0700 Subject: [PATCH] ABC consistent not implemented behavior (#2359) --- homeassistant/components/hvac/__init__.py | 18 ++++++++-------- homeassistant/components/hvac/zwave.py | 2 +- homeassistant/components/light/__init__.py | 3 ++- .../components/light/limitlessled.py | 1 + homeassistant/components/light/mysensors.py | 1 + homeassistant/components/switch/__init__.py | 2 +- .../components/switch/acer_projector.py | 21 ++++++++++++------- homeassistant/components/switch/arest.py | 1 + .../components/switch/wake_on_lan.py | 4 ++++ .../components/thermostat/__init__.py | 14 ++++++------- homeassistant/components/thermostat/demo.py | 2 +- homeassistant/components/thermostat/ecobee.py | 2 +- .../components/thermostat/eq3btsmart.py | 2 +- .../components/thermostat/heat_control.py | 3 +-- .../components/thermostat/heatmiser.py | 2 +- .../components/thermostat/homematic.py | 2 +- .../components/thermostat/honeywell.py | 5 ++--- homeassistant/components/thermostat/nest.py | 1 + .../components/thermostat/proliphix.py | 1 + .../components/thermostat/radiotherm.py | 1 + homeassistant/components/thermostat/zwave.py | 1 + homeassistant/helpers/entity.py | 8 +++---- 22 files changed, 56 insertions(+), 41 deletions(-) diff --git a/homeassistant/components/hvac/__init__.py b/homeassistant/components/hvac/__init__.py index 85d10671a17..560f3d13fd6 100644 --- a/homeassistant/components/hvac/__init__.py +++ b/homeassistant/components/hvac/__init__.py @@ -425,39 +425,39 @@ class HvacDevice(Entity): def set_temperature(self, temperature): """Set new target temperature.""" - pass + raise NotImplementedError() def set_humidity(self, humidity): """Set new target humidity.""" - pass + raise NotImplementedError() def set_fan_mode(self, fan): """Set new target fan mode.""" - pass + raise NotImplementedError() def set_operation_mode(self, operation_mode): """Set new target operation mode.""" - pass + raise NotImplementedError() def set_swing_mode(self, swing_mode): """Set new target swing operation.""" - pass + raise NotImplementedError() def turn_away_mode_on(self): """Turn away mode on.""" - pass + raise NotImplementedError() def turn_away_mode_off(self): """Turn away mode off.""" - pass + raise NotImplementedError() def turn_aux_heat_on(self): """Turn auxillary heater on.""" - pass + raise NotImplementedError() def turn_aux_heat_off(self): """Turn auxillary heater off.""" - pass + raise NotImplementedError() @property def min_temp(self): diff --git a/homeassistant/components/hvac/zwave.py b/homeassistant/components/hvac/zwave.py index 5becb53b98a..c950200932a 100755 --- a/homeassistant/components/hvac/zwave.py +++ b/homeassistant/components/hvac/zwave.py @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): discovery_info, zwave.NETWORK) -# pylint: disable=too-many-arguments +# pylint: disable=too-many-arguments, abstract-method class ZWaveHvac(ZWaveDeviceEntity, HvacDevice): """Represents a HeatControl hvac.""" diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 27c68819909..2b0af395d02 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -248,7 +248,8 @@ def setup(hass, config): class Light(ToggleEntity): """Representation of a light.""" - # pylint: disable=no-self-use + # pylint: disable=no-self-use, abstract-method + @property def brightness(self): """Return the brightness of this light between 0..255.""" diff --git a/homeassistant/components/light/limitlessled.py b/homeassistant/components/light/limitlessled.py index 5242746dc42..010088af824 100644 --- a/homeassistant/components/light/limitlessled.py +++ b/homeassistant/components/light/limitlessled.py @@ -4,6 +4,7 @@ Support for LimitlessLED bulbs. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.limitlessled/ """ +# pylint: disable=abstract-method import logging from homeassistant.components.light import ( diff --git a/homeassistant/components/light/mysensors.py b/homeassistant/components/light/mysensors.py index 04c0942e1f6..d8d288afd0e 100644 --- a/homeassistant/components/light/mysensors.py +++ b/homeassistant/components/light/mysensors.py @@ -4,6 +4,7 @@ Support for MySensors lights. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/light.mysensors/ """ +# pylint: disable=abstract-method import logging from homeassistant.components import mysensors diff --git a/homeassistant/components/switch/__init__.py b/homeassistant/components/switch/__init__.py index 1f92b458d53..60b9c9fdcd8 100644 --- a/homeassistant/components/switch/__init__.py +++ b/homeassistant/components/switch/__init__.py @@ -108,7 +108,7 @@ def setup(hass, config): class SwitchDevice(ToggleEntity): """Representation of a switch.""" - # pylint: disable=no-self-use + # pylint: disable=no-self-use, abstract-method @property def current_power_mwh(self): """Return the current power usage in mWh.""" diff --git a/homeassistant/components/switch/acer_projector.py b/homeassistant/components/switch/acer_projector.py index e6e1eb76b75..7a1f3498f18 100644 --- a/homeassistant/components/switch/acer_projector.py +++ b/homeassistant/components/switch/acer_projector.py @@ -4,7 +4,6 @@ Use serial protocol of acer projector to obtain state of the projector. This component allows to control almost all projectors from acer using their RS232 serial communication protocol. """ - import logging import re @@ -61,7 +60,8 @@ class AcerSwitch(SwitchDevice): write_timeout=write_timeout, **kwargs) self._serial_port = serial_port self._name = name - self._state = STATE_UNKNOWN + self._state = False + self._available = False self._attributes = { LAMP_HOURS: STATE_UNKNOWN, INPUT_SOURCE: STATE_UNKNOWN, @@ -100,14 +100,19 @@ class AcerSwitch(SwitchDevice): return match.group(1) return STATE_UNKNOWN + @property + def available(self): + """Return if projector is available.""" + return self._available + @property def name(self): """Return name of the projector.""" return self._name @property - def state(self): - """Return the current state of the projector.""" + def is_on(self): + """Return if the projector is turned on.""" return self._state @property @@ -120,11 +125,13 @@ class AcerSwitch(SwitchDevice): msg = CMD_DICT[LAMP] awns = self._write_read_format(msg) if awns == 'Lamp 1': - self._state = STATE_ON + self._state = True + self._available = True elif awns == 'Lamp 0': - self._state = STATE_OFF + self._state = False + self._available = True else: - self._state = STATE_UNKNOWN + self._available = False for key in self._attributes.keys(): msg = CMD_DICT.get(key, None) diff --git a/homeassistant/components/switch/arest.py b/homeassistant/components/switch/arest.py index 1a166a9c2dc..08138db9e70 100644 --- a/homeassistant/components/switch/arest.py +++ b/homeassistant/components/switch/arest.py @@ -4,6 +4,7 @@ Support for device running with the aREST RESTful framework. For more details about this platform, please refer to the documentation at https://home-assistant.io/components/switch.arest/ """ +# pylint: disable=abstract-method import logging import requests diff --git a/homeassistant/components/switch/wake_on_lan.py b/homeassistant/components/switch/wake_on_lan.py index e77453fa6eb..28a44249e12 100644 --- a/homeassistant/components/switch/wake_on_lan.py +++ b/homeassistant/components/switch/wake_on_lan.py @@ -65,6 +65,10 @@ class WOLSwitch(SwitchDevice): self._wol.send_magic_packet(self._mac_address) self.update_ha_state() + def turn_off(self): + """Do nothing.""" + pass + def update(self): """Check if device is on and update the state.""" if platform.system().lower() == "windows": diff --git a/homeassistant/components/thermostat/__init__.py b/homeassistant/components/thermostat/__init__.py index 4c57a23ff9c..8d811c3a5cc 100644 --- a/homeassistant/components/thermostat/__init__.py +++ b/homeassistant/components/thermostat/__init__.py @@ -273,29 +273,29 @@ class ThermostatDevice(Entity): """Return true if the fan is on.""" return None - def set_temperate(self, temperature): + def set_temperature(self, temperature): """Set new target temperature.""" - pass + raise NotImplementedError() def set_hvac_mode(self, hvac_mode): """Set hvac mode.""" - pass + raise NotImplementedError() def turn_away_mode_on(self): """Turn away mode on.""" - pass + raise NotImplementedError() def turn_away_mode_off(self): """Turn away mode off.""" - pass + raise NotImplementedError() def turn_fan_on(self): """Turn fan on.""" - pass + raise NotImplementedError() def turn_fan_off(self): """Turn fan off.""" - pass + raise NotImplementedError() @property def min_temp(self): diff --git a/homeassistant/components/thermostat/demo.py b/homeassistant/components/thermostat/demo.py index 5d47276c7bc..7718299ef6a 100644 --- a/homeassistant/components/thermostat/demo.py +++ b/homeassistant/components/thermostat/demo.py @@ -16,7 +16,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ]) -# pylint: disable=too-many-arguments +# pylint: disable=too-many-arguments, abstract-method class DemoThermostat(ThermostatDevice): """Representation of a demo thermostat.""" diff --git a/homeassistant/components/thermostat/ecobee.py b/homeassistant/components/thermostat/ecobee.py index f07ef47269d..577a33c87f4 100644 --- a/homeassistant/components/thermostat/ecobee.py +++ b/homeassistant/components/thermostat/ecobee.py @@ -68,7 +68,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): schema=SET_FAN_MIN_ON_TIME_SCHEMA) -# pylint: disable=too-many-public-methods +# pylint: disable=too-many-public-methods, abstract-method class Thermostat(ThermostatDevice): """A thermostat class for Ecobee.""" diff --git a/homeassistant/components/thermostat/eq3btsmart.py b/homeassistant/components/thermostat/eq3btsmart.py index 34c164f2c0d..c9bbdaeb0a4 100644 --- a/homeassistant/components/thermostat/eq3btsmart.py +++ b/homeassistant/components/thermostat/eq3btsmart.py @@ -31,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): return True -# pylint: disable=too-many-instance-attributes, import-error +# pylint: disable=too-many-instance-attributes, import-error, abstract-method class EQ3BTSmartThermostat(ThermostatDevice): """Representation of a EQ3 Bluetooth Smart thermostat.""" diff --git a/homeassistant/components/thermostat/heat_control.py b/homeassistant/components/thermostat/heat_control.py index 64f95c2e517..3d5190bcc2f 100644 --- a/homeassistant/components/thermostat/heat_control.py +++ b/homeassistant/components/thermostat/heat_control.py @@ -41,7 +41,6 @@ PLATFORM_SCHEMA = vol.Schema({ }) -# pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the heat control thermostat.""" name = config.get(CONF_NAME) @@ -55,7 +54,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): min_temp, max_temp, target_temp)]) -# pylint: disable=too-many-instance-attributes +# pylint: disable=too-many-instance-attributes, abstract-method class HeatControl(ThermostatDevice): """Representation of a HeatControl device.""" diff --git a/homeassistant/components/thermostat/heatmiser.py b/homeassistant/components/thermostat/heatmiser.py index ec8bbeb1981..e7bbfd72f9b 100644 --- a/homeassistant/components/thermostat/heatmiser.py +++ b/homeassistant/components/thermostat/heatmiser.py @@ -58,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class HeatmiserV3Thermostat(ThermostatDevice): """Representation of a HeatmiserV3 thermostat.""" - # pylint: disable=too-many-instance-attributes + # pylint: disable=too-many-instance-attributes, abstract-method def __init__(self, heatmiser, device, name, serport): """Initialize the thermostat.""" self.heatmiser = heatmiser diff --git a/homeassistant/components/thermostat/homematic.py b/homeassistant/components/thermostat/homematic.py index b4ecc6c166b..6f1ff29c16c 100644 --- a/homeassistant/components/thermostat/homematic.py +++ b/homeassistant/components/thermostat/homematic.py @@ -91,7 +91,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): return True -# pylint: disable=too-many-instance-attributes +# pylint: disable=too-many-instance-attributes, abstract-method class HomematicThermostat(ThermostatDevice): """Representation of a Homematic thermostat.""" diff --git a/homeassistant/components/thermostat/honeywell.py b/homeassistant/components/thermostat/honeywell.py index 633212e02b5..f45b07b9fd6 100644 --- a/homeassistant/components/thermostat/honeywell.py +++ b/homeassistant/components/thermostat/honeywell.py @@ -49,7 +49,6 @@ def _setup_round(username, password, config, add_devices): # config will be used later -# pylint: disable=unused-argument def _setup_us(username, password, config, add_devices): """Setup user.""" import somecomfort @@ -74,7 +73,6 @@ def _setup_us(username, password, config, add_devices): return True -# pylint: disable=unused-argument def setup_platform(hass, config, add_devices, discovery_info=None): """Setup the honeywel thermostat.""" username = config.get(CONF_USERNAME) @@ -98,7 +96,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class RoundThermostat(ThermostatDevice): """Representation of a Honeywell Round Connected thermostat.""" - # pylint: disable=too-many-instance-attributes + # pylint: disable=too-many-instance-attributes, abstract-method def __init__(self, device, zone_id, master, away_temp): """Initialize the thermostat.""" self.device = device @@ -182,6 +180,7 @@ class RoundThermostat(ThermostatDevice): self._is_dhw = False +# pylint: disable=abstract-method class HoneywellUSThermostat(ThermostatDevice): """Representation of a Honeywell US Thermostat.""" diff --git a/homeassistant/components/thermostat/nest.py b/homeassistant/components/thermostat/nest.py index 881eb821865..00a1acf07b4 100644 --- a/homeassistant/components/thermostat/nest.py +++ b/homeassistant/components/thermostat/nest.py @@ -26,6 +26,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): for structure, device in nest.devices()]) +# pylint: disable=abstract-method class NestThermostat(ThermostatDevice): """Representation of a Nest thermostat.""" diff --git a/homeassistant/components/thermostat/proliphix.py b/homeassistant/components/thermostat/proliphix.py index 4b86f556352..bf5c61d2be6 100644 --- a/homeassistant/components/thermostat/proliphix.py +++ b/homeassistant/components/thermostat/proliphix.py @@ -27,6 +27,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): ]) +# pylint: disable=abstract-method class ProliphixThermostat(ThermostatDevice): """Representation a Proliphix thermostat.""" diff --git a/homeassistant/components/thermostat/radiotherm.py b/homeassistant/components/thermostat/radiotherm.py index a6ae39434e7..963ef1a9a7f 100644 --- a/homeassistant/components/thermostat/radiotherm.py +++ b/homeassistant/components/thermostat/radiotherm.py @@ -45,6 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): add_devices(tstats) +# pylint: disable=abstract-method class RadioThermostat(ThermostatDevice): """Representation of a Radio Thermostat.""" diff --git a/homeassistant/components/thermostat/zwave.py b/homeassistant/components/thermostat/zwave.py index 57287605e67..8d7e36cc2aa 100644 --- a/homeassistant/components/thermostat/zwave.py +++ b/homeassistant/components/thermostat/zwave.py @@ -58,6 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): # pylint: disable=too-many-arguments, too-many-instance-attributes +# pylint: disable=abstract-method class ZWaveThermostat(zwave.ZWaveDeviceEntity, ThermostatDevice): """Represents a HeatControl thermostat.""" diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index ee1b786dce3..e4ccf11e168 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -229,17 +229,15 @@ class ToggleEntity(Entity): @property def is_on(self): """Return True if entity is on.""" - return False + raise NotImplementedError() def turn_on(self, **kwargs): """Turn the entity on.""" - _LOGGER.warning('Method turn_on not implemented for %s', - self.entity_id) + raise NotImplementedError() def turn_off(self, **kwargs): """Turn the entity off.""" - _LOGGER.warning('Method turn_off not implemented for %s', - self.entity_id) + raise NotImplementedError() def toggle(self, **kwargs): """Toggle the entity off."""