mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
@@ -42,7 +42,7 @@
|
||||
"react-dom": "latest",
|
||||
"react-dropzone": "^14.2.3",
|
||||
"react-icons": "^4.11.0",
|
||||
"react-router-dom": "^6.17.0",
|
||||
"react-router-dom": "^6.18.0",
|
||||
"react-toastify": "^9.1.3",
|
||||
"sockette": "^2.0.6",
|
||||
"typesafe-i18n": "^5.26.2",
|
||||
@@ -68,7 +68,7 @@
|
||||
"preact": "^10.18.1",
|
||||
"prettier": "^3.0.3",
|
||||
"rollup-plugin-visualizer": "^5.9.2",
|
||||
"terser": "^5.23.0",
|
||||
"terser": "^5.24.0",
|
||||
"vite": "^4.5.0",
|
||||
"vite-plugin-imagemin": "^0.6.1",
|
||||
"vite-tsconfig-paths": "^4.2.1"
|
||||
|
||||
@@ -114,7 +114,7 @@ const DashboardDevicesDialog = ({
|
||||
{editItem.l ? (
|
||||
<TextField
|
||||
name="v"
|
||||
label={LL.VALUE(0)}
|
||||
label={LL.VALUE(1)}
|
||||
value={editItem.v}
|
||||
disabled={!writeable}
|
||||
autoFocus
|
||||
@@ -132,7 +132,7 @@ const DashboardDevicesDialog = ({
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors}
|
||||
name="v"
|
||||
label={LL.VALUE(0)}
|
||||
label={LL.VALUE(1)}
|
||||
value={Math.round(editItem.v * 10) / 10}
|
||||
autoFocus
|
||||
disabled={!writeable}
|
||||
@@ -148,7 +148,7 @@ const DashboardDevicesDialog = ({
|
||||
<ValidatedTextField
|
||||
fieldErrors={fieldErrors}
|
||||
name="v"
|
||||
label={LL.VALUE(0)}
|
||||
label={LL.VALUE(1)}
|
||||
value={editItem.v}
|
||||
disabled={!writeable}
|
||||
autoFocus
|
||||
|
||||
@@ -183,7 +183,7 @@ const DashboardSensorsAnalogDialog = ({
|
||||
<Grid item xs={4}>
|
||||
<TextField
|
||||
name="o"
|
||||
label={LL.VALUE(0)}
|
||||
label={LL.VALUE(1)}
|
||||
value={numberValue(editItem.o)}
|
||||
fullWidth
|
||||
type="number"
|
||||
@@ -197,7 +197,7 @@ const DashboardSensorsAnalogDialog = ({
|
||||
<Grid item xs={4}>
|
||||
<TextField
|
||||
name="o"
|
||||
label={LL.VALUE(0)}
|
||||
label={LL.VALUE(1)}
|
||||
value={numberValue(editItem.o)}
|
||||
fullWidth
|
||||
type="number"
|
||||
|
||||
@@ -238,6 +238,7 @@ type BoardProfiles = {
|
||||
export const BOARD_PROFILES: BoardProfiles = {
|
||||
S32: 'BBQKees Gateway S32',
|
||||
E32: 'BBQKees Gateway E32',
|
||||
S32S3: 'BBQKees Gateway S3',
|
||||
NODEMCU: 'NodeMCU 32S',
|
||||
'MH-ET': 'MH-ET Live D1 Mini',
|
||||
LOLIN: 'Lolin D32',
|
||||
@@ -245,8 +246,7 @@ export const BOARD_PROFILES: BoardProfiles = {
|
||||
OLIMEXPOE: 'Olimex ESP32-POE',
|
||||
C3MINI: 'Wemos C3 Mini',
|
||||
S2MINI: 'Wemos S2 Mini',
|
||||
S3MINI: 'Liligo S3',
|
||||
S32S3: 'BBQKees Gateway S3'
|
||||
S3MINI: 'Liligo S3'
|
||||
};
|
||||
|
||||
export interface BoardProfile {
|
||||
|
||||
@@ -1099,10 +1099,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@remix-run/router@npm:1.10.0":
|
||||
version: 1.10.0
|
||||
resolution: "@remix-run/router@npm:1.10.0"
|
||||
checksum: 61f5e6374f2d0edd177a61c8a44715290d9197a61362505fb0784f948a39e8353d9604ce3747151f837fc7b950e1fbd71bc797b161643325c545037ffbedd134
|
||||
"@remix-run/router@npm:1.11.0":
|
||||
version: 1.11.0
|
||||
resolution: "@remix-run/router@npm:1.11.0"
|
||||
checksum: 629ec578b9dfd3c5cb5de64a0798dd7846ec5ba0351aa66f42b1c65efb43da8f30366be59b825303648965b0df55b638c110949b24ef94fd62e98117fdfb0c0f
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -1576,11 +1576,11 @@ __metadata:
|
||||
react-dom: "npm:latest"
|
||||
react-dropzone: "npm:^14.2.3"
|
||||
react-icons: "npm:^4.11.0"
|
||||
react-router-dom: "npm:^6.17.0"
|
||||
react-router-dom: "npm:^6.18.0"
|
||||
react-toastify: "npm:^9.1.3"
|
||||
rollup-plugin-visualizer: "npm:^5.9.2"
|
||||
sockette: "npm:^2.0.6"
|
||||
terser: "npm:^5.23.0"
|
||||
terser: "npm:^5.24.0"
|
||||
typesafe-i18n: "npm:^5.26.2"
|
||||
typescript: "npm:^5.2.2"
|
||||
vite: "npm:^4.5.0"
|
||||
@@ -6828,27 +6828,27 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"react-router-dom@npm:^6.17.0":
|
||||
version: 6.17.0
|
||||
resolution: "react-router-dom@npm:6.17.0"
|
||||
"react-router-dom@npm:^6.18.0":
|
||||
version: 6.18.0
|
||||
resolution: "react-router-dom@npm:6.18.0"
|
||||
dependencies:
|
||||
"@remix-run/router": "npm:1.10.0"
|
||||
react-router: "npm:6.17.0"
|
||||
"@remix-run/router": "npm:1.11.0"
|
||||
react-router: "npm:6.18.0"
|
||||
peerDependencies:
|
||||
react: ">=16.8"
|
||||
react-dom: ">=16.8"
|
||||
checksum: fc881346af12cdfc4f709c6ca91090d5ed62362154a398a0e8c2b19daabee1fbc8a3ddd0ab727e743ea4268b87f3b2ebc3251c730e2c190ee3ab286059f523e5
|
||||
checksum: b0e72603d73172b6c6662afe2faed326753d5bbd9905aa560e3dade7996fc13d19e34e3ed668d2849efd685e2db2f711129c84b1439870e92c9cc91ddc343cf5
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"react-router@npm:6.17.0":
|
||||
version: 6.17.0
|
||||
resolution: "react-router@npm:6.17.0"
|
||||
"react-router@npm:6.18.0":
|
||||
version: 6.18.0
|
||||
resolution: "react-router@npm:6.18.0"
|
||||
dependencies:
|
||||
"@remix-run/router": "npm:1.10.0"
|
||||
"@remix-run/router": "npm:1.11.0"
|
||||
peerDependencies:
|
||||
react: ">=16.8"
|
||||
checksum: 5c589c67b53cc1a210bd08285392e951a2c3d51a2502806f68d9ce604307944239b0a3b766d8390b484d707ace3068af858e999a1c242662b917ddcd4ab3c453
|
||||
checksum: a00c8f347b7ffee575f4a7731782e688e3fca458ca5bd970fb41cef66a6851853caa24464155ab438d5879f367b1223a539642a405a865913ffe7e63e53b1245
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -7912,9 +7912,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"terser@npm:^5.23.0":
|
||||
version: 5.23.0
|
||||
resolution: "terser@npm:5.23.0"
|
||||
"terser@npm:^5.24.0":
|
||||
version: 5.24.0
|
||||
resolution: "terser@npm:5.24.0"
|
||||
dependencies:
|
||||
"@jridgewell/source-map": "npm:^0.3.3"
|
||||
acorn: "npm:^8.8.2"
|
||||
@@ -7922,7 +7922,7 @@ __metadata:
|
||||
source-map-support: "npm:~0.5.20"
|
||||
bin:
|
||||
terser: bin/terser
|
||||
checksum: 0a9ffc843cf9ee529b3cb85c4e961fd61dc1d484c462372a7158099c3147c28d8bfe9d57e49d4d7594a9c7deed0a7f28a30f79a9161152bd89791fe986e834f0
|
||||
checksum: bd7ba6bfef58f8c179592894923c8c933d980e17287d3f2a9927550be853d1601beebb724cf015929599b32945641c44f9c3db8dd242c7933af3830bcb853510
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
25
src/mqtt.cpp
25
src/mqtt.cpp
@@ -472,6 +472,7 @@ void Mqtt::on_disconnect(espMqttClientTypes::DisconnectReason reason) {
|
||||
} else {
|
||||
LOG_WARNING("MQTT disconnected: code %d", reason);
|
||||
}
|
||||
mqttClient_->clearQueue(true);
|
||||
}
|
||||
|
||||
// MQTT on_connect - when an MQTT connect is established
|
||||
@@ -589,7 +590,7 @@ bool Mqtt::queue_message(const uint8_t operation, const std::string & topic, con
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (!mqtt_enabled_ || topic.empty()) {
|
||||
if (!mqtt_enabled_ || topic.empty() || !connected()) {
|
||||
return false; // quit, not using MQTT
|
||||
}
|
||||
// check free mem
|
||||
@@ -847,10 +848,11 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
|
||||
bool set_ha_classes = false; // set to true if we want to set the state class and device class
|
||||
|
||||
// create the topic, depending on the type and whether the device entity is writable (a command)
|
||||
// create the topic
|
||||
// depending on the type and whether the device entity is writable (a command)
|
||||
// https://developers.home-assistant.io/docs/core/entity
|
||||
char topic[MQTT_TOPIC_MAX_SIZE];
|
||||
// if it's a command then we can use Number, Switch, Select. Otherwise stick to Sensor
|
||||
// if it's a command then we can use Number, Switch, Select or Text. Otherwise stick to Sensor
|
||||
if (has_cmd) {
|
||||
switch (type) {
|
||||
case DeviceValueType::INT:
|
||||
@@ -877,6 +879,10 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
|
||||
set_ha_classes = true;
|
||||
break;
|
||||
case DeviceValueType::STRING:
|
||||
snprintf(topic, sizeof(topic), "text/%s", config_topic); // e.g. set_datetime, set_holiday, set_wwswitchtime
|
||||
set_ha_classes = true;
|
||||
break;
|
||||
default:
|
||||
// plain old sensor
|
||||
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
|
||||
@@ -910,12 +916,10 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
|
||||
char sample_val[30] = "0"; // sample, correct(!) entity value, used only to prevent warning/error in HA if real value is not published yet
|
||||
|
||||
// handle commands, which are device entities that are writable
|
||||
// we add the command topic parameter
|
||||
// note: there is no way to handle strings in HA so datetimes (e.g. set_datetime, set_holiday, set_wwswitchtime etc) are excluded
|
||||
// we add the command topic parameter for commands
|
||||
if (has_cmd) {
|
||||
// command topic back to EMS-ESP
|
||||
char command_topic[MQTT_TOPIC_MAX_SIZE];
|
||||
// add command topic
|
||||
if (tag >= DeviceValueTAG::TAG_HC1) {
|
||||
snprintf(command_topic, sizeof(command_topic), "%s/%s/%s/%s", mqtt_basename_.c_str(), device_name, EMSdevice::tag_to_mqtt(tag), entity);
|
||||
} else {
|
||||
@@ -923,7 +927,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
}
|
||||
doc["cmd_t"] = command_topic;
|
||||
|
||||
// for enums, add options
|
||||
// extend for enums, add options
|
||||
if (type == DeviceValueType::ENUM) {
|
||||
JsonArray option_list = doc.createNestedArray("ops"); // options
|
||||
if (EMSESP::system_.enum_format() == ENUM_FORMAT_INDEX) {
|
||||
@@ -941,7 +945,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
}
|
||||
|
||||
} else if (type != DeviceValueType::STRING && type != DeviceValueType::BOOL) {
|
||||
// Must be Numeric....
|
||||
// For numeric's add the range
|
||||
doc["mode"] = "box"; // auto, slider or box
|
||||
if (num_op > 0) {
|
||||
doc["step"] = 1.0 / num_op;
|
||||
@@ -1306,5 +1310,4 @@ void Mqtt::add_avty_to_doc(const char * state_t, const JsonObject & doc, const c
|
||||
doc["avty_mode"] = "all";
|
||||
}
|
||||
|
||||
|
||||
} // namespace emsesp
|
||||
} // namespace emsesp
|
||||
Reference in New Issue
Block a user