fix(ClockHandler): backlight key mismatch, bell get_config conversion, timezone in get_config
- updateClockBacklight: fix key names to match wire format (backlight/backlight_output/backlight_on/backlight_off instead of enabled/output/onTime/offTime) - handleGetConfig: convert stored 0-based bell indices back to 1-based for hour_bell/half_bell/quarter_bell (255 disabled sentinel passed through unchanged) - handleGetConfig: include gmt_offset_sec, dst_offset_sec, ntp_server from TimeConfig so clock.get_config supersedes clock.get_timezone Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -238,9 +238,10 @@ CommandResult ClockHandler::handleGetConfig(const CommandEnvelope& e) {
|
||||
doc["last_sync_time"] = cc.lastSyncTime;
|
||||
doc["alert_type"] = cc.alertType;
|
||||
doc["alert_interval"] = cc.alertRingInterval;
|
||||
doc["hour_bell"] = cc.hourBell;
|
||||
doc["half_bell"] = cc.halfBell;
|
||||
doc["quarter_bell"] = cc.quarterBell;
|
||||
// Stored 0-based internally; report 1-based to match API convention (255 = disabled, unchanged)
|
||||
doc["hour_bell"] = (cc.hourBell == 255) ? 255 : cc.hourBell + 1;
|
||||
doc["half_bell"] = (cc.halfBell == 255) ? 255 : cc.halfBell + 1;
|
||||
doc["quarter_bell"] = (cc.quarterBell == 255) ? 255 : cc.quarterBell + 1;
|
||||
doc["backlight"] = cc.backlight;
|
||||
doc["backlight_output"] = cc.backlightOutput;
|
||||
doc["backlight_on"] = cc.backlightOnTime;
|
||||
@@ -251,6 +252,10 @@ CommandResult ClockHandler::handleGetConfig(const CommandEnvelope& e) {
|
||||
doc["night_silence"] = cc.nighttimeSilenceEnabled;
|
||||
doc["night_on"] = cc.nighttimeSilenceOnTime;
|
||||
doc["night_off"] = cc.nighttimeSilenceOffTime;
|
||||
const auto& tc = _configManager.getTimeConfig();
|
||||
doc["gmt_offset_sec"] = tc.gmtOffsetSec;
|
||||
doc["dst_offset_sec"] = tc.daylightOffsetSec;
|
||||
doc["ntp_server"] = tc.ntpServer;
|
||||
return CommandResult::ok("clock.get_config", doc);
|
||||
}
|
||||
|
||||
@@ -295,12 +300,8 @@ CommandResult ClockHandler::handleSetConfig(const CommandEnvelope& e) {
|
||||
}
|
||||
|
||||
if (hasEnabled) _configManager.setClockEnabled(c["enabled"].as<bool>());
|
||||
if (hasC1 || hasC2) {
|
||||
JsonDocument tmp;
|
||||
if (hasC1) tmp["c1output"] = c["c1"].as<int>();
|
||||
if (hasC2) tmp["c2output"] = c["c2"].as<int>();
|
||||
_configManager.updateClockOutputs(tmp.as<JsonVariant>());
|
||||
}
|
||||
if (hasC1) _configManager.setClockOutput1(c["c1"].as<uint8_t>());
|
||||
if (hasC2) _configManager.setClockOutput2(c["c2"].as<uint8_t>());
|
||||
if (hasPulseDuration) _configManager.setClockPulseDuration(c["pulse_duration"].as<uint16_t>());
|
||||
if (hasPauseDuration) _configManager.setClockPauseDuration(c["pause_duration"].as<uint16_t>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user