mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Update docstrings (#8244)
This commit is contained in:
parent
445065700c
commit
a9f14b67a8
@ -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
|
For more details about this component, please refer to the documentation at
|
||||||
https://home-assistant.io/components/comfoconnect/
|
https://home-assistant.io/components/comfoconnect/
|
||||||
@ -10,8 +10,7 @@ import voluptuous as vol
|
|||||||
|
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
CONF_HOST, CONF_NAME, CONF_TOKEN, CONF_PIN,
|
CONF_HOST, CONF_NAME, CONF_TOKEN, CONF_PIN, EVENT_HOMEASSISTANT_STOP)
|
||||||
EVENT_HOMEASSISTANT_STOP)
|
|
||||||
from homeassistant.helpers import (discovery)
|
from homeassistant.helpers import (discovery)
|
||||||
from homeassistant.helpers.dispatcher import (dispatcher_send)
|
from homeassistant.helpers.dispatcher import (dispatcher_send)
|
||||||
|
|
||||||
@ -32,28 +31,27 @@ ATTR_AIR_FLOW_EXHAUST = 'air_flow_exhaust'
|
|||||||
|
|
||||||
CONF_USER_AGENT = 'user_agent'
|
CONF_USER_AGENT = 'user_agent'
|
||||||
|
|
||||||
|
DEFAULT_NAME = 'ComfoAirQ'
|
||||||
DEFAULT_PIN = 0
|
DEFAULT_PIN = 0
|
||||||
DEFAULT_TOKEN = '00000000000000000000000000000001'
|
DEFAULT_TOKEN = '00000000000000000000000000000001'
|
||||||
DEFAULT_NAME = 'ComfoAirQ'
|
|
||||||
DEFAULT_USER_AGENT = 'Home Assistant'
|
DEFAULT_USER_AGENT = 'Home Assistant'
|
||||||
|
|
||||||
|
DEVICE = None
|
||||||
|
|
||||||
CONFIG_SCHEMA = vol.Schema({
|
CONFIG_SCHEMA = vol.Schema({
|
||||||
DOMAIN: vol.Schema({
|
DOMAIN: vol.Schema({
|
||||||
vol.Required(CONF_HOST): cv.string,
|
vol.Required(CONF_HOST): cv.string,
|
||||||
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
|
||||||
vol.Optional(CONF_TOKEN, default=DEFAULT_TOKEN):
|
vol.Optional(CONF_TOKEN, default=DEFAULT_TOKEN):
|
||||||
vol.Length(min=32, max=32, msg='invalid token'),
|
vol.Length(min=32, max=32, msg='invalid token'),
|
||||||
vol.Optional(CONF_USER_AGENT, default=DEFAULT_USER_AGENT):
|
vol.Optional(CONF_USER_AGENT, default=DEFAULT_USER_AGENT): cv.string,
|
||||||
cv.string,
|
|
||||||
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
|
vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
|
||||||
}),
|
}),
|
||||||
}, extra=vol.ALLOW_EXTRA)
|
}, extra=vol.ALLOW_EXTRA)
|
||||||
|
|
||||||
DEVICE = None
|
|
||||||
|
|
||||||
|
|
||||||
def setup(hass, config):
|
def setup(hass, config):
|
||||||
"""Setup the ComfoConnect bridge."""
|
"""Set up the ComfoConnect bridge."""
|
||||||
from pycomfoconnect import (Bridge)
|
from pycomfoconnect import (Bridge)
|
||||||
|
|
||||||
conf = config[DOMAIN]
|
conf = config[DOMAIN]
|
||||||
@ -66,10 +64,10 @@ def setup(hass, config):
|
|||||||
# Run discovery on the configured ip
|
# Run discovery on the configured ip
|
||||||
bridges = Bridge.discover(host)
|
bridges = Bridge.discover(host)
|
||||||
if not bridges:
|
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
|
return False
|
||||||
bridge = bridges[0]
|
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
|
# Setup ComfoConnect Bridge
|
||||||
ccb = ComfoConnectBridge(hass, bridge, name, token, user_agent, pin)
|
ccb = ComfoConnectBridge(hass, bridge, name, token, user_agent, pin)
|
||||||
@ -101,25 +99,24 @@ class ComfoConnectBridge(object):
|
|||||||
self.name = name
|
self.name = name
|
||||||
self.hass = hass
|
self.hass = hass
|
||||||
|
|
||||||
self.comfoconnect = ComfoConnect(bridge=bridge,
|
self.comfoconnect = ComfoConnect(
|
||||||
local_uuid=bytes.fromhex(token),
|
bridge=bridge, local_uuid=bytes.fromhex(token),
|
||||||
local_devicename=friendly_name,
|
local_devicename=friendly_name, pin=pin)
|
||||||
pin=pin)
|
|
||||||
self.comfoconnect.callback_sensor = self.sensor_callback
|
self.comfoconnect.callback_sensor = self.sensor_callback
|
||||||
|
|
||||||
def connect(self):
|
def connect(self):
|
||||||
"""Connect with the bridge."""
|
"""Connect with the bridge."""
|
||||||
_LOGGER.debug('Connecting with bridge.')
|
_LOGGER.debug("Connecting with bridge")
|
||||||
self.comfoconnect.connect(True)
|
self.comfoconnect.connect(True)
|
||||||
|
|
||||||
def disconnect(self):
|
def disconnect(self):
|
||||||
"""Disconnect from the bridge."""
|
"""Disconnect from the bridge."""
|
||||||
_LOGGER.debug('Disconnecting from bridge.')
|
_LOGGER.debug("Disconnecting from bridge")
|
||||||
self.comfoconnect.disconnect()
|
self.comfoconnect.disconnect()
|
||||||
|
|
||||||
def sensor_callback(self, var, value):
|
def sensor_callback(self, var, value):
|
||||||
"""Callback function for sensor updates."""
|
"""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 (
|
from pycomfoconnect import (
|
||||||
SENSOR_TEMPERATURE_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR)
|
SENSOR_TEMPERATURE_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Platform to control a Zehnder ComfoAir Q350/450/600 ventilation unit.
|
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/
|
https://home-assistant.io/components/fan.comfoconnect/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
@ -27,28 +27,19 @@ SPEED_MAPPING = {
|
|||||||
|
|
||||||
|
|
||||||
def setup_platform(hass, config, add_devices, discovery_info=None):
|
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]
|
ccb = hass.data[DOMAIN]
|
||||||
|
|
||||||
add_devices([
|
add_devices([ComfoConnectFan(hass, name=ccb.name, ccb=ccb)], True)
|
||||||
ComfoConnectFan(
|
|
||||||
hass,
|
|
||||||
name=ccb.name,
|
|
||||||
ccb=ccb
|
|
||||||
)
|
|
||||||
], True)
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
class ComfoConnectFan(FanEntity):
|
class ComfoConnectFan(FanEntity):
|
||||||
"""Representation of the fan platform."""
|
"""Representation of the ComfoConnect fan platform."""
|
||||||
|
|
||||||
def __init__(self, hass, name, ccb: ComfoConnectBridge):
|
def __init__(self, hass, name, ccb: ComfoConnectBridge):
|
||||||
"""Initialize the ComfoConnect fan."""
|
"""Initialize the ComfoConnect fan."""
|
||||||
from pycomfoconnect import (
|
from pycomfoconnect import SENSOR_FAN_SPEED_MODE
|
||||||
SENSOR_FAN_SPEED_MODE
|
|
||||||
)
|
|
||||||
|
|
||||||
self._ccb = ccb
|
self._ccb = ccb
|
||||||
self._name = name
|
self._name = name
|
||||||
@ -58,7 +49,7 @@ class ComfoConnectFan(FanEntity):
|
|||||||
|
|
||||||
def _handle_update(var):
|
def _handle_update(var):
|
||||||
if var == SENSOR_FAN_SPEED_MODE:
|
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()
|
self.schedule_update_ha_state()
|
||||||
|
|
||||||
# Register for dispatcher updates
|
# Register for dispatcher updates
|
||||||
@ -112,8 +103,7 @@ class ComfoConnectFan(FanEntity):
|
|||||||
|
|
||||||
from pycomfoconnect import (
|
from pycomfoconnect import (
|
||||||
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
|
CMD_FAN_MODE_AWAY, CMD_FAN_MODE_LOW, CMD_FAN_MODE_MEDIUM,
|
||||||
CMD_FAN_MODE_HIGH
|
CMD_FAN_MODE_HIGH)
|
||||||
)
|
|
||||||
|
|
||||||
if mode == SPEED_OFF:
|
if mode == SPEED_OFF:
|
||||||
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)
|
self._ccb.comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user