Public Access
Development Tools
This folder contains development tools for the UPS HID ESPHome component.
scan-usb.sh
This script lists esp and ups releated usb devices.
generate_vendor_list.py
This script keeps the UPS vendor ID lists synchronized between C++, scripts and Python code.
Purpose
The UPS HID component maintains a list of known UPS vendor IDs in two places:
components/ups_hid/ups_vendors.h(C++ runtime code)components/ups_hid/__init__.py(Python configuration validation)
This script extracts the vendor list from the C++ header file and updates the Python file to ensure they stay in sync.
Usage
Command Line
cd /workspace
python3 tools/generate_vendor_list.py
VSCode Task
- Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+P) - Type "Tasks: Run Task"
- Select "Generate UPS Vendor List"
Or use the keyboard shortcut Ctrl+Shift+P -> "Tasks: Run Build Task" and select the vendor list generator.
When to Run
Run this script whenever you:
- Add new UPS vendor IDs to
components/ups_hid/ups_vendors.h - Modify existing vendor information
- Want to ensure the C++ and Python lists are synchronized
Output
The script will:
- Parse the C++ header file for vendor definitions
- Extract vendor IDs, names, and descriptions
- Update the
KNOWN_VENDOR_IDSdictionary in__init__.py - Display the number of vendors processed
Example Output
Parsing vendors from /workspace/components/ups_hid/ups_vendors.h...
Found 7 vendors
Updated /workspace/components/ups_hid/__init__.py
Adding New Vendors
To add a new UPS vendor:
- Edit
components/ups_hid/ups_vendors.h - Add a new entry to the
KNOWN_UPS_VENDORSarray:{0x1234, "New Vendor", "New Vendor Description"}, - Run the generate_vendor_list.py script to update the Python file
- Compile and test the component
The script automatically maintains alphabetical ordering by vendor ID.