From 31b4c8eb4dd44bebc117ef13b1215266a9b26577 Mon Sep 17 00:00:00 2001 From: Tom Duijf Date: Wed, 16 Dec 2015 21:52:49 +0000 Subject: [PATCH 1/3] Fixed imports --- homeassistant/components/lock/wink.py | 4 +--- homeassistant/components/thermostat/heatmiser.py | 3 ++- homeassistant/components/wink.py | 3 +-- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/lock/wink.py b/homeassistant/components/lock/wink.py index 3fd6d4bcf85..1ab8bcdc920 100644 --- a/homeassistant/components/lock/wink.py +++ b/homeassistant/components/lock/wink.py @@ -37,9 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class WinkLockDevice(LockDevice): """ Represents a Wink lock. """ - import pywink - - def __init__(self, wink: pywink.WinkLock): + def __init__(self, wink): self.wink = wink @property diff --git a/homeassistant/components/thermostat/heatmiser.py b/homeassistant/components/thermostat/heatmiser.py index eaeef858172..2a6a3b60e28 100644 --- a/homeassistant/components/thermostat/heatmiser.py +++ b/homeassistant/components/thermostat/heatmiser.py @@ -10,7 +10,6 @@ For more details about this platform, please refer to the documentation at https://home-assistant.io/components/thermostat.heatmiser/ """ import logging -import heatmiserV3 from homeassistant.components.thermostat import ThermostatDevice from homeassistant.const import TEMP_CELCIUS @@ -26,6 +25,8 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the heatmiser thermostat. """ + import heatmiserV3 + ipaddress = str(config[CONF_IPADDRESS]) port = str(config[CONF_PORT]) diff --git a/homeassistant/components/wink.py b/homeassistant/components/wink.py index c597a43cb4d..32ec26555b0 100644 --- a/homeassistant/components/wink.py +++ b/homeassistant/components/wink.py @@ -61,9 +61,8 @@ def setup(hass, config): class WinkToggleDevice(ToggleEntity): """ Represents a Wink toogle (switch) device. """ - import pywink - def __init__(self, wink: pywink.WinkBinarySwitch): + def __init__(self, wink): self.wink = wink @property From 687ce645519d92e2af73869c3bbc844366b583f2 Mon Sep 17 00:00:00 2001 From: Tom Duijf Date: Wed, 16 Dec 2015 22:21:32 +0000 Subject: [PATCH 2/3] small cleanup heatmiser --- homeassistant/components/thermostat/heatmiser.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/thermostat/heatmiser.py b/homeassistant/components/thermostat/heatmiser.py index 2a6a3b60e28..d5f434dee34 100644 --- a/homeassistant/components/thermostat/heatmiser.py +++ b/homeassistant/components/thermostat/heatmiser.py @@ -25,7 +25,7 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the heatmiser thermostat. """ - import heatmiserV3 + from heatmiserV3 import connection as HMC ipaddress = str(config[CONF_IPADDRESS]) port = str(config[CONF_PORT]) @@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): CONF_IPADDRESS, CONF_PORT) return False - serport = heatmiserV3.connection.connection(ipaddress, port) + serport = HMC.connection(ipaddress, port) serport.open() tstats = [] @@ -58,8 +58,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class HeatmiserV3Thermostat(ThermostatDevice): """ Represents a HeatmiserV3 thermostat. """ + from heatmiserV3 import heatmiser def __init__(self, device, name, serport): + self.device = device self.serport = serport self._current_temperature = None @@ -99,7 +101,7 @@ class HeatmiserV3Thermostat(ThermostatDevice): def set_temperature(self, temperature): """ Set new target temperature """ temperature = int(temperature) - heatmiserV3.heatmiser.hmSendAddress( + self.heatmiser.hmSendAddress( self._id, 18, temperature, @@ -108,7 +110,7 @@ class HeatmiserV3Thermostat(ThermostatDevice): self._target_temperature = int(temperature) def update(self): - self.dcb = heatmiserV3.heatmiser.hmReadAddress( + self.dcb = self.heatmiser.hmReadAddress( self._id, 'prt', self.serport) From 4eec89b35e14eaee3804f1864be121e326ee7422 Mon Sep 17 00:00:00 2001 From: Tom Duijf Date: Wed, 16 Dec 2015 22:36:40 +0000 Subject: [PATCH 3/3] fixed my own cleanup --- homeassistant/components/thermostat/heatmiser.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/homeassistant/components/thermostat/heatmiser.py b/homeassistant/components/thermostat/heatmiser.py index d5f434dee34..a7ea7699558 100644 --- a/homeassistant/components/thermostat/heatmiser.py +++ b/homeassistant/components/thermostat/heatmiser.py @@ -25,7 +25,7 @@ _LOGGER = logging.getLogger(__name__) def setup_platform(hass, config, add_devices, discovery_info=None): """ Sets up the heatmiser thermostat. """ - from heatmiserV3 import connection as HMC + from heatmiserV3 import heatmiser, connection ipaddress = str(config[CONF_IPADDRESS]) port = str(config[CONF_PORT]) @@ -35,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): CONF_IPADDRESS, CONF_PORT) return False - serport = HMC.connection(ipaddress, port) + serport = connection.connection(ipaddress, port) serport.open() tstats = [] @@ -49,6 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None): for tstat in tstats: add_devices([ HeatmiserV3Thermostat( + heatmiser, tstat.get("id"), tstat.get("name"), serport) @@ -58,10 +59,10 @@ def setup_platform(hass, config, add_devices, discovery_info=None): class HeatmiserV3Thermostat(ThermostatDevice): """ Represents a HeatmiserV3 thermostat. """ - from heatmiserV3 import heatmiser - - def __init__(self, device, name, serport): + # pylint: disable=too-many-instance-attributes + def __init__(self, heatmiser, device, name, serport): + self.heatmiser = heatmiser self.device = device self.serport = serport self._current_temperature = None