mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
add heartbeat interval to mqtt settings
This commit is contained in:
12
src/mqtt.cpp
12
src/mqtt.cpp
@@ -36,6 +36,7 @@ uint32_t Mqtt::publish_time_solar_;
|
||||
uint32_t Mqtt::publish_time_mixer_;
|
||||
uint32_t Mqtt::publish_time_sensor_;
|
||||
uint32_t Mqtt::publish_time_other_;
|
||||
uint32_t Mqtt::publish_time_heartbeat_;
|
||||
bool Mqtt::mqtt_enabled_;
|
||||
bool Mqtt::ha_enabled_;
|
||||
uint8_t Mqtt::nested_format_;
|
||||
@@ -146,6 +147,12 @@ void Mqtt::loop() {
|
||||
process_queue();
|
||||
}
|
||||
|
||||
// send heartbeat
|
||||
if ((currentMillis - last_publish_heartbeat_ > publish_time_heartbeat_)) {
|
||||
last_publish_heartbeat_ = currentMillis;
|
||||
EMSESP::system_.send_heartbeat(); // send heartbeat
|
||||
}
|
||||
|
||||
// dallas publish on change
|
||||
if (!publish_time_sensor_) {
|
||||
EMSESP::publish_sensor_values(false);
|
||||
@@ -430,6 +437,7 @@ void Mqtt::load_settings() {
|
||||
publish_time_mixer_ = mqttSettings.publish_time_mixer * 1000;
|
||||
publish_time_other_ = mqttSettings.publish_time_other * 1000;
|
||||
publish_time_sensor_ = mqttSettings.publish_time_sensor * 1000;
|
||||
publish_time_heartbeat_ = mqttSettings.publish_time_heartbeat * 1000;
|
||||
});
|
||||
|
||||
// create basename from base
|
||||
@@ -512,6 +520,10 @@ void Mqtt::set_publish_time_sensor(uint16_t publish_time) {
|
||||
publish_time_sensor_ = publish_time * 1000; // convert to milliseconds
|
||||
}
|
||||
|
||||
void Mqtt::set_publish_time_heartbeat(uint16_t publish_time) {
|
||||
publish_time_heartbeat_ = publish_time * 1000; // convert to milliseconds
|
||||
}
|
||||
|
||||
bool Mqtt::get_publish_onchange(uint8_t device_type) {
|
||||
if (publish_single_ && !ha_enabled_) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user