Update docstrings (#8244)

pull/8247/head
Fabian Affolter 2017-06-29 11:44:35 +02:00 committed by GitHub
parent 445065700c
commit a9f14b67a8
2 changed files with 22 additions and 35 deletions

View File

@ -1,5 +1,5 @@
"""
Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.
Support to control a Zehnder ComfoAir Q350/450/600 ventilation unit.
For more details about this component, please refer to the documentation at
https://home-assistant.io/components/comfoconnect/
@ -10,8 +10,7 @@ import voluptuous as vol
import homeassistant.helpers.config_validation as cv
from homeassistant.const import (
CONF_HOST, CONF_NAME, CONF_TOKEN, CONF_PIN,
EVENT_HOMEASSISTANT_STOP)
CONF_HOST, CONF_NAME, CONF_TOKEN, CONF_PIN, EVENT_HOMEASSISTANT_STOP)
from homeassistant.helpers import (discovery)
from homeassistant.helpers.dispatcher import (dispatcher_send)
@ -32,28 +31,27 @@ ATTR_AIR_FLOW_EXHAUST = 'air_flow_exhaust'
CONF_USER_AGENT = 'user_agent'
DEFAULT_NAME = 'ComfoAirQ'
DEFAULT_PIN = 0
DEFAULT_TOKEN = '00000000000000000000000000000001'
DEFAULT_NAME = 'ComfoAirQ'
DEFAULT_USER_AGENT = 'Home Assistant'
DEVICE = None
CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(CONF_HOST): cv.string,
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_TOKEN, default=DEFAULT_TOKEN):
vol.Length(min=32, max=32, msg='invalid token'),
vol.Optional(CONF_USER_AGENT, default=DEFAULT_USER_AGENT):
cv.string,
vol.Optional(CONF_USER_AGENT, default=DEFAULT_USER_AGENT): cv.string,
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
}),
}, extra=vol.ALLOW_EXTRA)
DEVICE = None
def setup(hass, config):
"""Setup the ComfoConnect bridge."""
"""Set up the ComfoConnect bridge."""
from pycomfoconnect import (Bridge)
conf = config[DOMAIN]
@ -66,10 +64,10 @@ def setup(hass, config):
# Run discovery on the configured ip
bridges = Bridge.discover(host)
if not bridges:
_LOGGER.error('Could not connect to ComfoConnect bridge on %s', host)
_LOGGER.error("Could not connect to ComfoConnect bridge on %s", host)
return False
bridge = bridges[0]
_LOGGER.info('Bridge found: %s (%s)', bridge.uuid.hex(), bridge.host)
_LOGGER.info("Bridge found: %s (%s)", bridge.uuid.hex(), bridge.host)
# Setup ComfoConnect Bridge
ccb = ComfoConnectBridge(hass, bridge, name, token, user_agent, pin)
@ -101,25 +99,24 @@ class ComfoConnectBridge(object):
self.name = name
self.hass = hass
self.comfoconnect = ComfoConnect(bridge=bridge,
local_uuid=bytes.fromhex(token),
local_devicename=friendly_name,
pin=pin)
self.comfoconnect = ComfoConnect(
bridge=bridge, local_uuid=bytes.fromhex(token),
local_devicename=friendly_name, pin=pin)
self.comfoconnect.callback_sensor = self.sensor_callback
def connect(self):
"""Connect with the bridge."""
_LOGGER.debug('Connecting with bridge.')
_LOGGER.debug("Connecting with bridge")
self.comfoconnect.connect(True)
def disconnect(self):
"""Disconnect from the bridge."""
_LOGGER.debug('Disconnecting from bridge.')
_LOGGER.debug("Disconnecting from bridge")
self.comfoconnect.disconnect()
def sensor_callback(self, var, value):
"""Callback 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)

View File

@ -1,7 +1,7 @@
"""
Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.
For more details about this component, please refer to the documentation at
For more details about this platform, please refer to the documentation at
https://home-assistant.io/components/fan.comfoconnect/
"""
import logging
@ -27,28 +27,19 @@ SPEED_MAPPING = {
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Setup the ComfoConnect fan platform."""
"""Set up the ComfoConnect fan platform."""
ccb = hass.data[DOMAIN]
add_devices([
ComfoConnectFan(
hass,
name=ccb.name,
ccb=ccb
)
], True)
add_devices([ComfoConnectFan(hass, name=ccb.name, ccb=ccb)], True)
return
class ComfoConnectFan(FanEntity):
"""Representation of the fan platform."""
"""Representation of the ComfoConnect fan platform."""
def __init__(self, hass, name, ccb: ComfoConnectBridge):
"""Initialize the ComfoConnect fan."""
from pycomfoconnect import (
SENSOR_FAN_SPEED_MODE
)
from pycomfoconnect import SENSOR_FAN_SPEED_MODE
self._ccb = ccb
self._name = name
@ -58,7 +49,7 @@ class ComfoConnectFan(FanEntity):
def _handle_update(var):
if var == SENSOR_FAN_SPEED_MODE:
_LOGGER.debug('Dispatcher update for %s.', var)
_LOGGER.debug("Dispatcher update for %s", var)
self.schedule_update_ha_state()
# Register for dispatcher updates
@ -112,8 +103,7 @@ class ComfoConnectFan(FanEntity):
from pycomfoconnect import (
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
CMD_FAN_MODE_HIGH
)
CMD_FAN_MODE_HIGH)
if mode == SPEED_OFF:
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)