Merge pull request #1798 from proddy/dev

formatting, fix MQTT HA
This commit is contained in:
Proddy
2024-06-14 12:33:44 +02:00
committed by GitHub
17 changed files with 44 additions and 76 deletions

View File

@@ -34,7 +34,7 @@
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/react-router-dom": "^5.3.3",
"alova": "^2.21.2",
"alova": "^2.21.3",
"async-validator": "^4.2.5",
"history": "^5.3.0",
"jwt-decode": "^4.0.0",
@@ -64,7 +64,7 @@
"rollup-plugin-visualizer": "^5.12.0",
"terser": "^5.31.1",
"typescript-eslint": "^7.13.0",
"vite": "^5.3.0",
"vite": "^5.3.1",
"vite-plugin-imagemin": "^0.6.1",
"vite-tsconfig-paths": "^4.3.2"
},

View File

@@ -289,7 +289,7 @@ const SystemStatus: FC = () => {
variant="outlined"
onClick={restart}
disabled={processing}
color="primary"
color="error"
>
{LL.RESTART()}
</Button>
@@ -298,7 +298,7 @@ const SystemStatus: FC = () => {
variant="outlined"
onClick={partition}
disabled={processing}
color="primary"
color="warning"
>
EMS-ESP Loader
</Button>

View File

@@ -2000,7 +2000,7 @@ __metadata:
"@types/react": "npm:^18.3.3"
"@types/react-dom": "npm:^18.3.0"
"@types/react-router-dom": "npm:^5.3.3"
alova: "npm:^2.21.2"
alova: "npm:^2.21.3"
async-validator: "npm:^4.2.5"
concurrently: "npm:^8.2.2"
eslint: "npm:^9.4.0"
@@ -2022,7 +2022,7 @@ __metadata:
typesafe-i18n: "npm:^5.26.2"
typescript: "npm:^5.4.5"
typescript-eslint: "npm:^7.13.0"
vite: "npm:^5.3.0"
vite: "npm:^5.3.1"
vite-plugin-imagemin: "npm:^0.6.1"
vite-tsconfig-paths: "npm:^4.3.2"
languageName: unknown
@@ -2084,10 +2084,10 @@ __metadata:
languageName: node
linkType: hard
"alova@npm:^2.21.2":
version: 2.21.2
resolution: "alova@npm:2.21.2"
checksum: 10c0/5e0e7e8cc6ac1972798f600c26b2adbc3bef0985d07e545898457cbc3f6b925d4ef0bec4a67c75676e8725da3a3c961d35706cd2553540c87ff891391ca8d25f
"alova@npm:^2.21.3":
version: 2.21.3
resolution: "alova@npm:2.21.3"
checksum: 10c0/ce03ced33660f15ec667e24df5c7fbeff223dace95a7d50d657dd038f21dc865d8a9290914edbc5a980c8573daa4354ac714f97ae58650ea5b8fefd8fc2d313c
languageName: node
linkType: hard
@@ -7340,9 +7340,9 @@ __metadata:
languageName: node
linkType: hard
"vite@npm:^5.3.0":
version: 5.3.0
resolution: "vite@npm:5.3.0"
"vite@npm:^5.3.1":
version: 5.3.1
resolution: "vite@npm:5.3.1"
dependencies:
esbuild: "npm:^0.21.3"
fsevents: "npm:~2.3.3"
@@ -7376,7 +7376,7 @@ __metadata:
optional: true
bin:
vite: bin/vite.js
checksum: 10c0/d07e1a2ce713d3f73cb83f6289c9ff320da5953f37c35edb8c1388d610e8ca1c98edd642d5c3f163f8771dae294d3d430356a09285e344f0de9fa4b058c541f0
checksum: 10c0/9317262c02ea2dc324dfdbc20c3c450cd89cc9a16399a41a4bf820a3a1f31cf400878c015135e355ee034853cc2399b5499899d5b1bc462d57642d71083e74b6
languageName: node
linkType: hard

View File

@@ -147,8 +147,6 @@ void NetworkSettingsService::setWiFiPowerOnRSSI() {
min_tx_pwr = max_tx_pwr;
}
uint8_t set_power = min_tx_pwr / 10; // this is the recommended power setting to use
// from WiFIGeneric.h use:
// WIFI_POWER_19_5dBm = 78,// 19.5dBm
// WIFI_POWER_19dBm = 76,// 19dBm
@@ -183,6 +181,7 @@ void NetworkSettingsService::setWiFiPowerOnRSSI() {
p = WIFI_POWER_5dBm;
#ifdef EMSESP_DEBUG
uint8_t set_power = min_tx_pwr / 10; // this is the recommended power setting to use
emsesp::EMSESP::logger().debug("Recommended set WiFi Tx Power (set_power %d, new power %d, rssi %d, threshold %d)", set_power, p, rssi, threshold);
#else
char result[10];
@@ -358,13 +357,13 @@ void NetworkSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info)
setWiFiPowerOnRSSI();
}
#if ESP_IDF_VERSION_MAJOR < 5
WiFi.enableIpV6();
WiFi.enableIpV6();
#endif
break;
case ARDUINO_EVENT_ETH_CONNECTED:
#if ESP_IDF_VERSION_MAJOR < 5
ETH.enableIpV6();
ETH.enableIpV6();
#endif
break;

View File

@@ -20,9 +20,6 @@
#include "emsuart_standalone.h"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
namespace emsesp {
/*

View File

@@ -13,7 +13,7 @@ extra_configs =
pio_local.ini
[common]
core_build_flags = -std=gnu++2a -Isrc -Wno-type-limits
core_build_flags = -std=gnu++2a -Isrc -Wno-type-limits -Wall -Wextra -Wno-unused-parameter
core_unbuild_flags = -std=gnu++11
; my_build_flags is set in pio_local.ini

View File

@@ -218,7 +218,7 @@
#endif
#ifndef EMSESP_DEFAULT_ENTITY_FORMAT
#define EMSESP_DEFAULT_ENTITY_FORMAT 3 // in MQTT discovery, single instance, shortname, v3.6
#define EMSESP_DEFAULT_ENTITY_FORMAT 1 // in MQTT discovery, single instance, shortname (EntityFormat::SINGLE_SHORT)
#endif
// matches Web UI settings

View File

@@ -1730,15 +1730,10 @@ void Boiler::process_UBASetPoints(std::shared_ptr<const Telegram> telegram) {
}
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// 0x35 - not yet implemented, not readable, only for settings
void Boiler::process_UBAFlags(std::shared_ptr<const Telegram> telegram) {
}
#pragma GCC diagnostic pop
// 0x1C
// 08 00 1C 94 0B 0A 1D 31 08 00 80 00 00 00 -> message for 29.11.2020
// 08 00 1C 94 0B 0A 1D 31 00 00 00 00 00 00 -> message reset

View File

@@ -187,9 +187,6 @@ void Heatpump::process_HPMonitor2(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, airHumidity_, 1);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
/*
* Type 0x42B- HeatPump Monitor 1
* e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01"
@@ -198,8 +195,6 @@ void Heatpump::process_HPMonitor1(std::shared_ptr<const Telegram> telegram) {
// still to implement
}
#pragma GCC diagnostic pop
// 0x09A0
// Heatpump(0x53) -> All(0x00), ?(0x09A0), data: 02 23 01 3E 01 39 00 5D 01 DE 01 38 00 40 00 5E 00 58 00 3F 01 34 00 02
void Heatpump::process_HPTemperature(std::shared_ptr<const Telegram> telegram) {

View File

@@ -162,9 +162,6 @@ void Heatsource::process_amSettingMessage(std::shared_ptr<const Telegram> telegr
has_update(telegram, releaseWait_, 15); // pos 15: Boiler release wait time (min)
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// 0x054F AM200 not broadcasted message, 7 bytes long
// Boiler(0x60) -> Me(0x0B), amCommand(0x054F), data: 00 00 00 00 00 00 00
void Heatsource::process_amCommandMessage(std::shared_ptr<const Telegram> telegram) {
@@ -182,8 +179,6 @@ void Heatsource::process_amExtraMessage(std::shared_ptr<const Telegram> telegram
has_update(telegram, blockRemainWw_, 25); // minutes
}
#pragma GCC diagnostic pop
// Settings AM200
// pos 12: off(00)/Keelbypass(01)/(hc1pump(02) only standalone)

View File

@@ -154,9 +154,6 @@ void Mixer::process_MMPLUSConfigMessage_HC(std::shared_ptr<const Telegram> teleg
has_update(telegram, flowTempOffset_, 2); // Mixer increase [0-20 K]
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// Thermostat(0x10) -> Mixer(0x20), ?(0x2E1), data: 01 1C 64 00 01
// Thermostat(0x10) -> Mixing Module(0x20), (0x2E1), data: 01 00 00 00 01
// Thermostat(0x10) -> Mixing Module(0x20), (0x2EB), data: 00
@@ -180,8 +177,6 @@ void Mixer::process_IPMSetMessage(std::shared_ptr<const Telegram> telegram) {
// pos 1: pump in %?
}
#pragma GCC diagnostic pop
bool Mixer::set_flowSetTemp(const char * value, const int8_t id) {
int v;
if (!Helpers::value2number(value, v)) {

View File

@@ -614,9 +614,6 @@ void Thermostat::process_RC10Set(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, heatingpid_, 6);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// type 0xB2, mode setting Data: 04 00
// not used, we read mode from monitor 0xB1
void Thermostat::process_RC10Set_2(std::shared_ptr<const Telegram> telegram) {
@@ -629,8 +626,6 @@ void Thermostat::process_RC10Set_2(std::shared_ptr<const Telegram> telegram) {
// has_update(hc->mode, mode >> 1); // store as enum 0, 1, 2
}
#pragma GCC diagnostic pop
// 0xA8 - for reading the mode from the RC20 thermostat (0x17)
// RC20Set(0xA8), data: 01 00 FF F6 01 06 00 01 0D 01 00 FF FF 01 02 02 02 00 00 05 1E 05 1E 02 1C 00 FF 00 00 26 02
void Thermostat::process_RC20Set(std::shared_ptr<const Telegram> telegram) {
@@ -1613,7 +1608,7 @@ void Thermostat::process_RCTime(std::shared_ptr<const Telegram> telegram) {
tm_->tm_isdst = -1; // determine dst
ttime = mktime(tm_); // thermostat time
}
struct timeval newnow = {.tv_sec = ttime};
struct timeval newnow = {.tv_sec = ttime, .tv_usec = 0};
settimeofday(&newnow, nullptr);
LOG_INFO("ems-esp time set from thermostat");
}

View File

@@ -168,14 +168,11 @@ void Water::process_SM100wwStatus2(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, wwPumpMod_, 9);
}
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
// SM100wwCommand - 0x07AB
// Thermostat(0x10) -> Solar Module(0x2A), (0x7AB), data: 01 00 01
void Water::process_SM100wwCommand(std::shared_ptr<const Telegram> telegram) {
// not implemented yet
}
#pragma GCC diagnostic pop
/*
* MM100 messages

View File

@@ -1701,7 +1701,7 @@ bool EMSdevice::generate_values(JsonObject output, const int8_t tag_filter, cons
char time_s[60];
snprintf(time_s,
sizeof(time_s),
"%d %s %d %s %d %s",
"%lu %s %lu %s %lu %s",
(time_value / 1440),
Helpers::translated_word(FL_(days)),
((time_value % 1440) / 60),

View File

@@ -841,18 +841,23 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
// build unique identifier also used as object_id which also becomes the Entity ID in HA
char uniq_id[80];
// list of boiler entities that need conversion for 3.6 compatibility, add ww suffix
// used when entity_format is SINGLE_OLD or MULTI_OLD to keep with 3.6.5
// see #1714 - https://github.com/emsesp/EMS-ESP32/issues/1714
const char * dhw_old[] =
{FL_(nrgWw)[0], FL_(upTimeCompWw)[0], FL_(nrgConsCompWw)[0], FL_(auxElecHeatNrgConsWw)[0], FL_(nrgSuppWw)[0], FL_(wwAltOpPrioWw)[0], FL_(hpCircPumpWw)[0]};
uint8_t num_dhw_old = sizeof(dhw_old) / sizeof(dhw_old[0]);
// create the uniq_d based on the entity format
if (Mqtt::entity_format() == entityFormat::MULTI_SHORT) {
// prefix base name to each uniq_id and use the shortname
// base name + shortname
snprintf(uniq_id, sizeof(uniq_id), "%s_%s_%s", mqtt_basename_.c_str(), device_name, entity_with_tag);
} else if (Mqtt::entity_format() == entityFormat::SINGLE_SHORT) {
// shortname, no mqtt base. This is the default version.
// shortname (default)
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
} else if (Mqtt::entity_format() == entityFormat::SINGLE_OLD) {
// shortname, remap to 3.6.
// shortname, remap to 3.6
if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT)
&& tag == DeviceValue::DeviceValueTAG::TAG_DHW1) {
snprintf(entity_with_tag, sizeof(entity_with_tag), "ww%s", entity);
@@ -872,7 +877,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
snprintf(uniq_id, sizeof(uniq_id), "%s_%s", device_name, entity_with_tag);
}
} else if (Mqtt::entity_format() == entityFormat::MULTI_OLD) {
// shortname, remap to 3.6.
// base name + shortname, remap to 3.6
if (has_tag && (device_type == EMSdevice::DeviceType::BOILER || device_type == EMSdevice::DeviceType::THERMOSTAT)
&& tag == DeviceValue::DeviceValueTAG::TAG_DHW1) {
snprintf(entity_with_tag, sizeof(entity_with_tag), "ww%s", entity);
@@ -1391,19 +1396,17 @@ void Mqtt::add_ha_sections_to_doc(const char * name,
char tpl[150];
// make local copy of state, as the pointer will get derefenced
char state[50];
strcpy(state, state_t);
// skip conditional Jinja2 templates if not home assistant
if (discovery_type() == discoveryType::HOMEASSISTANT) {
// EMS-ESP status check
// snprintf(tpl, sizeof(tpl), "%s/status", Mqtt::base().c_str());
// avty_json["t"] = tpl;
// snprintf(tpl, sizeof(tpl), tpl_draft, "value == 'online'");
// avty_json["val_tpl"] = tpl;
// avty.add(avty_json); // returns 0 if no mem
const char * tpl_draft = "{{'online' if %s else 'offline'}}";
// condition 1
avty_json.clear();
avty_json["t"] = state_t;
avty_json["t"] = state;
snprintf(tpl, sizeof(tpl), tpl_draft, cond1 == nullptr ? "value is defined" : cond1);
avty_json["val_tpl"] = tpl;
avty.add(avty_json); // returns 0 if no mem
@@ -1411,7 +1414,7 @@ void Mqtt::add_ha_sections_to_doc(const char * name,
// condition 2
if (cond2 != nullptr) {
avty_json.clear();
avty_json["t"] = state_t;
avty_json["t"] = state;
snprintf(tpl, sizeof(tpl), tpl_draft, cond2);
avty_json["val_tpl"] = tpl;
avty.add(avty_json); // returns 0 if no mem
@@ -1420,7 +1423,7 @@ void Mqtt::add_ha_sections_to_doc(const char * name,
// negative condition
if (negcond != nullptr) {
avty_json.clear();
avty_json["t"] = state_t;
avty_json["t"] = state;
snprintf(tpl, sizeof(tpl), "{{'offline' if %s else 'online'}}", negcond);
avty_json["val_tpl"] = tpl;
avty.add(avty_json); // returns 0 if no mem

View File

@@ -138,10 +138,6 @@ class Mqtt {
return discovery_prefix_ + "/";
}
static void base(const char * base) {
mqtt_base_ = base;
}
static uint32_t publish_count() {
return mqtt_message_id_;
}

View File

@@ -73,12 +73,13 @@ void EMSuart::uart_event_task(void * pvParameters) {
void EMSuart::start(const uint8_t tx_mode, const uint8_t rx_gpio, const uint8_t tx_gpio) {
if (tx_mode_ == 0xFF) {
uart_config_t uart_config = {
.baud_rate = EMSUART_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.source_clk = UART_SCLK_APB,
.baud_rate = EMSUART_BAUD,
.data_bits = UART_DATA_8_BITS,
.parity = UART_PARITY_DISABLE,
.stop_bits = UART_STOP_BITS_1,
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
.rx_flow_ctrl_thresh = 0, // not used - https://docs.espressif.com/projects/esp-idf/en/v3.3.6/api-reference/peripherals/uart.html
.source_clk = UART_SCLK_APB,
};
#if defined(EMSUART_RX_INVERT)
inverse_mask |= UART_SIGNAL_RXD_INV;