post_device_control
Send commands to LG ThinQ devices to adjust settings like temperature, operation mode, or power state using specific control methods and parameters.
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'})
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| device_type | Yes | ||
| device_id | Yes | ||
| control_method | Yes | ||
| control_params | Yes |
Implementation Reference
- thinqconnect_mcp/tools.py:255-316 (handler)Core handler implementing device control: fetches profile, instantiates device class, dynamically calls control method with parameter type conversion.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/server.py:104-129 (registration)MCP tool registration using @mcp.tool decorator, wrapper function injects thinq_api and delegates to tools.post_device_control.@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/server.py:105-114 (schema)Tool schema definition in MCP decorator, specifying input parameters, types, examples, and output.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 """