1 """Support to control a Zehnder ComfoAir Q350/450/600 ventilation unit."""
5 from pycomfoconnect
import Bridge, ComfoConnect
6 import voluptuous
as vol
13 EVENT_HOMEASSISTANT_STOP,
22 _LOGGER = logging.getLogger(__name__)
24 DOMAIN =
"comfoconnect"
26 SIGNAL_COMFOCONNECT_UPDATE_RECEIVED =
"comfoconnect_update_received_{}"
28 CONF_USER_AGENT =
"user_agent"
30 DEFAULT_NAME =
"ComfoAirQ"
32 DEFAULT_TOKEN =
"00000000000000000000000000000001"
33 DEFAULT_USER_AGENT =
"Home Assistant"
35 CONFIG_SCHEMA = vol.Schema(
39 vol.Required(CONF_HOST): cv.string,
40 vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
41 vol.Optional(CONF_TOKEN, default=DEFAULT_TOKEN): vol.Length(
42 min=32, max=32, msg=
"invalid token"
44 vol.Optional(CONF_USER_AGENT, default=DEFAULT_USER_AGENT): cv.string,
45 vol.Optional(CONF_PIN, default=DEFAULT_PIN): cv.positive_int,
49 extra=vol.ALLOW_EXTRA,
53 def setup(hass: HomeAssistant, config: ConfigType) -> bool:
54 """Set up the ComfoConnect bridge."""
57 host = conf[CONF_HOST]
58 name = conf[CONF_NAME]
59 token = conf[CONF_TOKEN]
60 user_agent = conf[CONF_USER_AGENT]
64 bridges = Bridge.discover(host)
66 _LOGGER.error(
"Could not connect to ComfoConnect bridge on %s", host)
69 _LOGGER.debug(
"Bridge found: %s (%s)", bridge.uuid.hex(), bridge.host)
73 hass.data[DOMAIN] = ccb
79 def _shutdown(_event: Event) ->
None:
82 hass.bus.listen_once(EVENT_HOMEASSISTANT_STOP, _shutdown)
85 discovery.load_platform(hass, Platform.FAN, DOMAIN, {}, config)
91 """Representation of a ComfoConnect bridge."""
102 """Initialize the ComfoConnect bridge."""
109 local_uuid=bytes.fromhex(token),
110 local_devicename=friendly_name,
116 """Connect with the bridge."""
117 _LOGGER.debug(
"Connecting with bridge")
121 """Disconnect from the bridge."""
122 _LOGGER.debug(
"Disconnecting from bridge")
126 """Notify listeners that we have received an update."""
127 _LOGGER.debug(
"Received update for %s: %s", var, value)
129 self.
hasshass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED.format(var), value
None sensor_callback(self, str var, str value)
None __init__(self, HomeAssistant hass, Bridge bridge, str name, str token, str friendly_name, int pin)
bool setup(HomeAssistant hass, ConfigType config)
None dispatcher_send(HomeAssistant hass, str signal, *Any args)