Merge branch 'emsesp:dev' into dev

This commit is contained in:
Proddy
2025-05-24 10:11:39 +02:00
committed by GitHub
15 changed files with 20 additions and 68 deletions

View File

@@ -11,7 +11,6 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/).
- boiler auxheatersource [#2489](https://github.com/emsesp/EMS-ESP32/discussions/2489)
- thermostat last error for RC100/300 [#2501](https://github.com/emsesp/EMS-ESP32/issues/2501)
- boiler 0xC6 telegram [#1963](https://github.com/emsesp/EMS-ESP32/issues/1963)
- HA optimistic [#2551](https://github.com/emsesp/EMS-ESP32/issues/2551)
- CS6800i changes [#2448](https://github.com/emsesp/EMS-ESP32/issues/2448), [#2449](https://github.com/emsesp/EMS-ESP32/issues/2449)
- charging pump [#2544](https://github.com/emsesp/EMS-ESP32/issues/2544)

View File

@@ -296,18 +296,6 @@ const MqttSettings = () => {
}
label={LL.MQTT_PUBLISH_TEXT_3()}
/>
{data.ha_enabled && data.discovery_type === 0 && (
<BlockFormControlLabel
control={
<Checkbox
name="ha_optimistic"
checked={data.ha_optimistic}
onChange={updateFormValue}
/>
}
label="Optimistic"
/>
)}
</Grid>
{data.ha_enabled && (
<Grid container spacing={2} rowSpacing={0}>

View File

@@ -43,7 +43,6 @@ export interface MqttSettingsType {
mqtt_qos: number;
mqtt_retain: boolean;
ha_enabled: boolean;
ha_optimistic: boolean;
nested_format: number;
send_response: boolean;
publish_single: boolean;

View File

@@ -36,7 +36,6 @@ class DummySettings {
String discovery_prefix = "homeassistant";
uint8_t discovery_type = 0; // HA
bool ha_enabled = true;
bool ha_optimistic = false;
String base = "ems-esp";
bool publish_single = false;
bool publish_single2cmd = false;

View File

@@ -567,7 +567,6 @@ let mqtt_settings = {
rootCA: '',
mqtt_retain: false,
ha_enabled: true,
ha_optimistic: false,
nested_format: 1,
discovery_type: 0,
discovery_prefix: 'homeassistant',

View File

@@ -244,7 +244,6 @@ void MqttSettings::read(MqttSettings & settings, JsonObject root) {
root["mqtt_qos"] = settings.mqtt_qos;
root["mqtt_retain"] = settings.mqtt_retain;
root["ha_enabled"] = settings.ha_enabled;
root["ha_optimistic"] = settings.ha_optimistic;
root["nested_format"] = settings.nested_format;
root["discovery_prefix"] = settings.discovery_prefix;
root["discovery_type"] = settings.discovery_type;
@@ -285,7 +284,6 @@ StateUpdateResult MqttSettings::update(JsonObject root, MqttSettings & settings)
newSettings.publish_time_heartbeat = static_cast<uint16_t>(root["publish_time_heartbeat"] | EMSESP_DEFAULT_PUBLISH_HEARTBEAT);
newSettings.ha_enabled = root["ha_enabled"] | EMSESP_DEFAULT_HA_ENABLED;
newSettings.ha_optimistic = root["ha_optimistic"] | EMSESP_DEFAULT_HA_OPTIMISTIC;
newSettings.nested_format = static_cast<uint8_t>(root["nested_format"] | EMSESP_DEFAULT_NESTED_FORMAT);
newSettings.discovery_prefix = root["discovery_prefix"] | EMSESP_DEFAULT_DISCOVERY_PREFIX;
newSettings.discovery_type = static_cast<uint8_t>(root["discovery_type"] | EMSESP_DEFAULT_DISCOVERY_TYPE);
@@ -347,14 +345,6 @@ StateUpdateResult MqttSettings::update(JsonObject root, MqttSettings & settings)
changed = true;
}
if (newSettings.discovery_type != 0) {
newSettings.ha_optimistic = false;
}
if (newSettings.ha_optimistic != settings.ha_optimistic) {
emsesp::EMSESP::mqtt_.ha_optimistic(newSettings.ha_optimistic);
changed = true;
}
if (newSettings.mqtt_retain != settings.mqtt_retain) {
emsesp::EMSESP::mqtt_.set_retain(newSettings.mqtt_retain);
changed = true;

View File

@@ -76,7 +76,6 @@ class MqttSettings {
uint8_t mqtt_qos;
bool mqtt_retain;
bool ha_enabled;
bool ha_optimistic;
uint8_t nested_format;
String discovery_prefix;
uint8_t discovery_type;

View File

@@ -682,9 +682,6 @@ void AnalogSensor::publish_values(const bool force) {
Mqtt::add_ha_sections_to_doc("analog", stat_t, config, !is_ha_device_created, val_cond);
if (Mqtt::ha_optimistic() && config["cmd_t"].is<const char*>()) {
config["optimistic"] = true;
}
sensor.ha_registered = Mqtt::queue_ha(topic, config.as<JsonObject>());
}
}

View File

@@ -197,16 +197,17 @@ class EMSdevice {
}
}
void has_enumupdate(std::shared_ptr<const Telegram> telegram,
uint8_t & value,
const uint8_t index,
const std::vector<uint8_t> & maskIn,
const std::vector<uint8_t> & maskOut) {
void has_enumupdate(std::shared_ptr<const Telegram> telegram, uint8_t & value, const uint8_t index, const std::vector<uint8_t> & maskIn) {
uint8_t val = value < maskIn.size() ? maskIn[value] : EMS_VALUE_UINT8_NOTSET;
if (telegram->read_value(val, index)) {
value = val < maskOut.size() ? maskOut[val] : EMS_VALUE_UINT8_NOTSET;
for (uint8_t i = 0; i < maskIn.size(); i++) {
if (val == maskIn[i]) {
value = i;
has_update_ = true;
publish_value((void *)&value);
return;
}
}
}
}

View File

@@ -40,7 +40,6 @@ uint32_t Mqtt::publish_time_heartbeat_;
bool Mqtt::mqtt_enabled_;
uint8_t Mqtt::entity_format_;
bool Mqtt::ha_enabled_;
bool Mqtt::ha_optimistic_;
uint8_t Mqtt::nested_format_;
std::string Mqtt::discovery_prefix_;
uint8_t Mqtt::discovery_type_;
@@ -341,7 +340,6 @@ void Mqtt::load_settings() {
mqtt_retain_ = mqttSettings.mqtt_retain;
mqtt_enabled_ = mqttSettings.enabled;
ha_enabled_ = mqttSettings.ha_enabled;
ha_optimistic_ = mqttSettings.ha_optimistic;
nested_format_ = mqttSettings.nested_format;
publish_single_ = mqttSettings.publish_single;
publish_single2cmd_ = mqttSettings.publish_single2cmd;
@@ -1127,9 +1125,6 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
doc["dev"] = dev_json;
if (ha_optimistic_ && has_cmd) {
doc["optimistic"] = true;
}
return queue_ha(topic, doc.as<JsonObject>());
}
@@ -1359,9 +1354,6 @@ bool Mqtt::publish_ha_climate_config(const int8_t tag, const bool has_roomtemp,
// device name must be different to the entity name, take the ids value we just created
add_ha_sections_to_doc("thermostat", topic_t, doc, false, seltemp_cond, has_roomtemp ? currtemp_cond : nullptr, hc_mode_cond);
if (ha_optimistic_) {
doc["optimistic"] = true;
}
return queue_ha(topic, doc.as<JsonObject>()); // publish the config payload with retain flag
}

View File

@@ -210,14 +210,6 @@ class Mqtt {
ha_enabled_ = ha_enabled;
}
static bool ha_optimistic() {
return ha_optimistic_;
}
static void ha_optimistic(bool ha_optimistic) {
ha_optimistic_ = ha_optimistic;
}
static bool ha_climate_reset() {
return ha_climate_reset_;
}
@@ -321,7 +313,6 @@ class Mqtt {
static uint32_t publish_time_heartbeat_;
static bool mqtt_enabled_;
static bool ha_enabled_;
static bool ha_optimistic_;
static uint8_t nested_format_;
static uint8_t entity_format_;
static std::string discovery_prefix_;

View File

@@ -1805,9 +1805,9 @@ void Boiler::process_HpCooling(std::shared_ptr<const Telegram> telegram) {
// Boiler(0x08) -W-> Me(0x0B), HpHeaterConfig(0x0492), data: 03 00 00 04 00
void Boiler::process_HpHeaterConfig(std::shared_ptr<const Telegram> telegram) {
if (model() == EMSdevice::EMS_DEVICE_FLAG_CS6800) {
has_enumupdate(telegram, maxHeatComp_, 2, {0, 2, 4, 5}, {0, 0, 1, 0, 2, 3});
has_enumupdate(telegram, maxHeatHeat_, 3, {2, 4, 5}, {0, 0, 0, 0, 1, 2});
has_enumupdate(telegram, maxHeatDhw_, 4, {2, 4, 5}, {0, 0, 0, 0, 1, 2});
has_enumupdate(telegram, maxHeatComp_, 2, {0, 2, 4, 5});
has_enumupdate(telegram, maxHeatHeat_, 3, {2, 4, 5});
has_enumupdate(telegram, maxHeatDhw_, 4, {2, 4, 5});
return;
}
has_update(telegram, maxHeatComp_, 2);

View File

@@ -1275,14 +1275,14 @@ void Thermostat::process_RC300WWmode(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, dhw->wwCircPump_, 1); // FF=off, 0=on ?
if (model() == EMSdevice::EMS_DEVICE_FLAG_BC400 || model() == EMSdevice::EMS_DEVICE_FLAG_HMC310) {
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 5, 1, 2, 4}, {0, 2, 3, 0, 4, 1});
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 5, 1, 2, 4});
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_R3000) {
// https://github.com/emsesp/EMS-ESP32/pull/1722#discussion_r1582823521
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 5}, {0, 0, 1, 0, 0, 2}); // normal, comfort, eco+
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 5}); // normal, comfort, eco+
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_CR120) {
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 4}, {0, 0, 1, 0, 2, 0}); // normal, comfort, auto
has_enumupdate(telegram, dhw->wwMode_, 2, {1, 2, 4}); // normal, comfort, auto
} else if (model() == EMSdevice::EMS_DEVICE_FLAG_RC100) {
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 2, 3}, {0, 0, 1, 2, 0, 0}); // normal, on, auto
has_enumupdate(telegram, dhw->wwMode_, 2, {0, 2, 3}); // normal, on, auto
} else {
has_update(telegram, dhw->wwMode_, 2); // 0=off, 1=low, 2=high, 3=auto, 4=own prog
}
@@ -4171,6 +4171,10 @@ bool Thermostat::set_temperature(const float temperature, const uint8_t mode, co
// add the write command to the Tx queue. value is *2
// post validate is the corresponding monitor or set type IDs as they can differ per model
write_command(set_typeid, offset, (uint8_t)(temperature * (float)factor), validate_typeid);
// update selTemp now, readback from monitor telegram takes a while
if (mode == HeatingCircuit::Mode::AUTO) {
has_update(hc->selTemp,(int16_t)(temperature * factor));
}
return true;
}
LOG_DEBUG("temperature mode %d not found", mode);

View File

@@ -452,9 +452,6 @@ void WebCustomEntityService::publish(const bool force) {
Mqtt::add_ha_sections_to_doc(F_(custom), stat_t, config, !ha_created, val_cond);
if (Mqtt::ha_optimistic() && (entityItem.writeable || entityItem.ram > 0)) {
config["optimistic"] = true;
}
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
}
}

View File

@@ -290,9 +290,6 @@ void WebSchedulerService::publish(const bool force) {
Mqtt::add_ha_bool(config);
Mqtt::add_ha_sections_to_doc(F_(scheduler), stat_t, config, !ha_created, val_cond);
if (Mqtt::ha_optimistic()) {
config["optimistic"] = true;
}
ha_created |= Mqtt::queue_ha(topic, config.as<JsonObject>());
}
}