mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
burner settings use min/max from telegram 4, fix max for values < 0
This commit is contained in:
@@ -980,15 +980,23 @@ void Boiler::check_active() {
|
|||||||
// boiler(0x08) -W-> Me(0x0B), ?(0x04), data: 13 96 09 81 00 64 64 35 05 64 5A 22 00 00 00 00 00 00 00 00 B7
|
// boiler(0x08) -W-> Me(0x0B), ?(0x04), data: 13 96 09 81 00 64 64 35 05 64 5A 22 00 00 00 00 00 00 00 00 B7
|
||||||
// offset 4 - nominal Power kW, could be zero, 5 - min. Burner, 6 - max. Burner
|
// offset 4 - nominal Power kW, could be zero, 5 - min. Burner, 6 - max. Burner
|
||||||
void Boiler::process_UBAFactory(std::shared_ptr<const Telegram> telegram) {
|
void Boiler::process_UBAFactory(std::shared_ptr<const Telegram> telegram) {
|
||||||
uint8_t nomPower = nomPower_;
|
// check for all wanted info in telegram
|
||||||
if (!telegram->read_value(nomPower, 4)) {
|
if (telegram->offset > 4 || telegram->offset + telegram->message_length < 7) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Update nominal Power only if not already set in nvs and we have a valid value
|
toggle_fetch(telegram->type_id, false); // only read once
|
||||||
|
uint8_t min, max, nomPower;
|
||||||
|
telegram->read_value(nomPower, 4);
|
||||||
|
telegram->read_value(min, 5);
|
||||||
|
telegram->read_value(max, 6);
|
||||||
|
// set the value only if no nvs-value is set
|
||||||
if (nomPower > 0 && nomPower_ == 0) {
|
if (nomPower > 0 && nomPower_ == 0) {
|
||||||
has_update(nomPower_, nomPower);
|
has_update(nomPower_, nomPower);
|
||||||
}
|
}
|
||||||
toggle_fetch(telegram->type_id, false); // only read once
|
set_minmax(&burnMinPower_, 0, max);
|
||||||
|
set_minmax(&burnMaxPower_, min, max);
|
||||||
|
set_minmax(&wwMaxPower_, min, max);
|
||||||
|
set_minmax(&selBurnPow_, 0, max);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 0x18
|
// 0x18
|
||||||
|
|||||||
@@ -713,6 +713,17 @@ bool EMSdevice::has_command(const void * value_p) const {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set min and max
|
||||||
|
void EMSdevice::set_minmax(const void * value_p, int16_t min, uint32_t max) {
|
||||||
|
for (auto & dv : devicevalues_) {
|
||||||
|
if (dv.value_p == value_p) {
|
||||||
|
dv.min = min;
|
||||||
|
dv.max = max;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// publish a single value on change
|
// publish a single value on change
|
||||||
void EMSdevice::publish_value(void * value_p) const {
|
void EMSdevice::publish_value(void * value_p) const {
|
||||||
if (!Mqtt::publish_single() || value_p == nullptr) {
|
if (!Mqtt::publish_single() || value_p == nullptr) {
|
||||||
@@ -1671,7 +1682,7 @@ bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, c
|
|||||||
if (v < dv.min) {
|
if (v < dv.min) {
|
||||||
dv.min = v;
|
dv.min = v;
|
||||||
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
||||||
} else if ((uint32_t)v > dv.max) {
|
} else if (v > 0 && (uint32_t)v > dv.max) {
|
||||||
dv.max = v;
|
dv.max = v;
|
||||||
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
dv.remove_state(DeviceValueState::DV_HA_CONFIG_CREATED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -303,6 +303,7 @@ class EMSdevice {
|
|||||||
bool is_readable(const void * value_p) const;
|
bool is_readable(const void * value_p) const;
|
||||||
bool is_readonly(const std::string & cmd, const int8_t id) const;
|
bool is_readonly(const std::string & cmd, const int8_t id) const;
|
||||||
bool has_command(const void * value_p) const;
|
bool has_command(const void * value_p) const;
|
||||||
|
void set_minmax(const void * value_p, int16_t min, uint32_t max);
|
||||||
void publish_value(void * value_p) const;
|
void publish_value(void * value_p) const;
|
||||||
void publish_all_values();
|
void publish_all_values();
|
||||||
|
|
||||||
|
|||||||
@@ -327,7 +327,7 @@ bool DeviceValue::get_custom_min(int16_t & val) {
|
|||||||
bool has_min = (min_pos != std::string::npos);
|
bool has_min = (min_pos != std::string::npos);
|
||||||
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
||||||
if (has_min) {
|
if (has_min) {
|
||||||
uint32_t v = Helpers::atoint(custom_fullname.substr(min_pos + 1).c_str());
|
int16_t v = Helpers::atoint(custom_fullname.substr(min_pos + 1).c_str());
|
||||||
if (fahrenheit) {
|
if (fahrenheit) {
|
||||||
v = (v - (32 * (fahrenheit - 1))) / 1.8; // reset to °C
|
v = (v - (32 * (fahrenheit - 1))) / 1.8; // reset to °C
|
||||||
}
|
}
|
||||||
@@ -345,7 +345,7 @@ bool DeviceValue::get_custom_max(uint32_t & val) {
|
|||||||
bool has_max = (max_pos != std::string::npos);
|
bool has_max = (max_pos != std::string::npos);
|
||||||
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
uint8_t fahrenheit = !EMSESP::system_.fahrenheit() ? 0 : (uom == DeviceValueUOM::DEGREES) ? 2 : (uom == DeviceValueUOM::DEGREES_R) ? 1 : 0;
|
||||||
if (has_max) {
|
if (has_max) {
|
||||||
int v = Helpers::atoint(custom_fullname.substr(max_pos + 1).c_str());
|
int32_t v = Helpers::atoint(custom_fullname.substr(max_pos + 1).c_str());
|
||||||
if (fahrenheit) {
|
if (fahrenheit) {
|
||||||
v = (v - (32 * (fahrenheit - 1))) / 1.8; // reset to °C
|
v = (v - (32 * (fahrenheit - 1))) / 1.8; // reset to °C
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user