class ComfoConnectBridge: """Representation of a ComfoConnect bridge.""" def __init__(self, hass, bridge, name, token, friendly_name, pin): """Initialize the ComfoConnect bridge.""" self.name = name self.hass = hass self.unique_id = bridge.uuid.hex() 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") self.comfoconnect.connect(True) def disconnect(self): """Disconnect from the bridge.""" _LOGGER.debug("Disconnecting from bridge") self.comfoconnect.disconnect() def sensor_callback(self, var, value): """Notify listeners that we have received an update.""" _LOGGER.debug("Received update for %s: %s", var, value) dispatcher_send(self.hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED.format(var), value)
def __init__(self, hass, bridge, name, token, friendly_name, pin): """Initialize the ComfoConnect bridge.""" from pycomfoconnect import (ComfoConnect) self.data = {} self.name = name self.hass = hass self.comfoconnect = ComfoConnect( bridge=bridge, local_uuid=bytes.fromhex(token), local_devicename=friendly_name, pin=pin) self.comfoconnect.callback_sensor = self.sensor_callback
def __init__(self, hass, bridge, name, token, friendly_name, pin): """Initialize the ComfoConnect bridge.""" self.name = name self.hass = hass self.unique_id = bridge.uuid.hex() self.comfoconnect = ComfoConnect( bridge=bridge, local_uuid=bytes.fromhex(token), local_devicename=friendly_name, pin=pin, ) self.comfoconnect.callback_sensor = self.sensor_callback
class ComfoConnectBridge: """Representation of a ComfoConnect bridge.""" def __init__(self, hass, bridge, name, token, friendly_name, pin): """Initialize the ComfoConnect bridge.""" self.data = {} self.name = name self.hass = hass 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") self.comfoconnect.connect(True) def disconnect(self): """Disconnect from the bridge.""" _LOGGER.debug("Disconnecting from bridge") self.comfoconnect.disconnect() def sensor_callback(self, var, value): """Call function for sensor updates.""" _LOGGER.debug("Got value from bridge: %d = %d", var, value) if var in [SENSOR_TEMPERATURE_EXTRACT, SENSOR_TEMPERATURE_OUTDOOR]: self.data[var] = value / 10 else: self.data[var] = value # Notify listeners that we have received an update dispatcher_send(self.hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED, var)
class ComfoConnectBridge(object): """Representation of a ComfoConnect bridge.""" def __init__(self, hass, bridge, name, token, friendly_name, pin): """Initialize the ComfoConnect bridge.""" from pycomfoconnect import (ComfoConnect) self.data = {} self.name = name self.hass = hass 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") self.comfoconnect.connect(True) def disconnect(self): """Disconnect from the bridge.""" _LOGGER.debug("Disconnecting from bridge") self.comfoconnect.disconnect() def sensor_callback(self, var, value): """Call function for sensor updates.""" _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]: self.data[var] = value / 10 else: self.data[var] = value # Notify listeners that we have received an update dispatcher_send(self.hass, SIGNAL_COMFOCONNECT_UPDATE_RECEIVED, var) def subscribe_sensor(self, sensor_id): """Subscribe for the specified sensor.""" self.comfoconnect.register_sensor(sensor_id)
def main(args): """ Check if running in debug mode """ if args.debug: import debugpy print("running in debug mode - waiting for debugger connection on {0}:{1}".format(args.debugip, args.debugport)) debugpy.listen((args.debugip, args.debugport)) debugpy.wait_for_client() pluginconfig = configparser.ConfigParser() pluginconfig.read(args.configfile) pin = pluginconfig.get('ZehnderCtrl', 'zehnderPIN') zehnderIP = pluginconfig.get('ZehnderCtrl', 'zehnderIP') pluginEnabled = pluginconfig.get('ZehnderCtrl', 'enabled') global statusPort statusPort = int(pluginconfig.get('ZehnderCtrl', 'statusPort')) global miniserverIP miniserverIP = pluginconfig.get('ZehnderCtrl', 'miniserverIP') # Discover the bridge bridge = bridge_discovery(zehnderIP) ## Setup a Comfoconnect session ################################################################################### comfoconnect = ComfoConnect(bridge, local_uuid, local_name, pin) comfoconnect.callback_sensor = callback_sensor try: # Connect to the bridge # comfoconnect.connect(False) # Don't disconnect existing clients. comfoconnect.connect(True) # Disconnect existing clients. except Exception as e: print('ERROR: %s' % e) exit(1) ## Register sensors ################################################################################################ # comfoconnect.register_sensor(SENSOR_FAN_NEXT_CHANGE) # General: Countdown until next fan speed change comfoconnect.register_sensor(SENSOR_FAN_SPEED_MODE) # Fans: Fan speed setting (65) # comfoconnect.register_sensor(SENSOR_FAN_SUPPLY_DUTY) # Fans: Supply fan duty # comfoconnect.register_sensor(SENSOR_FAN_EXHAUST_DUTY) # Fans: Exhaust fan duty # comfoconnect.register_sensor(SENSOR_FAN_SUPPLY_FLOW) # Fans: Supply fan flow # comfoconnect.register_sensor(SENSOR_FAN_EXHAUST_FLOW) # Fans: Exhaust fan flow # comfoconnect.register_sensor(SENSOR_FAN_SUPPLY_SPEED) # Fans: Supply fan speed # comfoconnect.register_sensor(SENSOR_FAN_EXHAUST_SPEED) # Fans: Exhaust fan speed # comfoconnect.register_sensor(SENSOR_POWER_CURRENT) # Power Consumption: Current Ventilation # comfoconnect.register_sensor(SENSOR_POWER_TOTAL_YEAR) # Power Consumption: Total year-to-date # comfoconnect.register_sensor(SENSOR_POWER_TOTAL) # Power Consumption: Total from start # comfoconnect.register_sensor(SENSOR_DAYS_TO_REPLACE_FILTER) # Days left before filters must be replaced # comfoconnect.register_sensor(SENSOR_AVOIDED_HEATING_CURRENT) # Avoided Heating: Avoided actual # comfoconnect.register_sensor(SENSOR_AVOIDED_HEATING_TOTAL_YEAR) # Avoided Heating: Avoided year-to-date # comfoconnect.register_sensor(SENSOR_AVOIDED_HEATING_TOTAL) # Avoided Heating: Avoided total #comfoconnect.register_sensor(SENSOR_TEMPERATURE_SUPPLY) # Temperature & Humidity: Supply Air (temperature) #comfoconnect.register_sensor(SENSOR_TEMPERATURE_EXTRACT) # Temperature & Humidity: Extract Air (temperature) #comfoconnect.register_sensor(SENSOR_TEMPERATURE_EXHAUST) # Temperature & Humidity: Exhaust Air (temperature) #comfoconnect.register_sensor(SENSOR_TEMPERATURE_OUTDOOR) # Temperature & Humidity: Outdoor Air (temperature) #comfoconnect.register_sensor(SENSOR_HUMIDITY_SUPPLY) # Temperature & Humidity: Supply Air (temperature) #comfoconnect.register_sensor(SENSOR_HUMIDITY_EXTRACT) # Temperature & Humidity: Extract Air (temperature) #comfoconnect.register_sensor(SENSOR_HUMIDITY_EXHAUST) # Temperature & Humidity: Exhaust Air (temperature) #comfoconnect.register_sensor(SENSOR_HUMIDITY_OUTDOOR) # Temperature & Humidity: Outdoor Air (temperature) #comfoconnect.register_sensor(SENSOR_BYPASS_STATE) # Bypass state #comfoconnect.register_sensor(SENSOR_OPERATING_MODE) # Operating mode #comfoconnect.register_sensor(SENSOR_OPERATING_MODE_BIS) # Operating mode (bis) # comfoconnect.register_sensor(16) # 1 # comfoconnect.register_sensor(33) # 1 # comfoconnect.register_sensor(37) # 0 # comfoconnect.register_sensor(53) # -1 # comfoconnect.register_sensor(66) # 0 # comfoconnect.register_sensor(67) # 0 # comfoconnect.register_sensor(70) # 0 # comfoconnect.register_sensor(71) # 0 # comfoconnect.register_sensor(82) # ffffffff # comfoconnect.register_sensor(85) # ffffffff # comfoconnect.register_sensor(86) # ffffffff # comfoconnect.register_sensor(87) # ffffffff # comfoconnect.register_sensor(144) # 0 # comfoconnect.register_sensor(145) # 0 # comfoconnect.register_sensor(146) # 0 # comfoconnect.register_sensor(176) # 0 # comfoconnect.register_sensor(208) # 0 # comfoconnect.register_sensor(210) # 0 # comfoconnect.register_sensor(211) # 0 # comfoconnect.register_sensor(212) # 228 # comfoconnect.register_sensor(216) # 0 # comfoconnect.register_sensor(217) # 28 # comfoconnect.register_sensor(218) # 28 # comfoconnect.register_sensor(219) # 0 # comfoconnect.register_sensor(224) # 3 # comfoconnect.register_sensor(225) # 1 # comfoconnect.register_sensor(226) # 100 # comfoconnect.register_sensor(228) # 0 # comfoconnect.register_sensor(321) # 15 # comfoconnect.register_sensor(325) # 1 # comfoconnect.register_sensor(337) # # comfoconnect.register_sensor(338) # 00000000 # comfoconnect.register_sensor(341) # 00000000 # comfoconnect.register_sensor(369) # 0 # comfoconnect.register_sensor(370) # 0 # comfoconnect.register_sensor(371) # 0 # comfoconnect.register_sensor(372) # 0 # comfoconnect.register_sensor(384) # 0 # comfoconnect.register_sensor(386) # 0 # comfoconnect.register_sensor(400) # 0 # comfoconnect.register_sensor(401) # 0 # comfoconnect.register_sensor(402) # 0 # comfoconnect.register_sensor(416) # -400 # comfoconnect.register_sensor(417) # 100 # comfoconnect.register_sensor(418) # 0 # comfoconnect.register_sensor(419) # 0 ## Execute functions ############################################################################################### # ListRegisteredApps # for app in comfoconnect.cmd_list_registered_apps(): # print('%s: %s' % (app['uuid'].hex(), app['devicename'])) # DeregisterApp # comfoconnect.cmd_deregister_app(bytes.fromhex('00000000000000000000000000000001')) # VersionRequest version = comfoconnect.cmd_version_request() print(version) # TimeRequest # timeinfo = comfoconnect.cmd_time_request() # print(timeinfo) ## Executing functions ############################################################################################# # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY) # Go to away mode # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_LOW) # Set fan speed to 1 # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_MEDIUM) # Set fan speed to 2 # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_HIGH) # Set fan speed to 3 ## Closing the session ############################################################################################# print('Disconnecting...') comfoconnect.disconnect()
def main(args): print("starting main") seconds = 120 if args.duration: seconds = int(args.duration) """ Check if running in debug mode """ if args.debug: import debugpy print( "running in debug mode - waiting for debugger connection on {0}:{1}" .format(args.debugip, args.debugport)) debugpy.listen((args.debugip, args.debugport)) debugpy.wait_for_client() pluginconfig = configparser.ConfigParser() pluginconfig.read(args.configfile) print("reading config, has sections: " + ", ".join(pluginconfig.sections())) if pluginconfig.has_section("ZehnderCtrl"): pin = pluginconfig.get('ZehnderCtrl', 'zehnderPIN') zehnderIP = pluginconfig.get('ZehnderCtrl', 'zehnderIP') pluginEnabled = pluginconfig.get('ZehnderCtrl', 'enabled') # Discover the bridge bridge = bridge_discovery(zehnderIP) ## Setup a Comfoconnect session ################################################################################### comfoconnect = ComfoConnect(bridge, local_uuid, local_name, pin) comfoconnect.callback_sensor = callback_sensor print("Connecting to zehnder bridge") try: # Connect to the bridge # comfoconnect.connect(False) # Don't disconnect existing clients. comfoconnect.connect(True) # Disconnect existing clients. except Exception as e: print('ERROR: %s' % e) exit(1) ## Executing functions ############################################################################################# seconds = 280 s = str("{:012x}".format(seconds)) #duration_bytes = r"\x" + r"\x".join(s[n : n+2] for n in range(0, len(s), 2)) duration_bytes = r"\x" + r"\x".join(s[n:n + 2] for n in range(0, len(s), 2)) bytestring = '\x84\x15\x01\x06' + duration_bytes + '\x00\x00\x03' print("Bytestring to send to zehnder: " + bytestring) s_new: bytes = (b'\x84\x15\x01\x06' + bytes(duration_bytes, encoding="raw_unicode_escape") + b'\x00\x00\x03') # 8415 0106 0000 0000 5802 0000 03 Boost mode: start for 10m (= 600 seconds = 0x0258) comfoconnect.cmd_rmi_request(s_new) # comfoconnect.cmd_rmi_request(b'\x84\x15\x01\x06' + duration_bytes + b'\x00\x00\x03') # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_AWAY) # Go to away mode # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_LOW) # Set fan speed to 1 # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_MEDIUM) # Set fan speed to 2 # comfoconnect.cmd_rmi_request(CMD_FAN_MODE_HIGH) # Set fan speed to 3 ## Closing the session ############################################################################################# print('Disconnecting...') comfoconnect.disconnect()