Public Access
fix(ups-hid): voltage, frequency and runtime
Signed-off-by: bullshit <coding@ow-software.pl>
This commit is contained in:
11 files changed
+378
-52
No files matched your search
@@ -414,6 +414,7 @@ void ApcHidProtocol::parse_battery_report(const HidReport &report, UpsData &data
|
||||
ESP_LOGI(APC_HID_TAG, "Battery level: %.0f%%", data.battery.level);
|
||||
|
||||
// Parse runtime if more bytes available (32-bit little-endian)
|
||||
// CORRECTED: Raw HID value is in seconds (like NUT), convert to minutes for ESPHome
|
||||
// recv[2] + 256 * recv[3] + 256 * 256 * recv[4] + 256 * 256 * 256 * recv[5]
|
||||
if (report.data.size() >= 6) {
|
||||
uint32_t runtime_raw = report.data[2] +
|
||||
@@ -421,8 +422,9 @@ void ApcHidProtocol::parse_battery_report(const HidReport &report, UpsData &data
|
||||
(report.data[4] << 16) +
|
||||
(report.data[5] << 24);
|
||||
if (runtime_raw > 0 && runtime_raw < 65535) { // Sanity check
|
||||
data.battery.runtime_minutes = static_cast<float>(runtime_raw);
|
||||
ESP_LOGI(APC_HID_TAG, "Runtime: %.0f minutes", data.battery.runtime_minutes);
|
||||
// Convert seconds to minutes to match ESPHome sensor expectations
|
||||
data.battery.runtime_minutes = static_cast<float>(runtime_raw) / 60.0f;
|
||||
ESP_LOGI(APC_HID_TAG, "Runtime: %d seconds (%.1f minutes)", runtime_raw, data.battery.runtime_minutes);
|
||||
} else {
|
||||
// Set estimate based on battery level if raw value seems invalid
|
||||
data.battery.runtime_minutes = data.battery.level * 0.5f;
|
||||
@@ -564,11 +566,13 @@ void ApcHidProtocol::parse_power_summary_report(const HidReport &report, UpsData
|
||||
ESP_LOGI(APC_HID_TAG, "PowerSummary: Battery %.0f%%", data.battery.level);
|
||||
|
||||
// Runtime at bytes 2-3 (16-bit little-endian, NUT offset 8)
|
||||
// CORRECTED: Raw HID value is in seconds (like NUT), convert to minutes for ESPHome
|
||||
if (report.data.size() >= 4) {
|
||||
uint16_t runtime_raw = report.data[2] | (report.data[3] << 8);
|
||||
if (runtime_raw > 0 && runtime_raw < 65535) {
|
||||
data.battery.runtime_minutes = static_cast<float>(runtime_raw);
|
||||
ESP_LOGI(APC_HID_TAG, "PowerSummary: Runtime %d minutes", runtime_raw);
|
||||
// Convert seconds to minutes to match ESPHome sensor expectations
|
||||
data.battery.runtime_minutes = static_cast<float>(runtime_raw) / 60.0f;
|
||||
ESP_LOGI(APC_HID_TAG, "PowerSummary: Runtime %d seconds (%.1f minutes)", runtime_raw, data.battery.runtime_minutes);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1734,6 +1738,7 @@ void ApcHidProtocol::read_frequency_data(UpsData &data) {
|
||||
|
||||
// Report IDs commonly used for frequency measurements:
|
||||
const std::vector<uint8_t> frequency_report_ids = {
|
||||
0x0d, // APC-specific config report (apparent power and frequency) - PRIORITY
|
||||
HID_USAGE_POW_FREQUENCY, // 0x32 - Standard HID frequency usage
|
||||
HID_USAGE_POW_VOLTAGE, // 0x30 - Input measurements (may include frequency)
|
||||
HID_USAGE_POW_CURRENT, // 0x31 - Output measurements (may include frequency)
|
||||
@@ -1758,16 +1763,59 @@ void ApcHidProtocol::read_frequency_data(UpsData &data) {
|
||||
|
||||
float ApcHidProtocol::parse_frequency_from_report(const HidReport &report) {
|
||||
if (report.data.size() < 2) {
|
||||
ESP_LOGV(APC_HID_TAG, "Frequency report 0x%02X too short: %zu bytes", report.data[0], report.data.size());
|
||||
return NAN;
|
||||
}
|
||||
|
||||
ESP_LOGD(APC_HID_TAG, "Parsing frequency from report 0x%02X (%zu bytes): %02X %02X %02X %02X",
|
||||
report.data[0], report.data.size(),
|
||||
report.data.size() > 0 ? report.data[0] : 0,
|
||||
report.data.size() > 1 ? report.data[1] : 0,
|
||||
report.data.size() > 2 ? report.data[2] : 0,
|
||||
report.data.size() > 3 ? report.data[3] : 0);
|
||||
|
||||
// APC-specific method: Report 0x0d frequency at byte[3] (based on ESP32 NUT server documentation)
|
||||
if (report.data[0] == 0x0d) {
|
||||
ESP_LOGD(APC_HID_TAG, "APC Method - Report 0x0d analysis: size=%zu bytes", report.data.size());
|
||||
if (report.data.size() >= 4) {
|
||||
uint8_t freq_byte = report.data[3];
|
||||
ESP_LOGV(APC_HID_TAG, "APC Method - Report 0x0d byte[3]: %d (0x%02X) - Range check: %s",
|
||||
freq_byte, freq_byte,
|
||||
(freq_byte >= FREQUENCY_MIN_VALID && freq_byte <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_byte >= FREQUENCY_MIN_VALID && freq_byte <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.0f Hz using APC Method (report 0x0d, byte[3])", static_cast<float>(freq_byte));
|
||||
return static_cast<float>(freq_byte);
|
||||
}
|
||||
} else {
|
||||
ESP_LOGW(APC_HID_TAG, "APC Method - Report 0x0d too short for frequency: only %zu bytes (need 4+)", report.data.size());
|
||||
// Try alternative: byte[1] might contain frequency or frequency-derived value in some APC models
|
||||
if (report.data.size() >= 2) {
|
||||
uint8_t alt_freq = report.data[1];
|
||||
ESP_LOGV(APC_HID_TAG, "APC Method - Report 0x0d byte[1]: %d (0x%02X)", alt_freq, alt_freq);
|
||||
|
||||
// Check if this could be a frequency indicator (100 -> 50Hz, 120 -> 60Hz)
|
||||
if (alt_freq == 100) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency 50 Hz using APC Method (report 0x0d, byte[1] = 100 -> 50Hz)");
|
||||
return 50.0f;
|
||||
} else if (alt_freq == 120) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency 60 Hz using APC Method (report 0x0d, byte[1] = 120 -> 60Hz)");
|
||||
return 60.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Try different byte positions and formats commonly used for frequency
|
||||
// Most UPS devices report frequency as integer Hz (50 or 60)
|
||||
|
||||
// Method 1: Single byte at position 1 (common for simple frequency reports)
|
||||
if (report.data.size() >= 2) {
|
||||
uint8_t freq_byte = report.data[1];
|
||||
ESP_LOGV(APC_HID_TAG, "Method 1 - Testing byte[1]: %d (0x%02X) - Range check: %s",
|
||||
freq_byte, freq_byte,
|
||||
(freq_byte >= FREQUENCY_MIN_VALID && freq_byte <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_byte >= FREQUENCY_MIN_VALID && freq_byte <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.0f Hz using Method 1 (single byte)", static_cast<float>(freq_byte));
|
||||
return static_cast<float>(freq_byte);
|
||||
}
|
||||
}
|
||||
@@ -1775,7 +1823,11 @@ float ApcHidProtocol::parse_frequency_from_report(const HidReport &report) {
|
||||
// Method 2: 16-bit little-endian value at position 1-2
|
||||
if (report.data.size() >= 3) {
|
||||
uint16_t freq_word = report.data[1] | (report.data[2] << 8);
|
||||
ESP_LOGV(APC_HID_TAG, "Method 2 - Testing little-endian word[1-2]: %d (0x%04X) - Range check: %s",
|
||||
freq_word, freq_word,
|
||||
(freq_word >= FREQUENCY_MIN_VALID && freq_word <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_word >= FREQUENCY_MIN_VALID && freq_word <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.0f Hz using Method 2 (16-bit little-endian)", static_cast<float>(freq_word));
|
||||
return static_cast<float>(freq_word);
|
||||
}
|
||||
}
|
||||
@@ -1783,7 +1835,11 @@ float ApcHidProtocol::parse_frequency_from_report(const HidReport &report) {
|
||||
// Method 3: 16-bit big-endian value at position 1-2
|
||||
if (report.data.size() >= 3) {
|
||||
uint16_t freq_word = (report.data[1] << 8) | report.data[2];
|
||||
ESP_LOGV(APC_HID_TAG, "Method 3 - Testing big-endian word[1-2]: %d (0x%04X) - Range check: %s",
|
||||
freq_word, freq_word,
|
||||
(freq_word >= FREQUENCY_MIN_VALID && freq_word <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_word >= FREQUENCY_MIN_VALID && freq_word <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.0f Hz using Method 3 (16-bit big-endian)", static_cast<float>(freq_word));
|
||||
return static_cast<float>(freq_word);
|
||||
}
|
||||
}
|
||||
@@ -1792,11 +1848,50 @@ float ApcHidProtocol::parse_frequency_from_report(const HidReport &report) {
|
||||
if (report.data.size() >= 3) {
|
||||
uint16_t freq_scaled = report.data[1] | (report.data[2] << 8);
|
||||
float freq_value = static_cast<float>(freq_scaled) / 10.0f;
|
||||
ESP_LOGV(APC_HID_TAG, "Method 4 - Testing scaled frequency: raw=%d, scaled=%.1f - Range check: %s",
|
||||
freq_scaled, freq_value,
|
||||
(freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.1f Hz using Method 4 (scaled 0.1x)", freq_value);
|
||||
return freq_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Method 5: APC-specific frequency encoding - scale by 0.01 (some APC models use centihz)
|
||||
if (report.data.size() >= 3) {
|
||||
uint16_t freq_scaled = report.data[1] | (report.data[2] << 8);
|
||||
float freq_value = static_cast<float>(freq_scaled) / 100.0f;
|
||||
ESP_LOGV(APC_HID_TAG, "Method 5 - Testing APC centihz frequency: raw=%d, scaled=%.2f - Range check: %s",
|
||||
freq_scaled, freq_value,
|
||||
(freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.2f Hz using Method 5 (APC centihz 0.01x)", freq_value);
|
||||
return freq_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Method 6: Try big-endian centihz scaling (some APC devices)
|
||||
if (report.data.size() >= 3) {
|
||||
uint16_t freq_scaled = (report.data[1] << 8) | report.data[2];
|
||||
float freq_value = static_cast<float>(freq_scaled) / 100.0f;
|
||||
ESP_LOGV(APC_HID_TAG, "Method 6 - Testing APC big-endian centihz: raw=%d, scaled=%.2f - Range check: %s",
|
||||
freq_scaled, freq_value,
|
||||
(freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) ? "PASS" : "FAIL");
|
||||
if (freq_value >= FREQUENCY_MIN_VALID && freq_value <= FREQUENCY_MAX_VALID) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found frequency %.2f Hz using Method 6 (APC big-endian centihz)", freq_value);
|
||||
return freq_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Method 7: Check for frequency encoded in a different byte position (NUT shows various layouts)
|
||||
for (size_t i = 1; i < report.data.size(); i++) {
|
||||
if (report.data[i] == 50 || report.data[i] == 60) {
|
||||
ESP_LOGI(APC_HID_TAG, "Found exact frequency %d Hz at byte[%zu]", report.data[i], i);
|
||||
return static_cast<float>(report.data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
ESP_LOGD(APC_HID_TAG, "No valid frequency found in report 0x%02X (tried 7 methods)", report.data[0]);
|
||||
return NAN;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,6 +274,12 @@ void UpsHidComponent::update_sensors() {
|
||||
value = ups_data_.power.load_percent;
|
||||
} else if (type == "frequency" && !std::isnan(ups_data_.power.frequency)) {
|
||||
value = ups_data_.power.frequency;
|
||||
} else if (type == "input_transfer_low" && !std::isnan(ups_data_.power.input_transfer_low)) {
|
||||
value = ups_data_.power.input_transfer_low;
|
||||
} else if (type == "input_transfer_high" && !std::isnan(ups_data_.power.input_transfer_high)) {
|
||||
value = ups_data_.power.input_transfer_high;
|
||||
} else if (type == "battery_runtime_low" && !std::isnan(ups_data_.battery.runtime_low_threshold)) {
|
||||
value = ups_data_.battery.runtime_low_threshold;
|
||||
} else if (type == "ups_realpower_nominal" && !std::isnan(ups_data_.power.realpower_nominal)) {
|
||||
value = ups_data_.power.realpower_nominal;
|
||||
} else if (type == "ups_delay_shutdown" && !std::isnan(ups_data_.config.delay_shutdown)) {
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
# Example: APC Back-UPS ES 700 Configuration
|
||||
# Complete production configuration for APC UPS
|
||||
# Complete production configuration for APC UPS with European defaults
|
||||
# Copy and customize this file for your APC device
|
||||
|
||||
substitutions:
|
||||
name: "apc-ups-monitor"
|
||||
friendly_name: "Office APC UPS"
|
||||
|
||||
# Device customization
|
||||
timezone: "America/Vienna" # Replace with your timezone
|
||||
|
||||
# Testing/production mode
|
||||
simulation_mode: "false" # Set to "true" for testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "APC Back-UPS ES 700 Monitor"
|
||||
comment: "APC Back-UPS ES 700 Monitor with European defaults"
|
||||
|
||||
# Use modular configuration packages
|
||||
packages:
|
||||
# Regional defaults (European voltage/frequency standards)
|
||||
regional_defaults: !include ../regional/european_base.yaml
|
||||
|
||||
# Core functionality
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
@@ -32,12 +30,6 @@ packages:
|
||||
# APC-specific optimizations
|
||||
apc_device: !include ../device_types/apc_backups_es.yaml
|
||||
|
||||
# Time component for accurate timestamps
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: "${timezone}"
|
||||
|
||||
# Optional: Home Assistant API (uncomment to enable)
|
||||
# api:
|
||||
# encryption:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Protocol Selection Demo Configuration
|
||||
# Demonstrates the new manual protocol selection feature
|
||||
# Demonstrates the new manual protocol selection feature with European defaults
|
||||
|
||||
substitutions:
|
||||
name: "ups-protocol-demo"
|
||||
@@ -9,10 +9,14 @@ substitutions:
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Demonstration of manual protocol selection"
|
||||
comment: "Demonstration of manual protocol selection with European defaults"
|
||||
|
||||
# Use base configuration package
|
||||
# Use modular configuration packages
|
||||
packages:
|
||||
# Regional defaults (European voltage/frequency standards)
|
||||
regional_defaults: !include ../regional/european_base.yaml
|
||||
|
||||
# Base functionality
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
|
||||
@@ -29,6 +33,10 @@ ups_hid:
|
||||
# protocol: cyberpower # Force CyberPower HID Protocol
|
||||
# protocol: generic # Force Generic HID Protocol
|
||||
|
||||
# Platform stubs for compilation
|
||||
button:
|
||||
binary_sensor:
|
||||
|
||||
# Enhanced logging to see protocol selection
|
||||
logger:
|
||||
level: DEBUG
|
||||
|
||||
@@ -1,24 +1,25 @@
|
||||
# Example: CyberPower CP1500EPFCLCD Configuration
|
||||
# Complete production configuration for CyberPower UPS
|
||||
# Complete production configuration for CyberPower UPS with European defaults
|
||||
# Copy and customize this file for your CyberPower device
|
||||
|
||||
substitutions:
|
||||
name: "rack-ups-monitor"
|
||||
friendly_name: "Rack CyberPower UPS"
|
||||
|
||||
# Device customization
|
||||
timezone: "America/Vienna" # Replace with your timezone
|
||||
|
||||
# Testing/production mode
|
||||
simulation_mode: "false" # Set to "true" for testing without hardware
|
||||
|
||||
# Override timezone if needed (defaults to Europe/Warsaw from regional template)
|
||||
timezone: "Europe/Vienna" # Austrian timezone
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "CyberPower CP1500EPFCLCD Monitor"
|
||||
comment: "CyberPower CP1500EPFCLCD Monitor with European defaults"
|
||||
|
||||
# Use modular configuration packages
|
||||
packages:
|
||||
# Regional defaults (European voltage/frequency standards)
|
||||
regional_defaults: !include ../regional/european_base.yaml
|
||||
|
||||
# Core functionality
|
||||
base_ups: !include ../base_ups.yaml
|
||||
essential: !include ../essential_sensors.yaml
|
||||
@@ -32,12 +33,6 @@ packages:
|
||||
# CyberPower-specific optimizations
|
||||
cyberpower_device: !include ../device_types/cyberpower_cp1500.yaml
|
||||
|
||||
# Time component for accurate timestamps
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: "${timezone}"
|
||||
|
||||
# Optional: Home Assistant API (uncomment to enable)
|
||||
# api:
|
||||
# encryption:
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# European Base Configuration (No Secrets Required)
|
||||
# Basic European electrical standards without network/API configuration
|
||||
# Use this for examples and basic templates
|
||||
|
||||
substitutions:
|
||||
# European regional defaults
|
||||
timezone: "Europe/Warsaw" # Default European timezone
|
||||
|
||||
# Base UPS configuration with European defaults
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
protocol_timeout: 15s
|
||||
protocol: auto
|
||||
fallback_nominal_voltage: 230.0 # European standard voltage - used only when AC power unavailable
|
||||
simulation_mode: false
|
||||
|
||||
# Time configuration with European timezone
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: ${timezone}
|
||||
servers:
|
||||
- "pool.ntp.org"
|
||||
- "time.nist.gov"
|
||||
|
||||
# Logging optimized for European users
|
||||
logger:
|
||||
level: INFO
|
||||
logs:
|
||||
ups_hid: INFO
|
||||
@@ -1,19 +1,43 @@
|
||||
# European Voltage Defaults
|
||||
# Configuration template for European electrical standards (IEC 60038)
|
||||
# Use this as a base for European installations
|
||||
# Test configuration for frequency implementation and European defaults
|
||||
|
||||
substitutions:
|
||||
# Device configuration
|
||||
name: "european-ups-test"
|
||||
friendly_name: "European UPS Test"
|
||||
|
||||
# European electrical standards
|
||||
nominal_voltage: "230V" # Standard European single-phase voltage (IEC 60038)
|
||||
frequency: "50Hz" # European frequency standard
|
||||
|
||||
# Regional timezone examples (adjust for your location)
|
||||
timezone: "Europe/Berlin" # Germany
|
||||
timezone: "Europe/Warsaw" # Poland
|
||||
# timezone: "Europe/Vienna" # Austria
|
||||
# timezone: "Europe/Berlin" # Germany
|
||||
# timezone: "Europe/London" # United Kingdom
|
||||
# timezone: "Europe/Paris" # France
|
||||
# timezone: "Europe/Rome" # Italy
|
||||
# timezone: "Europe/Madrid" # Spain
|
||||
|
||||
esphome:
|
||||
name: ${name}
|
||||
friendly_name: ${friendly_name}
|
||||
comment: "Testing European defaults and frequency implementation"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Base UPS configuration with European defaults
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
@@ -40,17 +64,8 @@ logger:
|
||||
|
||||
# WiFi configuration template
|
||||
wifi:
|
||||
# Configure your WiFi credentials
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# European WiFi channel optimization (1-13 allowed in EU)
|
||||
channel: 6
|
||||
|
||||
# Enable fast connect for better reconnection
|
||||
fast_connect: true
|
||||
|
||||
# Access point fallback (if main WiFi fails)
|
||||
ap:
|
||||
ssid: "${friendly_name} AP"
|
||||
password: !secret ap_password
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
# North American Base Configuration (No Secrets Required)
|
||||
# Basic North American electrical standards without network/API configuration
|
||||
# Use this for examples and basic templates
|
||||
|
||||
substitutions:
|
||||
# North American regional defaults
|
||||
timezone: "America/New_York" # Default North American timezone (Eastern Time)
|
||||
|
||||
# Base UPS configuration with North American defaults
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
protocol_timeout: 15s
|
||||
protocol: auto
|
||||
fallback_nominal_voltage: 120.0 # North American standard voltage - used only when AC power unavailable
|
||||
simulation_mode: false
|
||||
|
||||
# Time configuration with North American timezone
|
||||
time:
|
||||
- platform: sntp
|
||||
id: sntp_time
|
||||
timezone: ${timezone}
|
||||
servers:
|
||||
- "pool.ntp.org"
|
||||
- "time.nist.gov"
|
||||
|
||||
# Logging optimized for North American users
|
||||
logger:
|
||||
level: INFO
|
||||
logs:
|
||||
ups_hid: INFO
|
||||
@@ -39,17 +39,8 @@ logger:
|
||||
|
||||
# WiFi configuration template
|
||||
wifi:
|
||||
# Configure your WiFi credentials
|
||||
ssid: !secret wifi_ssid
|
||||
password: !secret wifi_password
|
||||
|
||||
# North American WiFi channel optimization (1-11 allowed in US/Canada)
|
||||
channel: 6
|
||||
|
||||
# Enable fast connect for better reconnection
|
||||
fast_connect: true
|
||||
|
||||
# Access point fallback (if main WiFi fails)
|
||||
ap:
|
||||
ssid: "${friendly_name} AP"
|
||||
password: !secret ap_password
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
# North American Regional Template Test Configuration
|
||||
# Tests North American regional defaults (120V/60Hz)
|
||||
# Use: esphome compile configs/testing/north_american_template_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "north-american-test"
|
||||
friendly_name: "North American Test"
|
||||
simulation_mode: "true" # Safe testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Testing North American regional template (120V/60Hz)"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Minimal logging
|
||||
logger:
|
||||
level: INFO
|
||||
baud_rate: 115200
|
||||
|
||||
# Basic network
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Use North American regional template
|
||||
packages:
|
||||
regional_defaults: !include ../regional/north_american_defaults.yaml
|
||||
|
||||
# UPS component (inherits North American defaults from regional template)
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
simulation_mode: ${simulation_mode}
|
||||
# fallback_nominal_voltage comes from regional template (120V North American)
|
||||
|
||||
# Platform stubs
|
||||
binary_sensor:
|
||||
button:
|
||||
|
||||
# Test sensors to validate North American regional defaults
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage (North American 120V)"
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Frequency (North American 60Hz)"
|
||||
type: frequency
|
||||
unit_of_measurement: "Hz"
|
||||
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Protocol Name"
|
||||
type: protocol
|
||||
@@ -0,0 +1,81 @@
|
||||
# Regional Template Test Configuration
|
||||
# Tests both European and North American regional defaults
|
||||
# Use: esphome compile configs/testing/regional_template_test.yaml
|
||||
|
||||
substitutions:
|
||||
name: "regional-template-test"
|
||||
friendly_name: "Regional Template Test"
|
||||
simulation_mode: "true" # Safe testing without hardware
|
||||
|
||||
esphome:
|
||||
name: "${name}"
|
||||
friendly_name: "${friendly_name}"
|
||||
comment: "Testing regional template functionality and defaults"
|
||||
|
||||
# Core ESP32 configuration
|
||||
esp32:
|
||||
board: esp32-s3-devkitc-1
|
||||
framework:
|
||||
type: esp-idf
|
||||
|
||||
# Minimal logging
|
||||
logger:
|
||||
level: INFO
|
||||
baud_rate: 115200
|
||||
|
||||
# Basic network
|
||||
wifi:
|
||||
ssid: "TestNetwork"
|
||||
password: "TestPassword"
|
||||
|
||||
# External components
|
||||
external_components:
|
||||
- source:
|
||||
type: local
|
||||
path: ../../components
|
||||
|
||||
# Use European regional template (can be changed to ../regional/north_american_defaults.yaml)
|
||||
packages:
|
||||
regional_defaults: !include ../regional/european_defaults.yaml
|
||||
|
||||
# UPS component (inherits European defaults from regional template)
|
||||
ups_hid:
|
||||
id: ups_monitor
|
||||
update_interval: 30s
|
||||
simulation_mode: ${simulation_mode}
|
||||
# fallback_nominal_voltage comes from regional template (230V European)
|
||||
|
||||
# Platform stubs
|
||||
binary_sensor:
|
||||
button:
|
||||
|
||||
# Test sensors to validate regional defaults
|
||||
sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Battery Level"
|
||||
type: battery_level
|
||||
unit_of_measurement: "%"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Voltage (European 230V)"
|
||||
type: input_voltage
|
||||
unit_of_measurement: "V"
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Input Frequency (European 50Hz)"
|
||||
type: frequency
|
||||
unit_of_measurement: "Hz"
|
||||
|
||||
text_sensor:
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "UPS Status"
|
||||
type: status
|
||||
|
||||
- platform: ups_hid
|
||||
ups_hid_id: ups_monitor
|
||||
name: "Protocol Name"
|
||||
type: protocol
|
||||
Reference in new issue
Block a user