Skip to main content

get_device_by_sn()

Instance Method | VTSDeviceFinder Class

📖 Method Description

Get the configuration object of a specific device by its serial number (Serial Number). This method allows you to precisely locate and access a specific device.


📝 Syntax

device = finder.get_device_by_sn(sn)

🔧 Parameters

ParameterTypeRequiredDescription
snstrDevice serial number

📤 Return Type

Optional[VTSDeviceConfig] - Device configuration object, returns None if not found


💡 Example Code

from pyvitaisdk import VTSDeviceFinder, GF225

# Create VTSDeviceFinder instance
finder = VTSDeviceFinder()

# Method 1: Use known serial number
device = finder.get_device_by_sn("SN123456")
if device:
print(f"Found device: {device}")
else:
print("Device with specified serial number not found")

# Method 2: Select from serial number list
serial_numbers = finder.get_sns()
if serial_numbers:
# Get first device
device = finder.get_device_by_sn(serial_numbers[0])
print(f"Using device: {serial_numbers[0]}")

⚠️ Notes

Return Value Check
  • If the specified serial number does not exist, the method returns None
  • Always check if the return value is None before using it
How to Get Serial Numbers

You can obtain device serial numbers through:

  1. Use the get_sns() method to query all device serial numbers
  2. Read from the device product label
  3. Retrieve from previously saved configuration files
Use Cases
  • Locate specific devices in multi-device environments
  • Load device-specific configurations based on serial number
  • Implement fixed device binding

  • get_sns - Get all device serial number list
  • get_devices - Get all device configurations
  • GF225 - Create sensor instance using device configuration