Public Access
refactor(ups-hid): remove unused UpsVendor class
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
7 files changed
+101
-368
No files matched your search
@@ -1181,8 +1181,7 @@ A: Yes, beeper settings are stored in the UPS device's NVRAM and persist across
|
||||
|
||||
1. Inherit from `UpsProtocolBase`
|
||||
2. Implement required methods: `detect()`, `initialize()`, `read_data()`
|
||||
3. Add to protocol detection in `detect_ups_protocol()`
|
||||
4. Update vendor ID mapping in `ups_vendors.h`
|
||||
3. Register protocol using `REGISTER_UPS_PROTOCOL_FOR_VENDOR()` macro
|
||||
|
||||
### Testing
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#include "ups_hid.h"
|
||||
#include "ups_constants.h"
|
||||
#include "ups_vendors.h"
|
||||
#include "usb_transport_factory.h"
|
||||
#include "simulated_transport.h"
|
||||
#ifdef USE_ESP32
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file ups_vendors.h
|
||||
* @brief Known UPS vendor IDs for device identification and validation
|
||||
*
|
||||
* This file contains the definitive list of known UPS vendor IDs
|
||||
* shared between C++ runtime code and Python configuration validation.
|
||||
*/
|
||||
|
||||
namespace esphome
|
||||
{
|
||||
namespace ups_hid
|
||||
{
|
||||
|
||||
// Known UPS vendor IDs with their names
|
||||
struct UpsVendor
|
||||
{
|
||||
uint16_t vendor_id;
|
||||
const char *name;
|
||||
const char *description;
|
||||
};
|
||||
|
||||
// Definitive list of known UPS vendors (based on NUT project HID driver support)
|
||||
static constexpr UpsVendor KNOWN_UPS_VENDORS[] = {
|
||||
// Vendors with dedicated HID drivers and ESPHome implementations
|
||||
{0x051D, "APC", "American Power Conversion (dedicated ESPHome protocol)"},
|
||||
{0x0764, "CyberPower", "CyberPower Systems (dedicated ESPHome protocol)"},
|
||||
|
||||
// Vendors with dedicated NUT HID drivers (Generic HID protocol support)
|
||||
{0x0463, "MGE Office Protection Systems", "MGE Office Protection Systems (Eaton)"},
|
||||
{0x047C, "Dell", "Dell UPS devices (via MGE HID driver)"},
|
||||
{0x04B3, "IBM", "IBM UPS devices (via MGE HID driver)"},
|
||||
{0x04D8, "OpenUPS", "OpenUPS HID devices"},
|
||||
{0x050D, "Belkin", "Belkin USB UPS models"},
|
||||
{0x0592, "Powerware", "Powerware UPS devices (via MGE HID driver)"},
|
||||
{0x05DD, "Delta Electronics", "Delta UPS devices (Tripp Lite OEM)"},
|
||||
{0x06DA, "MGE UPS Systems", "MGE UPS Systems / Liebert / Phoenixtec (now Eaton)"},
|
||||
{0x075D, "Idowell", "Idowell HID UPS devices"},
|
||||
{0x09AE, "Tripp Lite", "Tripp Lite UPS devices"},
|
||||
{0x09D6, "KSTAR", "KSTAR/Micropower UPS devices"},
|
||||
|
||||
// STMicroelectronics OEM vendor (used by multiple UPS manufacturers)
|
||||
{0x0483, "STMicroelectronics", "STMicro OEM UPS devices (CPS, Ever, others)"},
|
||||
};
|
||||
|
||||
static constexpr size_t KNOWN_UPS_VENDORS_COUNT = sizeof(KNOWN_UPS_VENDORS) / sizeof(KNOWN_UPS_VENDORS[0]);
|
||||
|
||||
/**
|
||||
* Check if a vendor ID is in the known UPS vendors list
|
||||
* @param vendor_id The USB vendor ID to check
|
||||
* @return True if vendor ID is known, false otherwise
|
||||
*/
|
||||
inline bool is_known_ups_vendor(uint16_t vendor_id)
|
||||
{
|
||||
for (size_t i = 0; i < KNOWN_UPS_VENDORS_COUNT; i++)
|
||||
{
|
||||
if (KNOWN_UPS_VENDORS[i].vendor_id == vendor_id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get vendor name for a given vendor ID
|
||||
* @param vendor_id The USB vendor ID
|
||||
* @return Vendor name or nullptr if unknown
|
||||
*/
|
||||
inline const char *get_ups_vendor_name(uint16_t vendor_id)
|
||||
{
|
||||
for (size_t i = 0; i < KNOWN_UPS_VENDORS_COUNT; i++)
|
||||
{
|
||||
if (KNOWN_UPS_VENDORS[i].vendor_id == vendor_id)
|
||||
{
|
||||
return KNOWN_UPS_VENDORS[i].name;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace ups_hid
|
||||
} // namespace esphome
|
||||
Reference in new issue
Block a user