Move imports in comfoconnect component (#27886)

pull/27897/head
bouni 2019-10-19 00:01:03 +02:00 committed by cgtobi
parent dc30119d20
commit 93db814b15
3 changed files with 23 additions and 24 deletions

View File

@ -1,6 +1,12 @@
"""Support to control a Zehnder ComfoAir Q350/450/600 ventilation unit.""" """Support to control a Zehnder ComfoAir Q350/450/600 ventilation unit."""
import logging import logging
from pycomfoconnect import (
SENSOR_TEMPERATURE_EXTRACT,
SENSOR_TEMPERATURE_OUTDOOR,
Bridge,
ComfoConnect,
)
import voluptuous as vol import voluptuous as vol
from homeassistant.const import ( from homeassistant.const import (
@ -56,7 +62,6 @@ CONFIG_SCHEMA = vol.Schema(
def setup(hass, config): def setup(hass, config):
"""Set up the ComfoConnect bridge.""" """Set up the ComfoConnect bridge."""
from pycomfoconnect import Bridge
conf = config[DOMAIN] conf = config[DOMAIN]
host = conf.get(CONF_HOST) host = conf.get(CONF_HOST)
@ -97,7 +102,6 @@ class ComfoConnectBridge:
def __init__(self, hass, bridge, name, token, friendly_name, pin): def __init__(self, hass, bridge, name, token, friendly_name, pin):
"""Initialize the ComfoConnect bridge.""" """Initialize the ComfoConnect bridge."""
from pycomfoconnect import ComfoConnect
self.data = {} self.data = {}
self.name = name self.name = name
@ -125,11 +129,6 @@ class ComfoConnectBridge:
"""Call function for sensor updates.""" """Call function for sensor updates."""
_LOGGER.debug("Got value from bridge: %d = %d", var, value) _LOGGER.debug("Got value from bridge: %d = %d", var, value)
from pycomfoconnect import (
SENSOR_TEMPERATURE_EXTRACT,
SENSOR_TEMPERATURE_OUTDOOR,
)
if var in [SENSOR_TEMPERATURE_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR]: if var in [SENSOR_TEMPERATURE_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR]:
self.data[var] = value / 10 self.data[var] = value / 10
else: else:

View File

@ -1,6 +1,14 @@
"""Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.""" """Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit."""
import logging import logging
from pycomfoconnect import (
CMD_FAN_MODE_AWAY,
CMD_FAN_MODE_HIGH,
CMD_FAN_MODE_LOW,
CMD_FAN_MODE_MEDIUM,
SENSOR_FAN_SPEED_MODE,
)
from homeassistant.components.fan import ( from homeassistant.components.fan import (
SPEED_HIGH, SPEED_HIGH,
SPEED_LOW, SPEED_LOW,
@ -30,7 +38,6 @@ class ComfoConnectFan(FanEntity):
def __init__(self, hass, name, ccb: ComfoConnectBridge) -> None: def __init__(self, hass, name, ccb: ComfoConnectBridge) -> None:
"""Initialize the ComfoConnect fan.""" """Initialize the ComfoConnect fan."""
from pycomfoconnect import SENSOR_FAN_SPEED_MODE
self._ccb = ccb self._ccb = ccb
self._name = name self._name = name
@ -64,7 +71,6 @@ class ComfoConnectFan(FanEntity):
@property @property
def speed(self): def speed(self):
"""Return the current fan mode.""" """Return the current fan mode."""
from pycomfoconnect import SENSOR_FAN_SPEED_MODE
try: try:
speed = self._ccb.data[SENSOR_FAN_SPEED_MODE] speed = self._ccb.data[SENSOR_FAN_SPEED_MODE]
@ -91,13 +97,6 @@ class ComfoConnectFan(FanEntity):
"""Set fan speed.""" """Set fan speed."""
_LOGGER.debug("Changing fan speed to %s.", speed) _LOGGER.debug("Changing fan speed to %s.", speed)
from pycomfoconnect import (
CMD_FAN_MODE_AWAY,
CMD_FAN_MODE_LOW,
CMD_FAN_MODE_MEDIUM,
CMD_FAN_MODE_HIGH,
)
if speed == SPEED_OFF: if speed == SPEED_OFF:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY) self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)
elif speed == SPEED_LOW: elif speed == SPEED_LOW:

View File

@ -1,6 +1,15 @@
"""Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.""" """Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit."""
import logging import logging
from pycomfoconnect import (
SENSOR_FAN_EXHAUST_FLOW,
SENSOR_FAN_SUPPLY_FLOW,
SENSOR_HUMIDITY_EXTRACT,
SENSOR_HUMIDITY_OUTDOOR,
SENSOR_TEMPERATURE_EXTRACT,
SENSOR_TEMPERATURE_OUTDOOR,
)
from homeassistant.const import CONF_RESOURCES, TEMP_CELSIUS from homeassistant.const import CONF_RESOURCES, TEMP_CELSIUS
from homeassistant.helpers.dispatcher import dispatcher_connect from homeassistant.helpers.dispatcher import dispatcher_connect
from homeassistant.helpers.entity import Entity from homeassistant.helpers.entity import Entity
@ -24,14 +33,6 @@ SENSOR_TYPES = {}
def setup_platform(hass, config, add_entities, discovery_info=None): def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the ComfoConnect fan platform.""" """Set up the ComfoConnect fan platform."""
from pycomfoconnect import (
SENSOR_TEMPERATURE_EXTRACT,
SENSOR_HUMIDITY_EXTRACT,
SENSOR_TEMPERATURE_OUTDOOR,
SENSOR_HUMIDITY_OUTDOOR,
SENSOR_FAN_SUPPLY_FLOW,
SENSOR_FAN_EXHAUST_FLOW,
)
global SENSOR_TYPES global SENSOR_TYPES
SENSOR_TYPES = { SENSOR_TYPES = {