ABC consistent not implemented behavior (#2359)

This commit is contained in:
Paulus Schoutsen 2016-06-24 21:27:40 -07:00 committed by GitHub
parent c616115419
commit 68df3deee0
22 changed files with 56 additions and 41 deletions

View File

@ -425,39 +425,39 @@ class HvacDevice(Entity):
def set_temperature(self, temperature): def set_temperature(self, temperature):
"""Set new target temperature.""" """Set new target temperature."""
pass raise NotImplementedError()
def set_humidity(self, humidity): def set_humidity(self, humidity):
"""Set new target humidity.""" """Set new target humidity."""
pass raise NotImplementedError()
def set_fan_mode(self, fan): def set_fan_mode(self, fan):
"""Set new target fan mode.""" """Set new target fan mode."""
pass raise NotImplementedError()
def set_operation_mode(self, operation_mode): def set_operation_mode(self, operation_mode):
"""Set new target operation mode.""" """Set new target operation mode."""
pass raise NotImplementedError()
def set_swing_mode(self, swing_mode): def set_swing_mode(self, swing_mode):
"""Set new target swing operation.""" """Set new target swing operation."""
pass raise NotImplementedError()
def turn_away_mode_on(self): def turn_away_mode_on(self):
"""Turn away mode on.""" """Turn away mode on."""
pass raise NotImplementedError()
def turn_away_mode_off(self): def turn_away_mode_off(self):
"""Turn away mode off.""" """Turn away mode off."""
pass raise NotImplementedError()
def turn_aux_heat_on(self): def turn_aux_heat_on(self):
"""Turn auxillary heater on.""" """Turn auxillary heater on."""
pass raise NotImplementedError()
def turn_aux_heat_off(self): def turn_aux_heat_off(self):
"""Turn auxillary heater off.""" """Turn auxillary heater off."""
pass raise NotImplementedError()
@property @property
def min_temp(self): def min_temp(self):

View File

@ -58,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
discovery_info, zwave.NETWORK) discovery_info, zwave.NETWORK)
# pylint: disable=too-many-arguments # pylint: disable=too-many-arguments, abstract-method
class ZWaveHvac(ZWaveDeviceEntity, HvacDevice): class ZWaveHvac(ZWaveDeviceEntity, HvacDevice):
"""Represents a HeatControl hvac.""" """Represents a HeatControl hvac."""

View File

@ -248,7 +248,8 @@ def setup(hass, config):
class Light(ToggleEntity): class Light(ToggleEntity):
"""Representation of a light.""" """Representation of a light."""
# pylint: disable=no-self-use # pylint: disable=no-self-use, abstract-method
@property @property
def brightness(self): def brightness(self):
"""Return the brightness of this light between 0..255.""" """Return the brightness of this light between 0..255."""

View File

@ -4,6 +4,7 @@ Support for LimitlessLED bulbs.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.limitlessled/ https://home-assistant.io/components/light.limitlessled/
""" """
# pylint: disable=abstract-method
import logging import logging
from homeassistant.components.light import ( from homeassistant.components.light import (

View File

@ -4,6 +4,7 @@ Support for MySensors lights.
For more details about this platform, please refer to the documentation at For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/light.mysensors/ https://home-assistant.io/components/light.mysensors/
""" """
# pylint: disable=abstract-method
import logging import logging
from homeassistant.components import mysensors from homeassistant.components import mysensors

View File

@ -108,7 +108,7 @@ def setup(hass, config):
class SwitchDevice(ToggleEntity): class SwitchDevice(ToggleEntity):
"""Representation of a switch.""" """Representation of a switch."""
# pylint: disable=no-self-use # pylint: disable=no-self-use, abstract-method
@property @property
def current_power_mwh(self): def current_power_mwh(self):
"""Return the current power usage in mWh.""" """Return the current power usage in mWh."""

View File

@ -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 This component allows to control almost all projectors from acer using
their RS232 serial communication protocol. their RS232 serial communication protocol.
""" """
import logging import logging
import re import re
@ -61,7 +60,8 @@ class AcerSwitch(SwitchDevice):
write_timeout=write_timeout, **kwargs) write_timeout=write_timeout, **kwargs)
self._serial_port = serial_port self._serial_port = serial_port
self._name = name self._name = name
self._state = STATE_UNKNOWN self._state = False
self._available = False
self._attributes = { self._attributes = {
LAMP_HOURS: STATE_UNKNOWN, LAMP_HOURS: STATE_UNKNOWN,
INPUT_SOURCE: STATE_UNKNOWN, INPUT_SOURCE: STATE_UNKNOWN,
@ -100,14 +100,19 @@ class AcerSwitch(SwitchDevice):
return match.group(1) return match.group(1)
return STATE_UNKNOWN return STATE_UNKNOWN
@property
def available(self):
"""Return if projector is available."""
return self._available
@property @property
def name(self): def name(self):
"""Return name of the projector.""" """Return name of the projector."""
return self._name return self._name
@property @property
def state(self): def is_on(self):
"""Return the current state of the projector.""" """Return if the projector is turned on."""
return self._state return self._state
@property @property
@ -120,11 +125,13 @@ class AcerSwitch(SwitchDevice):
msg = CMD_DICT[LAMP] msg = CMD_DICT[LAMP]
awns = self._write_read_format(msg) awns = self._write_read_format(msg)
if awns == 'Lamp 1': if awns == 'Lamp 1':
self._state = STATE_ON self._state = True
self._available = True
elif awns == 'Lamp 0': elif awns == 'Lamp 0':
self._state = STATE_OFF self._state = False
self._available = True
else: else:
self._state = STATE_UNKNOWN self._available = False
for key in self._attributes.keys(): for key in self._attributes.keys():
msg = CMD_DICT.get(key, None) msg = CMD_DICT.get(key, None)

View File

@ -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 For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/switch.arest/ https://home-assistant.io/components/switch.arest/
""" """
# pylint: disable=abstract-method
import logging import logging
import requests import requests

View File

@ -65,6 +65,10 @@ class WOLSwitch(SwitchDevice):
self._wol.send_magic_packet(self._mac_address) self._wol.send_magic_packet(self._mac_address)
self.update_ha_state() self.update_ha_state()
def turn_off(self):
"""Do nothing."""
pass
def update(self): def update(self):
"""Check if device is on and update the state.""" """Check if device is on and update the state."""
if platform.system().lower() == "windows": if platform.system().lower() == "windows":

View File

@ -273,29 +273,29 @@ class ThermostatDevice(Entity):
"""Return true if the fan is on.""" """Return true if the fan is on."""
return None return None
def set_temperate(self, temperature): def set_temperature(self, temperature):
"""Set new target temperature.""" """Set new target temperature."""
pass raise NotImplementedError()
def set_hvac_mode(self, hvac_mode): def set_hvac_mode(self, hvac_mode):
"""Set hvac mode.""" """Set hvac mode."""
pass raise NotImplementedError()
def turn_away_mode_on(self): def turn_away_mode_on(self):
"""Turn away mode on.""" """Turn away mode on."""
pass raise NotImplementedError()
def turn_away_mode_off(self): def turn_away_mode_off(self):
"""Turn away mode off.""" """Turn away mode off."""
pass raise NotImplementedError()
def turn_fan_on(self): def turn_fan_on(self):
"""Turn fan on.""" """Turn fan on."""
pass raise NotImplementedError()
def turn_fan_off(self): def turn_fan_off(self):
"""Turn fan off.""" """Turn fan off."""
pass raise NotImplementedError()
@property @property
def min_temp(self): def min_temp(self):

View File

@ -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): class DemoThermostat(ThermostatDevice):
"""Representation of a demo thermostat.""" """Representation of a demo thermostat."""

View File

@ -68,7 +68,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
schema=SET_FAN_MIN_ON_TIME_SCHEMA) schema=SET_FAN_MIN_ON_TIME_SCHEMA)
# pylint: disable=too-many-public-methods # pylint: disable=too-many-public-methods, abstract-method
class Thermostat(ThermostatDevice): class Thermostat(ThermostatDevice):
"""A thermostat class for Ecobee.""" """A thermostat class for Ecobee."""

View File

@ -31,7 +31,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return True return True
# pylint: disable=too-many-instance-attributes, import-error # pylint: disable=too-many-instance-attributes, import-error, abstract-method
class EQ3BTSmartThermostat(ThermostatDevice): class EQ3BTSmartThermostat(ThermostatDevice):
"""Representation of a EQ3 Bluetooth Smart thermostat.""" """Representation of a EQ3 Bluetooth Smart thermostat."""

View File

@ -41,7 +41,6 @@ PLATFORM_SCHEMA = vol.Schema({
}) })
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the heat control thermostat.""" """Setup the heat control thermostat."""
name = config.get(CONF_NAME) 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)]) min_temp, max_temp, target_temp)])
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes, abstract-method
class HeatControl(ThermostatDevice): class HeatControl(ThermostatDevice):
"""Representation of a HeatControl device.""" """Representation of a HeatControl device."""

View File

@ -58,7 +58,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class HeatmiserV3Thermostat(ThermostatDevice): class HeatmiserV3Thermostat(ThermostatDevice):
"""Representation of a HeatmiserV3 thermostat.""" """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): def __init__(self, heatmiser, device, name, serport):
"""Initialize the thermostat.""" """Initialize the thermostat."""
self.heatmiser = heatmiser self.heatmiser = heatmiser

View File

@ -91,7 +91,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
return True return True
# pylint: disable=too-many-instance-attributes # pylint: disable=too-many-instance-attributes, abstract-method
class HomematicThermostat(ThermostatDevice): class HomematicThermostat(ThermostatDevice):
"""Representation of a Homematic thermostat.""" """Representation of a Homematic thermostat."""

View File

@ -49,7 +49,6 @@ def _setup_round(username, password, config, add_devices):
# config will be used later # config will be used later
# pylint: disable=unused-argument
def _setup_us(username, password, config, add_devices): def _setup_us(username, password, config, add_devices):
"""Setup user.""" """Setup user."""
import somecomfort import somecomfort
@ -74,7 +73,6 @@ def _setup_us(username, password, config, add_devices):
return True return True
# pylint: disable=unused-argument
def setup_platform(hass, config, add_devices, discovery_info=None): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the honeywel thermostat.""" """Setup the honeywel thermostat."""
username = config.get(CONF_USERNAME) username = config.get(CONF_USERNAME)
@ -98,7 +96,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
class RoundThermostat(ThermostatDevice): class RoundThermostat(ThermostatDevice):
"""Representation of a Honeywell Round Connected thermostat.""" """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): def __init__(self, device, zone_id, master, away_temp):
"""Initialize the thermostat.""" """Initialize the thermostat."""
self.device = device self.device = device
@ -182,6 +180,7 @@ class RoundThermostat(ThermostatDevice):
self._is_dhw = False self._is_dhw = False
# pylint: disable=abstract-method
class HoneywellUSThermostat(ThermostatDevice): class HoneywellUSThermostat(ThermostatDevice):
"""Representation of a Honeywell US Thermostat.""" """Representation of a Honeywell US Thermostat."""

View File

@ -26,6 +26,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
for structure, device in nest.devices()]) for structure, device in nest.devices()])
# pylint: disable=abstract-method
class NestThermostat(ThermostatDevice): class NestThermostat(ThermostatDevice):
"""Representation of a Nest thermostat.""" """Representation of a Nest thermostat."""

View File

@ -27,6 +27,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
]) ])
# pylint: disable=abstract-method
class ProliphixThermostat(ThermostatDevice): class ProliphixThermostat(ThermostatDevice):
"""Representation a Proliphix thermostat.""" """Representation a Proliphix thermostat."""

View File

@ -45,6 +45,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
add_devices(tstats) add_devices(tstats)
# pylint: disable=abstract-method
class RadioThermostat(ThermostatDevice): class RadioThermostat(ThermostatDevice):
"""Representation of a Radio Thermostat.""" """Representation of a Radio Thermostat."""

View File

@ -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=too-many-arguments, too-many-instance-attributes
# pylint: disable=abstract-method
class ZWaveThermostat(zwave.ZWaveDeviceEntity, ThermostatDevice): class ZWaveThermostat(zwave.ZWaveDeviceEntity, ThermostatDevice):
"""Represents a HeatControl thermostat.""" """Represents a HeatControl thermostat."""

View File

@ -229,17 +229,15 @@ class ToggleEntity(Entity):
@property @property
def is_on(self): def is_on(self):
"""Return True if entity is on.""" """Return True if entity is on."""
return False raise NotImplementedError()
def turn_on(self, **kwargs): def turn_on(self, **kwargs):
"""Turn the entity on.""" """Turn the entity on."""
_LOGGER.warning('Method turn_on not implemented for %s', raise NotImplementedError()
self.entity_id)
def turn_off(self, **kwargs): def turn_off(self, **kwargs):
"""Turn the entity off.""" """Turn the entity off."""
_LOGGER.warning('Method turn_off not implemented for %s', raise NotImplementedError()
self.entity_id)
def toggle(self, **kwargs): def toggle(self, **kwargs):
"""Toggle the entity off.""" """Toggle the entity off."""