mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 01:09:51 +03:00
mqtt status shows queue and reconnects
This commit is contained in:
@@ -860,7 +860,8 @@ void EMSdevice::generate_values_web(JsonObject & output) {
|
||||
obj["s"] = Helpers::render_value(s, (float)(-1) * dv.numeric_operator, 0);
|
||||
}
|
||||
|
||||
int16_t dv_set_min, dv_set_max;
|
||||
int16_t dv_set_min;
|
||||
uint16_t dv_set_max;
|
||||
if (dv.get_min_max(dv_set_min, dv_set_max)) {
|
||||
obj["m"] = Helpers::render_value(s, dv_set_min, 0);
|
||||
obj["x"] = Helpers::render_value(s, dv_set_max, 0);
|
||||
@@ -1042,7 +1043,7 @@ void EMSdevice::setCustomEntity(const std::string & entity_id) {
|
||||
auto min = dv.min;
|
||||
auto max = dv.max;
|
||||
dv.set_custom_minmax();
|
||||
if (dv.short_name == FL_(seltemp)[0] && (min != dv.min || max != dv.max)) {
|
||||
if (Mqtt::ha_enabled() && dv.short_name == FL_(seltemp)[0] && (min != dv.min || max != dv.max)) {
|
||||
set_climate_minmax(dv.tag, dv.min, dv.max);
|
||||
}
|
||||
return;
|
||||
@@ -1214,7 +1215,8 @@ bool EMSdevice::get_value_info(JsonObject & output, const char * cmd, const int8
|
||||
|
||||
// set the min and max only for commands
|
||||
if (dv.has_cmd) {
|
||||
int16_t dv_set_min, dv_set_max;
|
||||
int16_t dv_set_min;
|
||||
uint16_t dv_set_max;
|
||||
if (dv.get_min_max(dv_set_min, dv_set_max)) {
|
||||
json["min"] = dv_set_min;
|
||||
json["max"] = dv_set_max;
|
||||
|
||||
@@ -266,7 +266,7 @@ bool DeviceValue::hasValue() const {
|
||||
// converts to signed int, which means rounding to an whole integer
|
||||
// returns false if there is no min/max needed
|
||||
// Types BOOL, ENUM, STRING and CMD are not used
|
||||
bool DeviceValue::get_min_max(int16_t & dv_set_min, int16_t & dv_set_max) {
|
||||
bool DeviceValue::get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max) {
|
||||
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
||||
|
||||
// if we have individual limits set already, just do the conversion
|
||||
|
||||
@@ -177,7 +177,7 @@ class DeviceValue {
|
||||
uint8_t state);
|
||||
|
||||
bool hasValue() const;
|
||||
bool get_min_max(int16_t & dv_set_min, int16_t & dv_set_max);
|
||||
bool get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max);
|
||||
|
||||
void set_custom_minmax();
|
||||
bool get_custom_min(int16_t & val);
|
||||
|
||||
@@ -917,8 +917,8 @@ void Mqtt::publish_ha_sensor_config(DeviceValue & dv, const std::string & model,
|
||||
}
|
||||
|
||||
// calculate the min and max
|
||||
int16_t dv_set_min;
|
||||
int16_t dv_set_max;
|
||||
int16_t dv_set_min;
|
||||
uint16_t dv_set_max;
|
||||
(void)dv.get_min_max(dv_set_min, dv_set_max);
|
||||
|
||||
// determine if we're creating the command topics which we use special HA configs
|
||||
|
||||
12
src/mqtt.h
12
src/mqtt.h
@@ -167,6 +167,14 @@ class Mqtt {
|
||||
return mqtt_publish_fails_;
|
||||
}
|
||||
|
||||
static uint32_t publish_queued() {
|
||||
return mqtt_messages_.size();
|
||||
}
|
||||
|
||||
static uint8_t connect_count() {
|
||||
return connectcount_;
|
||||
}
|
||||
|
||||
static void reset_mqtt();
|
||||
|
||||
static bool is_nested() {
|
||||
@@ -178,7 +186,7 @@ class Mqtt {
|
||||
}
|
||||
|
||||
static bool publish_single() {
|
||||
return publish_single_;
|
||||
return mqtt_enabled_ && publish_single_;
|
||||
}
|
||||
|
||||
static bool publish_single2cmd() {
|
||||
@@ -190,7 +198,7 @@ class Mqtt {
|
||||
}
|
||||
|
||||
static bool ha_enabled() {
|
||||
return ha_enabled_;
|
||||
return mqtt_enabled_ && ha_enabled_;
|
||||
}
|
||||
|
||||
static void ha_enabled(bool ha_enabled) {
|
||||
|
||||
Reference in New Issue
Block a user