mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Merge pull request #766 from balloob/import_fixes
Import fixes for wink and heatmiser
This commit is contained in:
commit
7fb5927ac8
@ -37,9 +37,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class WinkLockDevice(LockDevice):
|
class WinkLockDevice(LockDevice):
|
||||||
""" Represents a Wink lock. """
|
""" Represents a Wink lock. """
|
||||||
|
|
||||||
import pywink
|
def __init__(self, wink):
|
||||||
|
|
||||||
def __init__(self, wink: pywink.WinkLock):
|
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -10,7 +10,6 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/thermostat.heatmiser/
|
https://home-assistant.io/components/thermostat.heatmiser/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
import heatmiserV3
|
|
||||||
from homeassistant.components.thermostat import ThermostatDevice
|
from homeassistant.components.thermostat import ThermostatDevice
|
||||||
from homeassistant.const import TEMP_CELCIUS
|
from homeassistant.const import TEMP_CELCIUS
|
||||||
|
|
||||||
@ -26,6 +25,8 @@ _LOGGER = logging.getLogger(__name__)
|
|||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
def setup_platform(hass, config, add_devices, discovery_info=None):
|
||||||
""" Sets up the heatmiser thermostat. """
|
""" Sets up the heatmiser thermostat. """
|
||||||
|
|
||||||
|
from heatmiserV3 import heatmiser, connection
|
||||||
|
|
||||||
ipaddress = str(config[CONF_IPADDRESS])
|
ipaddress = str(config[CONF_IPADDRESS])
|
||||||
port = str(config[CONF_PORT])
|
port = str(config[CONF_PORT])
|
||||||
|
|
||||||
@ -34,7 +35,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
CONF_IPADDRESS, CONF_PORT)
|
CONF_IPADDRESS, CONF_PORT)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
serport = heatmiserV3.connection.connection(ipaddress, port)
|
serport = connection.connection(ipaddress, port)
|
||||||
serport.open()
|
serport.open()
|
||||||
|
|
||||||
tstats = []
|
tstats = []
|
||||||
@ -48,6 +49,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
for tstat in tstats:
|
for tstat in tstats:
|
||||||
add_devices([
|
add_devices([
|
||||||
HeatmiserV3Thermostat(
|
HeatmiserV3Thermostat(
|
||||||
|
heatmiser,
|
||||||
tstat.get("id"),
|
tstat.get("id"),
|
||||||
tstat.get("name"),
|
tstat.get("name"),
|
||||||
serport)
|
serport)
|
||||||
@ -58,7 +60,9 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
class HeatmiserV3Thermostat(ThermostatDevice):
|
class HeatmiserV3Thermostat(ThermostatDevice):
|
||||||
""" Represents a HeatmiserV3 thermostat. """
|
""" Represents a HeatmiserV3 thermostat. """
|
||||||
|
|
||||||
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.device = device
|
||||||
self.serport = serport
|
self.serport = serport
|
||||||
self._current_temperature = None
|
self._current_temperature = None
|
||||||
@ -98,7 +102,7 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
|||||||
def set_temperature(self, temperature):
|
def set_temperature(self, temperature):
|
||||||
""" Set new target temperature """
|
""" Set new target temperature """
|
||||||
temperature = int(temperature)
|
temperature = int(temperature)
|
||||||
heatmiserV3.heatmiser.hmSendAddress(
|
self.heatmiser.hmSendAddress(
|
||||||
self._id,
|
self._id,
|
||||||
18,
|
18,
|
||||||
temperature,
|
temperature,
|
||||||
@ -107,7 +111,7 @@ class HeatmiserV3Thermostat(ThermostatDevice):
|
|||||||
self._target_temperature = int(temperature)
|
self._target_temperature = int(temperature)
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.dcb = heatmiserV3.heatmiser.hmReadAddress(
|
self.dcb = self.heatmiser.hmReadAddress(
|
||||||
self._id,
|
self._id,
|
||||||
'prt',
|
'prt',
|
||||||
self.serport)
|
self.serport)
|
||||||
|
@ -61,9 +61,8 @@ def setup(hass, config):
|
|||||||
|
|
||||||
class WinkToggleDevice(ToggleEntity):
|
class WinkToggleDevice(ToggleEntity):
|
||||||
""" Represents a Wink toogle (switch) device. """
|
""" Represents a Wink toogle (switch) device. """
|
||||||
import pywink
|
|
||||||
|
|
||||||
def __init__(self, wink: pywink.WinkBinarySwitch):
|
def __init__(self, wink):
|
||||||
self.wink = wink
|
self.wink = wink
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user