From 52c219558c54b2e3b5a8439b8416136c0361336a Mon Sep 17 00:00:00 2001 From: Chenny Du Date: Wed, 15 Mar 2023 16:05:26 +0800 Subject: [PATCH] merge (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 修复不填写mqtt led快闪的问题 * 更改保存电量时间为一小时,避免频繁写入flash https://github.com/qlwz/esp_dc1/issues/16#issuecomment-1121838037 --------- Co-authored-by: 情留メ蚊子 Co-authored-by: gitercn <53464166+gitercn@users.noreply.github.com> --- lib/esp_framework/src/Led.cpp | 2 +- src/DC1.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/esp_framework/src/Led.cpp b/lib/esp_framework/src/Led.cpp index bfb9137..526c11b 100644 --- a/lib/esp_framework/src/Led.cpp +++ b/lib/esp_framework/src/Led.cpp @@ -45,7 +45,7 @@ void Led::loop() } } #ifndef DISABLE_MQTT - else if (!Mqtt::mqttClient.connected()) + else if (globalConfig.mqtt.port != 0 && !Mqtt::mqttClient.connected()) { if (Led::ledType != 1) { diff --git a/src/DC1.cpp b/src/DC1.cpp index 337d640..e47a1b0 100644 --- a/src/DC1.cpp +++ b/src/DC1.cpp @@ -62,7 +62,7 @@ void DC1::init() bool DC1::moduleLed() { - if (WiFi.status() == WL_CONNECTED && Mqtt::mqttClient.connected()) + if (WiFi.status() == WL_CONNECTED && (globalConfig.mqtt.port ==0 || Mqtt::mqttClient.connected())) { if (config.wifi_led == 0) { @@ -658,7 +658,7 @@ void DC1::energyUpdate() { energyUpdateToday(); } - if (perSecond % 301 == 0 && cse7766->Energy.kWhtoday > 0) + if (perSecond % 3600 == 0 && cse7766->Energy.kWhtoday > 0) { energySync(); Config::saveConfig(); @@ -943,4 +943,4 @@ void DC1::reportPower() powerStatTopic[strlen(powerStatTopic) - 1] = ch + 49; // 48 + 1 + ch Mqtt::publish(powerStatTopic, bitRead(lastState, ch) ? "on" : "off", globalConfig.mqtt.retain); } -} \ No newline at end of file +}