Files
esphome-components-ups/components/ups_hid/protocol_goldenmate.h
T
rwalker777 d5d81ab445 Refine GoldenMate UPS protocol documentation
Updated protocol description and field mappings for GoldenMate UPS.
2026-05-02 13:14:27 -05:00

57 lines
2.0 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#pragma once
#include "ups_hid.h"
namespace esphome {
namespace ups_hid {
/**
* GoldenMate LiFePO4 UPS Protocol
*
* Vendor: 0x075D, Product: UPS Pro
* Used by GoldenMate UPS with USB port.
*
* Data sources:
* Report 0x01 (Feature, 21 bytes) - binary status:
* byte 11: battery % (0-100)
* bytes 12-13 LE16: runtime to empty (seconds)
*
* Report 0x0C (Feature, 64+ bytes) - contains packed BMS ASCII at bytes 30-61:
* Field 1 (4 chars): Current × 100 (e.g., "1491" = 14.91 A) -> mapped to load_percent
* Field 2 (4 chars): Voltage × 100 (e.g., "1400" = 14.00 V) -> mapped to battery.voltage
* Field 3 (4 chars): Power × 10 (e.g., "2084" = 208.4 W) -> mapped to input_voltage
* Field 4 (3 chars): SOC % (e.g., "100" = 100 %) -> mapped to battery.level
* Field 5 (3 chars): Capacity Ah × 10 (e.g., "599" = 59.9 Ah) -> mapped to frequency
* Field 6 (3 chars): Cycles (e.g., "205" = 205) -> mapped to output_voltage
* Field 7 (3 chars): Temp × 10 (e.g., "350" = 35.0 °C) -> mapped to input_transfer_low
* Field 8 (8 chars): Status bits
*/
class GoldenMateProtocol : public UpsProtocolBase {
public:
GoldenMateProtocol(UpsHidComponent *parent) : UpsProtocolBase(parent) {}
bool detect() override;
bool initialize() override;
bool read_data(UpsData &data) override;
DeviceInfo::DetectedProtocol get_protocol_type() const override { return DeviceInfo::PROTOCOL_GENERIC_HID; }
std::string get_protocol_name() const override { return "GoldenMate"; }
private:
static const uint8_t REPORT_ID_STATUS = 0x01;
static const uint8_t REPORT_ID_MEGATEC = 0x0C;
struct HidReport {
uint8_t report_id;
std::vector<uint8_t> data;
HidReport() : report_id(0) {}
};
bool read_feature_report(uint8_t report_id, HidReport &report);
bool parse_binary_status(const HidReport &report, UpsData &data);
bool parse_megatec_string(const HidReport &report, UpsData &data);
std::string extract_packed_ascii(const uint8_t *data, size_t offset, size_t len);
};
} // namespace ups_hid
} // namespace esphome