post_device_control
Send control commands to a specific device on the ThinQ Connect platform to modify its settings or state.
Instructions
Send control commands to a specific device on the ThinQ Connect platform to change its settings or state Args: device_type: Device type (e.g., DEVICE_AIR_CONDITIONER, DEVICE_ROBOT_CLEANER, DEVICE_STYLER) device_id: Unique ID of the device to control control_method: Co ntrol method name to execute (e.g., set_air_con_operation_mode, set_target_temperature, set_wind_strength) control_params: Parameter dictionary to pass to the control method (e.g., {'operation': 'POWER_OFF'}, {'temperature': 25}, {'wind_strength': 'HIGH'})
Returns:
String containing device control result messageInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_type | Yes | ||
| device_id | Yes | ||
| control_method | Yes | ||
| control_params | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- thinqconnect_mcp/server.py:104-128 (registration)The tool is registered with the MCP server via the @mcp.tool decorator. Defines parameters (device_type, device_id, control_method, control_params) and delegates to the handler in tools.py.
@mcp.tool( description="""Send control commands to a specific device on the ThinQ Connect platform to change its settings or state Args: device_type: Device type (e.g., DEVICE_AIR_CONDITIONER, DEVICE_ROBOT_CLEANER, DEVICE_STYLER) device_id: Unique ID of the device to control control_method: Co ntrol method name to execute (e.g., set_air_con_operation_mode, set_target_temperature, set_wind_strength) control_params: Parameter dictionary to pass to the control method (e.g., {'operation': 'POWER_OFF'}, {'temperature': 25}, {'wind_strength': 'HIGH'}) Returns: String containing device control result message """ ) async def post_device_control( device_type: str, device_id: str, control_method: str, control_params: dict, ) -> str: return await tools.post_device_control( thinq_api=thinq_api, device_type=device_type, device_id=device_id, control_method=control_method, control_params=control_params, ) - thinqconnect_mcp/tools.py:255-315 (handler)The handler function that executes the device control logic. It resolves the device profile (with caching), looks up the device class, creates a device instance, inspects the method signature, converts parameter types, and calls the method with kwargs.
async def post_device_control( thinq_api: ThinQApi, device_type: str, device_id: str, control_method: str, control_params: dict, ) -> str: """ Device Control """ try: global local_device_profiles thinq_api._session = ClientSession() if not local_device_profiles.get(device_id): device_profile = await thinq_api.async_get_device_profile(device_id=device_id) local_device_profiles[device_id] = device_profile else: device_profile = local_device_profiles[device_id] device_class = device_class_mapping.get(device_type) if not device_class: raise ValueError(f"Unsupported device type: {device_type}") # Create device object device = device_class( thinq_api=thinq_api, device_id=device_id, device_type=device_type, model_name="model_name", alias="alias", reportable=True, profile=device_profile, ) # Call device control method if hasattr(device, control_method): method = getattr(device, control_method) sig = inspect.signature(method) # Get method signature (parameter information) # Prepare arguments for each method parameter kwargs = {} for param_name, param in sig.parameters.items(): if param_name in control_params: param_type = param.annotation value = control_params[param_name] # Convert based on parameter type if param_type == int or param_type == "int": kwargs[param_name] = int(value) elif param_type == str or param_type == "str": kwargs[param_name] = str(value) else: kwargs[param_name] = value await method(**kwargs) else: return f"Command '{control_method}' not found." return f"Device control completed. Please relay appropriately to the user. Command: {control_method}, Parameters: {control_params}" except Exception as e: return f"An error occurred during device control: {str(e)}, Command: {control_method}, Parameters: {control_params}" - thinqconnect_mcp/tools.py:50-81 (helper)The helper mapping used by the handler to resolve device_type strings to concrete device classes from the thinqconnect library.
device_class_mapping = { "DEVICE_AIR_CONDITIONER": AirConditionerDevice, "DEVICE_AIR_PURIFIER": AirPurifierDevice, "DEVICE_AIR_PURIFIER_FAN": AirPurifierFanDevice, "DEVICE_CEILING_FAN": CeilingFanDevice, "DEVICE_COOKTOP": CooktopDevice, "DEVICE_DEHUMIDIFIER": DehumidifierDevice, "DEVICE_DISH_WASHER": DishWasherDevice, "DEVICE_DRYER": DryerDevice, "DEVICE_HOME_BREW": HomeBrewDevice, "DEVICE_HOOD": HoodDevice, "DEVICE_HUMIDIFIER": HumidifierDevice, "DEVICE_KIMCHI_REFRIGERATOR": KimchiRefrigeratorDevice, "DEVICE_MICROWAVE_OVEN": MicrowaveOvenDevice, "DEVICE_OVEN": OvenDevice, "DEVICE_PLANT_CULTIVATOR": PlantCultivatorDevice, "DEVICE_REFRIGERATOR": RefrigeratorDevice, "DEVICE_ROBOT_CLEANER": RobotCleanerDevice, "DEVICE_STICK_CLEANER": StickCleanerDevice, "DEVICE_STYLER": StylerDevice, "DEVICE_SYSTEM_BOILER": SystemBoilerDevice, "DEVICE_VENTILATOR": VentilatorDevice, "DEVICE_WASHCOMBO_MAIN": WashcomboMainDevice, "DEVICE_WASHCOMBO_MINI": WashcomboMiniDevice, "DEVICE_WASHER": WasherDevice, "DEVICE_WASHTOWER": WashtowerDevice, "DEVICE_WASHTOWER_DRYER": WashtowerDryerDevice, "DEVICE_WASHTOWER_WASHER": WashtowerWasherDevice, "DEVICE_WATER_HEATER": WaterHeaterDevice, "DEVICE_WATER_PURIFIER": WaterPurifierDevice, "DEVICE_WINE_CELLAR": WineCellarDevice, }