### CLI Usage Examples Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Examples demonstrating how to use the aiocomfoconnect library from the command line interface. ```APIDOC ## CLI Usage Examples ### Discover Bridges ```shell python -m aiocomfoconnect discover ``` ### Register Device ```shell python -m aiocomfoconnect register --host 192.168.1.213 ``` ### Set Speed ```shell python -m aiocomfoconnect set-speed away --host 192.168.1.213 python -m aiocomfoconnect set-speed low --host 192.168.1.213 python -m aiocomfoconnect set-speed medium --host 192.168.1.213 python -m aiocomfoconnect set-speed high --host 192.168.1.213 ``` ### Set Mode ```shell python -m aiocomfoconnect set-mode auto --host 192.168.1.213 ``` ### Set Boost ```shell python -m aiocomfoconnect set-boost on --host 192.168.1.213 --timeout 1200 ``` ### Set Comfocool ```shell python -m aiocomfoconnect set-comfocool auto --host 192.168.1.213 python -m aiocomfoconnect set-comfocool off --host 192.168.1.213 ``` ### Show Sensors ```shell python -m aiocomfoconnect show-sensors --host 192.168.1.213 python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 -f ``` ### Get Property ```shell python -m aiocomfoconnect get-property --host 192.168.1.213 1 1 8 9 ``` ``` -------------------------------- ### Install aiocomfoconnect Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Install the library using pip. ```shell pip3 install aiocomfoconnect ``` -------------------------------- ### Python Example: Discovery Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md An example demonstrating how to discover ComfoConnect LAN C Bridges on the subnet using the aiocomfoconnect library. ```APIDOC ## Python Example: Discovery ### Discovery of ComfoConnect LAN C Bridges ```python import asyncio from aiocomfoconnect import discover_bridges async def main(): """ ComfoConnect LAN C Bridge discovery example.""" # Discover all ComfoConnect LAN C Bridges on the subnet. bridges = await discover_bridges() print(bridges) if __name__ == "__main__": asyncio.run(main()) ``` ``` -------------------------------- ### Generate Protobuf Files Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Installs the required gRPC tools and compiles the protobuf definitions. ```shell python3 -m pip install grpcio-tools==1.73.0 python3 -m grpc_tools.protoc -Iprotobuf --python_out=aiocomfoconnect/protobuf protobuf/*.proto ``` -------------------------------- ### RMI Command CAN ID Examples Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Examples illustrating different RMI command CAN IDs, showing multi-message requests, single-message requests, and responses with and without errors. ```plaintext 1F015057: 11111 0000 0001 0101 00 0001 010111 multi-msg request with SeqNr = 0 1F011074: 11111 0000 0001 0001 00 0001 110100 single-msg request with SeqNr = 0 1F071074: 11111 0000 0111 0001 00 0001 110100 single-msg request with SeqNr = 3 1F005D01: 11111 0000 0000 0101 11 0100 000001 no-error multi-msg response, seqnr = 0 1F001D01: 11111 0000 0000 0001 11 0100 000001 no-error single-msg response, seqnr = 0 1F009D01: 11111 0000 0000 1001 11 0100 000001 error, seqnr = 0 ``` -------------------------------- ### CnRmiRequest Example Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Example of a CnRmiRequest to execute a function on a device. Requires nodeId and a message payload. ```javascript type: CnRmiRequestType reference: 122 nodeId: 1 message: "\001\001\001\020\010" ``` -------------------------------- ### CnRmiResponse Example Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Example of a CnRmiResponse from the bridge. Includes reference and message content. ```javascript type: CnRmiResponseType reference: 122 message: "ComfoAir Q450 B R RF ST Quality\000" ``` -------------------------------- ### Boost Mode Commands Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Commands to start and end the boost ventilation mode. ```hex 84 15 01 06 00000000 58020000 03 ``` ```hex 85 15 01 06 ``` -------------------------------- ### Configure Airflow Settings Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Get and set target airflow rates in m³/h for each ventilation speed level. Supports custom values for specific speeds and accepts string literals for speed. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.const import VentilationSpeed async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Get current airflow settings for each speed for speed in [VentilationSpeed.AWAY, VentilationSpeed.LOW, VentilationSpeed.MEDIUM, VentilationSpeed.HIGH]: flow = await comfoconnect.get_flow_for_speed(speed) print(f"{speed}: {flow} m³/h") # Set custom airflow for medium speed (e.g., 200 m³/h) await comfoconnect.set_flow_for_speed(VentilationSpeed.MEDIUM, 200) print(f"\nMedium speed now: {await comfoconnect.get_flow_for_speed('medium')} m³/h") await comfoconnect.disconnect() # Output: # away: 50 m³/h # low: 100 m³/h # medium: 150 m³/h # high: 300 m³/h # # Medium speed now: 200 m³/h asyncio.run(main()) ``` -------------------------------- ### Set Temperature Profile Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Get and set the target temperature profile for comfort control. Supports WARM, NORMAL, and COOL profiles, and accepts string literals. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.const import VentilationTemperatureProfile async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Get current temperature profile profile = await comfoconnect.get_temperature_profile() print(f"Temperature profile: {profile}") # Set different temperature profiles await comfoconnect.set_temperature_profile(VentilationTemperatureProfile.WARM) # Higher supply temp await comfoconnect.set_temperature_profile(VentilationTemperatureProfile.NORMAL) # Balanced await comfoconnect.set_temperature_profile(VentilationTemperatureProfile.COOL) # Lower supply temp # Using string literals await comfoconnect.set_temperature_profile("normal") await comfoconnect.disconnect() # Output: # Temperature profile: normal asyncio.run(main()) ``` -------------------------------- ### Get Multiple Properties Command Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Reads multiple properties in a single request. The Type value must be OR'ed with the count of properties being requested. ```text 02 01 01 01 15 03 04 06 05 14 ``` -------------------------------- ### 0x02 Get Multiple Properties Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Reads multiple properties in a single request. ```APIDOC ## 0x02 Get Multiple Properties ### Description Allows reading multiple properties in one request by OR'ing the Type with the number of properties. ### Method 0x02 ### Parameters - **Unit** (hex) - Required - **SubUnit** (hex) - Required - **Type** (hex) - Required - Type OR'd with the number of properties (e.g., 0x10 | 0x05 = 0x15). - **Properties** (hex list) - Required - List of property IDs to retrieve. ### Request Example 02 01 01 01 15 03 04 06 05 14 ``` -------------------------------- ### Get Property - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Retrieve a specific property value using its unit, sub-unit, property ID, and type. Refer to PROTOCOL-RMI.md for details. ```shell python -m aiocomfoconnect get-property --host 192.168.1.213 1 1 8 9 # Unit 0x01, SubUnit 0x01, Property 0x08, Type STRING. See PROTOCOL-RMI.md ``` -------------------------------- ### Low-Level RMI and RPDO Requests with aiocomfoconnect Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Enables sending raw RMI commands and RPDO sensor requests for advanced use cases and debugging. Includes examples for requesting bridge version and time, sending keepalives, and registering for PDO sensor updates. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.const import PdoType async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Send raw RMI request # Format: [command, unit, subunit, ...] # Get property: 0x01, Set property: 0x03 # Example: Get model name (Unit 0x01, SubUnit 0x01, Property 0x08) result = await comfoconnect.cmd_rmi_request( message=bytes([0x01, 0x01, 0x01, 0x10, 0x08]), node_id=1 ) model = result.message.decode("utf-8").rstrip("\x00") print(f"Model: {model}") # Request bridge version information version_info = await comfoconnect.cmd_version_request() print(f"Gateway version: {version_info.gatewayVersion}") print(f"Serial: {version_info.serialNumber}") # Request bridge time (seconds since 2000-01-01) time_info = await comfoconnect.cmd_time_request() print(f"Bridge time: {time_info.currentTime}") # Send keepalive to maintain connection await comfoconnect.cmd_keepalive() # Register for PDO sensor updates directly # pdid=276 is outdoor temperature, type=6 is CN_INT16 await comfoconnect.cmd_rpdo_request( pdid=276, pdo_type=PdoType.TYPE_CN_INT16, zone=1, timeout=None # Infinite ) await comfoconnect.disconnect() # Output: # Model: ComfoAir Q450 B R RF ST Quality # Gateway version: 2.0.0.48 # Serial: CC_LAN_00251010800170b3d54264b4 # Bridge time: 789012345 asyncio.run(main()) ``` -------------------------------- ### Get Single Property Command Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Reads a single property from a unit. The Type field determines whether to retrieve the actual value, range, or step size. ```text 01 20 01 10 03 ``` -------------------------------- ### Maintain Long-Running Connection with Keepalive Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt For long-running applications, send periodic keepalive messages to maintain the connection. This example uses a time request as a keepalive, which provides a response for verification. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.sensors import SENSORS from aiocomfoconnect.exceptions import AioComfoConnectNotConnected, AioComfoConnectTimeout async def main(): bridges = await discover_bridges(host="192.168.1.213") def sensor_callback(sensor, value): print(f"{sensor.name}: {value} {sensor.unit or ''}") def alarm_callback(node_id, errors): for error_id, error_msg in errors.items(): print(f"ALARM [{error_id}]: {error_msg}") comfoconnect = ComfoConnect( bridges[0].host, bridges[0].uuid, sensor_callback=sensor_callback, alarm_callback=alarm_callback ) await comfoconnect.connect(DEFAULT_UUID) # Register all sensors for sensor in SENSORS.values(): await comfoconnect.register_sensor(sensor) try: while True: # Send keepalive every 30 seconds await asyncio.sleep(30) try: # Use time request as keepalive (has a response we can verify) await comfoconnect.cmd_time_request() print("Keepalive sent successfully") except AioComfoConnectTimeout: print("Keepalive timeout - connection may be lost") except AioComfoConnectNotConnected: print("Connection lost - reconnecting...") # The library handles automatic reconnection except KeyboardInterrupt: print("\nShutting down...") finally: await comfoconnect.disconnect() print("Disconnected") asyncio.run(main()) ``` -------------------------------- ### Control Ventilation Speed Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Set and get the ventilation fan speed using predefined constants or string literals. Valid speeds include AWAY, LOW, MEDIUM, and HIGH. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.const import VentilationSpeed async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Get current speed current_speed = await comfoconnect.get_speed() print(f"Current speed: {current_speed}") # Set speed to different levels await comfoconnect.set_speed(VentilationSpeed.AWAY) # Minimal ventilation await comfoconnect.set_speed(VentilationSpeed.LOW) # Low speed await comfoconnect.set_speed(VentilationSpeed.MEDIUM) # Medium speed await comfoconnect.set_speed(VentilationSpeed.HIGH) # Maximum speed # Using string literals also works await comfoconnect.set_speed("medium") print(f"Speed set to: {await comfoconnect.get_speed()}") await comfoconnect.disconnect() asyncio.run(main()) ``` -------------------------------- ### Unfragmented RMI Message Encoding Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Example of encoding an RMI message that is 8 bytes or less into a single CAN frame. Demonstrates a request to get a value and its corresponding response. ```plaintext can1 1F011074 [5] 01 1D 01 10 0A can1 1F001D01 [2] E6 00 ``` -------------------------------- ### Show Help - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Display help information for the aiocomfoconnect command-line interface. ```shell python -m aiocomfoconnect --help ``` -------------------------------- ### Connect to ComfoConnect Bridge and Register Sensors Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Demonstrates initializing the ComfoConnect client, registering sensors with a callback, and setting the ventilation speed. ```python import asyncio from aiocomfoconnect import ComfoConnect from aiocomfoconnect.const import VentilationSpeed from aiocomfoconnect.sensors import SENSORS async def main(local_uuid, host, uuid): """ Basic example.""" def sensor_callback(sensor, value): """ Print sensor updates. """ print(f"{sensor.name} = {value}") # Connect to the Bridge comfoconnect = ComfoConnect(host, uuid, sensor_callback=sensor_callback) await comfoconnect.connect(local_uuid) # Register all sensors for key in SENSORS: await comfoconnect.register_sensor(SENSORS[key]) # Set speed to LOW await comfoconnect.set_speed(VentilationSpeed.LOW) # Wait 2 minutes so we can see some sensor updates await asyncio.sleep(120) # Disconnect from the bridge await comfoconnect.disconnect() if __name__ == "__main__": asyncio.run(main(local_uuid='00000000000000000000000000001337', host='192.168.1.20', uuid='00000000000000000000000000000055')) # Replace with your bridge's IP and UUID ``` -------------------------------- ### StartSession Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Initiates a session with the bridge. Only one client can be logged in at a time. ```APIDOC ## POST StartSession ### Description Logs the client in by sending a StartSessionRequestType. Supports session takeover if another client is already connected. ### Request Body - **type** (string) - Required - 'StartSessionRequestType' - **reference** (integer) - Required - Request reference ID - **takeover** (integer) - Optional - Set to 1 to force session takeover ### Response #### Success Response (200) - **type** (string) - 'StartSessionConfirmType' - **result** (string) - 'OK' #### Error Response - **result** (string) - 'OTHER_SESSION' if another client is logged in - **devicename** (string) - Name of the currently connected device ``` -------------------------------- ### Initialize ComfoConnect Instance Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Create a ComfoConnect instance to manage ventilation control, providing callbacks for sensor and alarm updates. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges async def main(): # First discover the bridge to get its UUID bridges = await discover_bridges(host="192.168.1.213") bridge = bridges[0] # Define callbacks for sensor and alarm updates def sensor_callback(sensor, value): print(f"Sensor update: {sensor.name} = {value} {sensor.unit or ''}") def alarm_callback(node_id, errors): print(f"Alarm on node {node_id}:") for error_id, error_msg in errors.items(): print(f" Error {error_id}: {error_msg}") # Create ComfoConnect instance with callbacks comfoconnect = ComfoConnect( host=bridge.host, uuid=bridge.uuid, sensor_callback=sensor_callback, alarm_callback=alarm_callback, sensor_delay=2, # Buffer sensor values for 2 seconds on connect connect_timeout=30 # Connection timeout in seconds ) # Connect using your app's UUID (must be registered first) local_uuid = "00000000000000000000000000001337" await comfoconnect.connect(local_uuid) print(f"Connected to {comfoconnect.host}") await comfoconnect.disconnect() asyncio.run(main()) ``` -------------------------------- ### Handle Connection and Protocol Exceptions in Python Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Demonstrates how to catch specific library exceptions during bridge discovery, connection, and command execution. Ensure proper cleanup by calling disconnect after operations. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.exceptions import ( AioComfoConnectNotConnected, AioComfoConnectTimeout, ComfoConnectNotAllowed, ComfoConnectOtherSession, ComfoConnectBadRequest, ComfoConnectNotReachable, BridgeNotFoundException, ) async def main(): try: bridges = await discover_bridges(host="192.168.1.213", timeout=5) if not bridges: raise BridgeNotFoundException("No bridge found at specified address") comfoconnect = ComfoConnect( bridges[0].host, bridges[0].uuid, connect_timeout=30 ) try: await comfoconnect.connect(DEFAULT_UUID) except ComfoConnectNotAllowed: print("Not registered - please register first") return except ComfoConnectOtherSession: print("Another session is active - use takeover") return except AioComfoConnectTimeout: print("Connection timed out") return try: await comfoconnect.set_speed("invalid") except ValueError as e: print(f"Invalid parameter: {e}") try: await comfoconnect.cmd_rmi_request(bytes([0xFF, 0xFF])) except ComfoConnectBadRequest: print("Invalid RMI request") except ComfoConnectNotReachable: print("Node not reachable") await comfoconnect.disconnect() except BridgeNotFoundException: print("Bridge not found on network") except AioComfoConnectNotConnected: print("Lost connection to bridge") except Exception as e: print(f"Unexpected error: {e}") asyncio.run(main()) ``` -------------------------------- ### Set Boost - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Enable boost mode for a specified duration (in seconds) using the CLI. ```shell python -m aiocomfoconnect set-boost on --host 192.168.1.213 --timeout 1200 ``` -------------------------------- ### 0x01 Get Single Property Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Reads a single property identified by Unit, SubUnit, and Property ID. ```APIDOC ## 0x01 Get Single Property ### Description Reads a single property from the unit. Supports retrieving actual values, ranges, and step sizes. ### Method 0x01 ### Parameters - **Unit** (hex) - Required - The unit identifier. - **SubUnit** (hex) - Required - The subunit identifier. - **Type** (hex) - Required - 0x00 (None), 0x10 (Actual value), 0x20 (Range), 0x40 (Step size). - **Property** (hex) - Required - The property identifier. ### Request Example 01 20 01 10 03 ### Response - **Data** (hex) - The requested property value. ``` -------------------------------- ### Register Device - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Register a device with the specified host IP address using the CLI. ```shell python -m aiocomfoconnect register --host 192.168.1.213 ``` -------------------------------- ### Discover Bridges - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Discover ComfoConnect LAN C Bridges on the local network using the CLI. ```shell python -m aiocomfoconnect discover ``` -------------------------------- ### StartSession Request and Confirm Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Log in to the bridge. Only one client can be active at a time, though sessions can be taken over. ```text type: StartSessionRequestType reference: 16 ``` ```text type: StartSessionConfirmType result: OK reference: 16 ``` ```text type: StartSessionConfirmType result: OTHER_SESSION reference: 16 devicename: "Google Nexus 5X" ``` ```text type: StartSessionConfirmType result: OK reference: 17 takeover: 1 ``` -------------------------------- ### Show Sensors - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Display all sensor information or specific sensor details using the CLI. The -f flag can be used for formatted output. ```shell python -m aiocomfoconnect show-sensors --host 192.168.1.213 ``` ```shell python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 ``` ```shell python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 -f ``` -------------------------------- ### Fragmented RMI Message Encoding Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Example of encoding an RMI message longer than 8 bytes, fragmented into 7-byte blocks. Shows a request and its multi-frame response. ```plaintext can1 1F011074 [3] 80 03 01 # I send can1 1F005D01 [8] 00 00 00 00 00 00 00 00 # Answer can1 1F005D01 [8] 01 00 00 00 00 00 00 00 can1 1F005D01 [8] 02 00 00 00 00 00 00 00 can1 1F005D01 [8] 03 00 00 00 00 00 00 00 can1 1F005D01 [5] 84 00 00 00 00 ``` -------------------------------- ### Manage Fan Balance Mode in Python Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Use set_balance_mode with VentilationBalance constants to adjust supply and exhaust ratios for pressure control. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.const import VentilationBalance async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Get current balance mode balance = await comfoconnect.get_balance_mode() print(f"Balance mode: {balance}") # Normal balanced operation (both fans equal) await comfoconnect.set_balance_mode(VentilationBalance.BALANCE) # Supply only (positive pressure) for 1 hour await comfoconnect.set_balance_mode(VentilationBalance.SUPPLY_ONLY, timeout=3600) print("Supply only mode for 1 hour") # Exhaust only (negative pressure) for 30 minutes await comfoconnect.set_balance_mode(VentilationBalance.EXHAUST_ONLY, timeout=1800) # Return to balanced operation await comfoconnect.set_balance_mode("balance") await comfoconnect.disconnect() # Output: # Balance mode: balance # Supply only mode for 1 hour asyncio.run(main()) ``` -------------------------------- ### RegisterApp Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Registers a new device with the bridge before login. ```APIDOC ## POST RegisterApp ### Description Registers a device by sending a RegisterAppRequestType. The bridge responds with a RegisterAppConfirmType. ### Request Body - **type** (string) - Required - Must be 'RegisterAppRequestType' - **reference** (integer) - Required - Request reference ID - **uuid** (string) - Required - Device UUID - **pin** (integer) - Required - PIN code - **devicename** (string) - Required - Name of the device ### Response #### Success Response (200) - **type** (string) - 'RegisterAppConfirmType' - **reference** (integer) - Matching reference ID #### Error Response - **result** (string) - 'NOT_ALLOWED' if PIN is invalid ``` -------------------------------- ### Temperature Profile Commands Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL-RMI.md Commands to set the temperature profile to normal, cool, or warm. ```hex 84 15 03 01 00000000 ffffffff 00 ``` ```hex 84 15 03 01 00000000 ffffffff 01 ``` ```hex 84 15 03 01 00000000 ffffffff 02 ``` -------------------------------- ### RegisterApp Request and Confirm Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/docs/PROTOCOL.md Register a device before logging in. The bridge responds with a confirmation indicating success or failure. ```text type: RegisterAppRequestType reference: 15 uuid: "\251\226\031\002 \004Mh\240}\205\242\343\206o\312" pin: 0 devicename: "Computer" ``` ```text type: RegisterAppConfirmType reference: 15 ``` ```text type: RegisterAppConfirmType result: NOT_ALLOWED reference: 15 ``` -------------------------------- ### Enable Away Mode in Python Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Use set_away to reduce ventilation to minimum levels. The timeout is specified in seconds. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Check if away mode is active is_away = await comfoconnect.get_away() print(f"Away mode: {is_away}") # Enable away mode for 8 hours await comfoconnect.set_away(mode=True, timeout=8 * 3600) print("Away mode enabled for 8 hours") # Disable away mode await comfoconnect.set_away(False) print(f"Away mode: {await comfoconnect.get_away()}") await comfoconnect.disconnect() # Output: # Away mode: False # Away mode enabled for 8 hours # Away mode: False asyncio.run(main()) ``` -------------------------------- ### Register and Monitor Sensors with Callbacks Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Register specific sensors or all available sensors to receive real-time updates via a callback function. The callback receives sensor name and value. Ensure necessary sensor constants are imported. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID from aiocomfoconnect.sensors import ( SENSORS, SENSOR_TEMPERATURE_OUTDOOR, SENSOR_TEMPERATURE_SUPPLY, SENSOR_TEMPERATURE_EXTRACT, SENSOR_HUMIDITY_EXTRACT, SENSOR_FAN_SUPPLY_FLOW, SENSOR_FAN_EXHAUST_FLOW, SENSOR_POWER_USAGE, SENSOR_BYPASS_STATE, ) async def main(): bridges = await discover_bridges(host="192.168.1.213") # Store sensor values sensor_data = {} def sensor_callback(sensor, value): sensor_data[sensor.name] = value print(f"{sensor.name}: {value} {sensor.unit or ''}") comfoconnect = ComfoConnect( bridges[0].host, bridges[0].uuid, sensor_callback=sensor_callback ) await comfoconnect.connect(DEFAULT_UUID) # Register specific sensors important_sensors = [ SENSOR_TEMPERATURE_OUTDOOR, # 276 - Outdoor temperature SENSOR_TEMPERATURE_SUPPLY, # 221 - Supply air temperature SENSOR_TEMPERATURE_EXTRACT, # 274 - Extract air temperature SENSOR_HUMIDITY_EXTRACT, # 290 - Extract humidity SENSOR_FAN_SUPPLY_FLOW, # 120 - Supply fan flow (m³/h) SENSOR_FAN_EXHAUST_FLOW, # 119 - Exhaust fan flow (m³/h) SENSOR_POWER_USAGE, # 128 - Current power (W) SENSOR_BYPASS_STATE, # 227 - Bypass position (%) ] for sensor_id in important_sensors: await comfoconnect.register_sensor(SENSORS[sensor_id]) # Or register ALL available sensors # for sensor in SENSORS.values(): # await comfoconnect.register_sensor(sensor) # Wait for sensor updates await asyncio.sleep(10) # Deregister a sensor when no longer needed await comfoconnect.deregister_sensor(SENSORS[SENSOR_POWER_USAGE]) await comfoconnect.disconnect() # Output: # Outdoor Air Temperature: 8.5 °C # Supply Air Temperature: 19.2 °C # Extract Air Temperature: 21.3 °C # Extract Air Humidity: 45 % # Supply Fan Flow: 150 m³/h # Exhaust Fan Flow: 148 m³/h # Power Usage: 18 W # Bypass State: 0 % asyncio.run(main()) ``` -------------------------------- ### Activate Boost Mode in Python Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Use set_boost to toggle high-speed ventilation. The timeout parameter accepts duration in seconds. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID async def main(): bridges = await discover_bridges(host="192.168.1.213") comfoconnect = ComfoConnect(bridges[0].host, bridges[0].uuid) await comfoconnect.connect(DEFAULT_UUID) # Check if boost is currently active is_boost_active = await comfoconnect.get_boost() print(f"Boost active: {is_boost_active}") # Activate boost for 20 minutes (1200 seconds) await comfoconnect.set_boost(mode=True, timeout=1200) print("Boost activated for 20 minutes") # Activate boost for 1 hour (default timeout is 3600 seconds) await comfoconnect.set_boost(True) # Deactivate boost early await comfoconnect.set_boost(False) print(f"Boost active: {await comfoconnect.get_boost()}") await comfoconnect.disconnect() # Output: # Boost active: False # Boost activated for 20 minutes # Boost active: False asyncio.run(main()) ``` -------------------------------- ### Discover ComfoConnect Bridges - Python Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Asynchronously discover all ComfoConnect LAN C Bridges on the local subnet using the `discover_bridges` function. ```python import asyncio from aiocomfoconnect import discover_bridges async def main(): """ ComfoConnect LAN C Bridge discovery example.""" # Discover all ComfoConnect LAN C Bridges on the subnet. bridges = await discover_bridges() print(bridges) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Execute CLI Commands for Bridge Management Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Provides common command-line operations for interacting with the ventilation bridge, including discovery, registration, and sensor monitoring. ```bash # Discover bridges on the network python -m aiocomfoconnect discover python -m aiocomfoconnect discover --host 192.168.1.213 # Register with a bridge (required before other operations) python -m aiocomfoconnect register --host 192.168.1.213 python -m aiocomfoconnect register --host 192.168.1.213 --pin 1234 --name "My App" # Deregister an application python -m aiocomfoconnect deregister --host 192.168.1.213 # Set ventilation speed python -m aiocomfoconnect set-speed away --host 192.168.1.213 python -m aiocomfoconnect set-speed low --host 192.168.1.213 python -m aiocomfoconnect set-speed medium --host 192.168.1.213 python -m aiocomfoconnect set-speed high --host 192.168.1.213 # Set ventilation mode python -m aiocomfoconnect set-mode auto --host 192.168.1.213 python -m aiocomfoconnect set-mode manual --host 192.168.1.213 # Control boost mode python -m aiocomfoconnect set-boost on --host 192.168.1.213 --timeout 1200 python -m aiocomfoconnect set-boost off --host 192.168.1.213 # Control ComfoCool python -m aiocomfoconnect set-comfocool auto --host 192.168.1.213 python -m aiocomfoconnect set-comfocool off --host 192.168.1.213 # Show all sensor values (continuous monitoring) python -m aiocomfoconnect show-sensors --host 192.168.1.213 # Show a specific sensor value python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 python -m aiocomfoconnect show-sensor 276 --host 192.168.1.213 -f # Follow updates # Get/set airflow for speed levels python -m aiocomfoconnect get-flow-for-speed medium --host 192.168.1.213 python -m aiocomfoconnect set-flow-for-speed medium 200 --host 192.168.1.213 # Get a raw property value python -m aiocomfoconnect get-property 1 1 8 9 --host 192.168.1.213 # Enable debug logging python -m aiocomfoconnect --debug show-sensors --host 192.168.1.213 ``` -------------------------------- ### Register Application with ComfoConnect Bridge Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Register your application with the ComfoConnect LAN C bridge using its PIN code. This is required before connecting. Registration only needs to be done once per UUID. ```python import asyncio from aiocomfoconnect import ComfoConnect, discover_bridges, DEFAULT_UUID, DEFAULT_NAME, DEFAULT_PIN from aiocomfoconnect.exceptions import ComfoConnectNotAllowed async def main(): bridges = await discover_bridges(host="192.168.1.213") bridge = bridges[0] comfoconnect = ComfoConnect(bridge.host, bridge.uuid) # Try to connect - if not registered, register first try: await comfoconnect.connect(DEFAULT_UUID) print("Already registered and connected!") except ComfoConnectNotAllowed: # Not registered yet, need to register print("Not registered. Registering now...") try: await comfoconnect.cmd_register_app( uuid=DEFAULT_UUID, # Your unique app identifier device_name=DEFAULT_NAME, # "aiocomfoconnect" pin=DEFAULT_PIN # Bridge PIN (default: 0) ) print("Registration successful!") # Now connect and start session await comfoconnect.cmd_start_session(take_over=True) except ComfoConnectNotAllowed: print("Registration failed - check PIN code") return # List all registered applications reply = await comfoconnect.cmd_list_registered_apps() print("\nRegistered applications:") for app in reply.apps: print(f" UUID: {app.uuid.hex()}, Name: {app.devicename}") await comfoconnect.disconnect() asyncio.run(main()) ``` -------------------------------- ### Set Speed - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Set the ventilation speed to 'away', 'low', 'medium', or 'high' using the CLI. ```shell python -m aiocomfoconnect set-speed away --host 192.168.1.213 ``` ```shell python -m aiocomfoconnect set-speed low --host 192.168.1.213 ``` ```shell python -m aiocomfoconnect set-speed medium --host 192.168.1.213 ``` ```shell python -m aiocomfoconnect set-speed high --host 192.168.1.213 ``` -------------------------------- ### Low-Level API Methods Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md This section details the low-level methods for direct communication with the ventilation system's bridge. ```APIDOC ## Low-Level API Methods ### `cmd_start_session()` - **Description**: Start a session. - **Method**: async ### `cmd_close_session()` - **Description**: Close a session. - **Method**: async ### `cmd_list_registered_apps()` - **Description**: List registered apps. - **Method**: async ### `cmd_register_app(uuid, device_name, pin)` - **Description**: Register an app. - **Method**: async - **Parameters**: - **uuid** (string) - Required - The UUID of the app. - **device_name** (string) - Required - The name of the device. - **pin** (string) - Required - The registration PIN. ### `cmd_deregister_app(uuid)` - **Description**: Deregister an app. - **Method**: async - **Parameters**: - **uuid** (string) - Required - The UUID of the app to deregister. ### `cmd_version_request()` - **Description**: Request the bridge's version. - **Method**: async ### `cmd_time_request()` - **Description**: Request the bridge's time. - **Method**: async ### `cmd_rmi_request(message, node_id)` - **Description**: Send a RMI request. - **Method**: async - **Parameters**: - **message** (object) - Required - The RMI message payload. - **node_id** (string) - Required - The target node ID. ### `cmd_rpdo_request(pdid, type, zone, timeout)` - **Description**: Send a RPDO request. - **Method**: async - **Parameters**: - **pdid** (string) - Required - The PDID of the request. - **type** (string) - Required - The type of the request. - **zone** (string) - Required - The zone for the request. - **timeout** (integer) - Required - The timeout for the request. ### `cmd_keepalive()` - **Description**: Send a keepalive message. - **Method**: async ``` -------------------------------- ### Discover ComfoConnect Bridges Source: https://context7.com/michaelarnauts/aiocomfoconnect/llms.txt Use discover_bridges to locate bridges on the network via UDP broadcast or by specifying a host IP. ```python import asyncio from aiocomfoconnect import discover_bridges async def main(): # Discover all bridges on the network (broadcast) bridges = await discover_bridges() for bridge in bridges: print(f"Found bridge: {bridge.host}, UUID: {bridge.uuid}") # Discover a specific bridge by IP address bridges = await discover_bridges(host="192.168.1.213", timeout=5) if bridges: print(f"Bridge found at {bridges[0].host}") # Output: # Found bridge: 192.168.1.213, UUID: 0000000000251010800170b3d54264b4 asyncio.run(main()) ``` -------------------------------- ### Set Mode - CLI Source: https://github.com/michaelarnauts/aiocomfoconnect/blob/master/README.md Set the ventilation mode to 'auto' using the CLI. ```shell python -m aiocomfoconnect set-mode auto --host 192.168.1.213 ```