mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-11 10:19:55 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
# Changelog
|
||||
|
||||
For more details go to [www.emsesp.org](https://www.emsesp.org/).
|
||||
|
||||
## [3.7.1]
|
||||
|
||||
## **IMPORTANT! BREAKING CHANGES with 3.7.0**
|
||||
|
||||
For more details go to [www.emsesp.org](https://www.emsesp.org/).
|
||||
|
||||
## Added
|
||||
|
||||
- Include HA "unit_of_meas", "stat_cla" and "dev_cla" attributes for Number sensors [#2149](https://github.com/emsesp/EMS-ESP32/issues/2149)
|
||||
|
||||
## Fixed
|
||||
|
||||
- Modbus integration in 3.7.0 missing offset [#2148](https://github.com/emsesp/EMS-ESP32/issues/2148)
|
||||
|
||||
## Changed
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# creates an CSV file called "dump_entities.cvs" with all devices and their entities
|
||||
# run from top folder like `sh ./scripts/dump_entities.sh`
|
||||
rm -f dump_entities.csv
|
||||
make clean
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py > dump_entities.csv
|
||||
cat dump_entities.csv
|
||||
@@ -1,9 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# creates an CSV file called "dump_telegrams.cvs" with all devices and their telegrams
|
||||
# run from top folder like `sh ./scripts/dump_telegrams.sh`
|
||||
rm -f dump_telegrams.csv
|
||||
make clean
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
echo "test telegram_dump" | ./emsesp | python3 ./scripts/strip_csv.py > dump_telegrams.csv
|
||||
cat dump_telegrams.csv
|
||||
@@ -1,7 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This is used to build the contents of the `Modbus-Entity-Registers.md` file used in the emsesp.org documentation.
|
||||
|
||||
make clean
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/generate-modbus-register-doc.py
|
||||
@@ -37,20 +37,24 @@ EOL
|
||||
make clean
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
|
||||
# dump_entities.csv
|
||||
rm -f dump_entities.csv
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py >dump_entities.csv
|
||||
ls -al dump_entities.csv
|
||||
|
||||
# dump_telegrams.csv
|
||||
rm -f dump_telegrams.csv
|
||||
echo "test telegram_dump" | ./emsesp | python3 ./scripts/strip_csv.py >dump_telegrams.csv
|
||||
ls -al dump_telegrams.csv
|
||||
|
||||
# generate ./src/modbus_entity_parameters.hpp
|
||||
# Generate Modbus entity parameters
|
||||
# One to build the modbus_entity_parameters.hpp header file
|
||||
# And then run entity_dump test again to create the dump_entities.csv file with the correct modbus counts
|
||||
rm -f ./src/modbus_entity_parameters.hpp
|
||||
cat dump_entities.csv | python3 ./scripts/update_modbus_registers.py >./src/modbus_entity_parameters.hpp
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/update_modbus_registers.py >./src/modbus_entity_parameters.hpp
|
||||
ls -al ./src/modbus_entity_parameters.hpp
|
||||
|
||||
# generate doc - Modbus-Entity-Registers.md used in the emsesp.org documentation.
|
||||
cat dump_entities.csv | python3 ./scripts/generate-modbus-register-doc.py >./docs/Modbus-Entity-Registers.md
|
||||
# dump_entities.csv
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
rm -f ./docs/dump_entities.csv
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py >./docs/dump_entities.csv
|
||||
ls -al ./docs/dump_entities.csv
|
||||
|
||||
# dump_telegrams.csv
|
||||
rm -f ./docs/dump_telegrams.csv
|
||||
echo "test telegram_dump" | ./emsesp | python3 ./scripts/strip_csv.py >./docs/dump_telegrams.csv
|
||||
ls -al ./docs/dump_telegrams.csv
|
||||
|
||||
# generate doc - Modbus-Entity-Registers.md used in the emsesp.org documentation
|
||||
rm -f ./docs/Modbus-Entity-Registers.md
|
||||
cat ./docs/dump_entities.csv | python3 ./scripts/generate-modbus-register-doc.py >./docs/Modbus-Entity-Registers.md
|
||||
|
||||
Binary file not shown.
@@ -1,64 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Update modbus parameters from entity definitions.
|
||||
# This script generates c++ code for the modbus parameter definitions.
|
||||
#
|
||||
# Run this script from the EMS-ESP32 root directory with the command `bash ./scripts/update_modbus_registers.sh`.
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--reset)
|
||||
RESET=YES
|
||||
shift
|
||||
;;
|
||||
--force)
|
||||
FORCE=YES
|
||||
shift
|
||||
;;
|
||||
* | -* | --*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$RESET" = "YES" ]; then
|
||||
if [ "$FORCE" != "YES" ]; then
|
||||
read -p "Are you sure you want to reset all modbus entity parameters, potentially generating new register mappings? WARNING: This might introduce breaking changes for end users. [yes/no] " CONFIRMATION
|
||||
if [ "$CONFIRMATION" != "yes" ]; then
|
||||
echo "Aborted."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "Resetting modbus configuration"
|
||||
cat >./src/modbus_entity_parameters.hpp <<EOL
|
||||
#include "modbus.h"
|
||||
#include "emsdevice.h"
|
||||
|
||||
/*
|
||||
* This file is auto-generated by the update_modbus_registers.sh script. Do not modify.
|
||||
*/
|
||||
|
||||
// clang-format off
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
using dt = EMSdevice::DeviceType;
|
||||
|
||||
#define REGISTER_MAPPING(device_type, device_value_tag_type, long_name, modbus_register_offset, modbus_register_count) \\
|
||||
{ device_type, device_value_tag_type, long_name[0], modbus_register_offset, modbus_register_count }
|
||||
|
||||
// IMPORTANT: This list MUST be ordered by keys "device_type", "device_value_tag_type" and "modbus_register_offset" in this order.
|
||||
const std::initializer_list<Modbus::EntityModbusInfo> Modbus::modbus_register_mappings = {};
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
// clang-format on
|
||||
|
||||
EOL
|
||||
fi
|
||||
|
||||
make clean
|
||||
make ARGS=-DEMSESP_STANDALONE
|
||||
echo "test entity_dump" | ./emsesp | python3 ./scripts/strip_csv.py | python3 ./scripts/update_modbus_registers.py >./src/modbus_entity_parameters.hpp
|
||||
echo "Modbus entity parameters written to ./src/modbus_entity_parameters.hpp."
|
||||
@@ -1982,9 +1982,14 @@ void EMSdevice::read_command(const uint16_t type_id, const uint8_t offset, const
|
||||
// returns either default or custom name
|
||||
std::string EMSdevice::name() {
|
||||
if (custom_name_.empty()) {
|
||||
return default_name_;
|
||||
// return default name prefixed with a model if exists
|
||||
if (model().empty()) {
|
||||
return default_name();
|
||||
}
|
||||
return model() + "/" + default_name();
|
||||
}
|
||||
return custom_name_;
|
||||
|
||||
return custom_name();
|
||||
}
|
||||
|
||||
// copy a raw value (i.e. without applying the numeric_operator) to the output buffer.
|
||||
|
||||
145
src/emsdevice.h
145
src/emsdevice.h
@@ -53,28 +53,48 @@ class EMSdevice {
|
||||
static uint8_t decode_brand(uint8_t value);
|
||||
static bool export_values(uint8_t device_type, JsonObject output, const int8_t id, const uint8_t output_target);
|
||||
|
||||
// non static
|
||||
// non static functions
|
||||
|
||||
const char * device_type_name(); // returns short non-translated device type name
|
||||
const char * device_type_2_device_name_translated(); // returns translated device type name
|
||||
bool has_tags(const int8_t tag) const;
|
||||
bool has_cmd(const char * cmd, const int8_t id) const;
|
||||
const char * brand_to_char();
|
||||
std::string to_string();
|
||||
std::string to_string_short();
|
||||
std::string name(); // returns either default or custom name of a device (if defined)
|
||||
|
||||
bool has_tags(const int8_t tag) const;
|
||||
bool has_cmd(const char * cmd, const int8_t id) const;
|
||||
bool is_device_id(uint8_t device_id) const {
|
||||
return ((device_id & 0x7F) == (device_id_ & 0x7F));
|
||||
}
|
||||
|
||||
inline uint8_t device_id() const {
|
||||
// Getters
|
||||
uint8_t device_id() const {
|
||||
return device_id_;
|
||||
}
|
||||
|
||||
inline uint8_t product_id() const {
|
||||
uint8_t product_id() const {
|
||||
return product_id_;
|
||||
}
|
||||
|
||||
void product_id(uint8_t product_id) {
|
||||
product_id_ = product_id;
|
||||
uint8_t device_type() const {
|
||||
return device_type_; // see enum DeviceType below
|
||||
}
|
||||
|
||||
inline bool is_device_id(uint8_t device_id) const {
|
||||
return ((device_id & 0x7F) == (device_id_ & 0x7F));
|
||||
const char * version() const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
uint8_t brand() const {
|
||||
return brand_;
|
||||
}
|
||||
|
||||
void active(bool active) {
|
||||
active_ = active;
|
||||
}
|
||||
|
||||
const char * default_name() const {
|
||||
return default_name_;
|
||||
}
|
||||
|
||||
// flags
|
||||
@@ -91,66 +111,46 @@ class EMSdevice {
|
||||
return flags_;
|
||||
}
|
||||
|
||||
inline uint8_t device_type() const {
|
||||
return device_type_; // see enum DeviceType below
|
||||
}
|
||||
|
||||
inline void version(const char * version) {
|
||||
strlcpy(version_, version, sizeof(version_));
|
||||
}
|
||||
|
||||
inline const char * version() const {
|
||||
return version_;
|
||||
}
|
||||
|
||||
inline void brand(uint8_t brand) {
|
||||
brand_ = brand;
|
||||
}
|
||||
|
||||
inline uint8_t brand() const {
|
||||
return brand_;
|
||||
}
|
||||
|
||||
inline void active(bool active) {
|
||||
active_ = active;
|
||||
}
|
||||
|
||||
// set custom device name
|
||||
inline void custom_name(std::string const & custom_name) {
|
||||
void custom_name(std::string const & custom_name) {
|
||||
custom_name_ = custom_name;
|
||||
}
|
||||
std::string name(); // returns either default or custom name if defined
|
||||
|
||||
// default name
|
||||
inline void default_name(const char * default_name) {
|
||||
default_name_ = default_name;
|
||||
std::string custom_name() const {
|
||||
return custom_name_;
|
||||
}
|
||||
inline const char * default_name() const {
|
||||
return default_name_;
|
||||
|
||||
// set device model
|
||||
void model(std::string const & model) {
|
||||
model_ = model;
|
||||
}
|
||||
|
||||
std::string model() const {
|
||||
return model_;
|
||||
}
|
||||
|
||||
inline uint8_t unique_id() const {
|
||||
return unique_id_;
|
||||
}
|
||||
|
||||
inline void unique_id(uint8_t unique_id) {
|
||||
void unique_id(uint8_t unique_id) {
|
||||
unique_id_ = unique_id;
|
||||
}
|
||||
|
||||
inline bool has_update() const {
|
||||
bool has_update() const {
|
||||
return has_update_;
|
||||
}
|
||||
|
||||
inline void has_update(bool flag) {
|
||||
void has_update(bool flag) {
|
||||
has_update_ = flag;
|
||||
}
|
||||
|
||||
inline void has_update(void * value) {
|
||||
void has_update(void * value) {
|
||||
has_update_ = true;
|
||||
publish_value(value);
|
||||
}
|
||||
|
||||
inline void has_update(char * value, const char * newvalue, size_t len) {
|
||||
void has_update(char * value, const char * newvalue, size_t len) {
|
||||
if (strcmp(value, newvalue) != 0) {
|
||||
strlcpy(value, newvalue, len);
|
||||
has_update_ = true;
|
||||
@@ -158,7 +158,7 @@ class EMSdevice {
|
||||
}
|
||||
}
|
||||
|
||||
inline void has_update(uint8_t & value, uint8_t newvalue) {
|
||||
void has_update(uint8_t & value, uint8_t newvalue) {
|
||||
if (value != newvalue) {
|
||||
value = newvalue;
|
||||
has_update_ = true;
|
||||
@@ -166,7 +166,7 @@ class EMSdevice {
|
||||
}
|
||||
}
|
||||
|
||||
inline void has_update(uint16_t & value, uint16_t newvalue) {
|
||||
void has_update(uint16_t & value, uint16_t newvalue) {
|
||||
if (value != newvalue) {
|
||||
value = newvalue;
|
||||
has_update_ = true;
|
||||
@@ -174,7 +174,7 @@ class EMSdevice {
|
||||
}
|
||||
}
|
||||
|
||||
inline void has_update(uint32_t & value, uint32_t newvalue) {
|
||||
void has_update(uint32_t & value, uint32_t newvalue) {
|
||||
if (value != newvalue) {
|
||||
value = newvalue;
|
||||
has_update_ = true;
|
||||
@@ -182,7 +182,7 @@ class EMSdevice {
|
||||
}
|
||||
}
|
||||
|
||||
inline void has_enumupdate(std::shared_ptr<const Telegram> telegram, uint8_t & value, const uint8_t index, int8_t s = 0) {
|
||||
void has_enumupdate(std::shared_ptr<const Telegram> telegram, uint8_t & value, const uint8_t index, int8_t s = 0) {
|
||||
if (telegram->read_enumvalue(value, index, s)) {
|
||||
has_update_ = true;
|
||||
publish_value((void *)&value);
|
||||
@@ -190,7 +190,7 @@ class EMSdevice {
|
||||
}
|
||||
|
||||
template <typename Value>
|
||||
inline void has_update(std::shared_ptr<const Telegram> telegram, Value & value, const uint8_t index, uint8_t s = 0) {
|
||||
void has_update(std::shared_ptr<const Telegram> telegram, Value & value, const uint8_t index, uint8_t s = 0) {
|
||||
if (telegram->read_value(value, index, s)) {
|
||||
has_update_ = true;
|
||||
publish_value((void *)&value);
|
||||
@@ -198,22 +198,18 @@ class EMSdevice {
|
||||
}
|
||||
|
||||
template <typename BitValue>
|
||||
inline void has_bitupdate(std::shared_ptr<const Telegram> telegram, BitValue & value, const uint8_t index, uint8_t b) {
|
||||
void has_bitupdate(std::shared_ptr<const Telegram> telegram, BitValue & value, const uint8_t index, uint8_t b) {
|
||||
if (telegram->read_bitvalue(value, index, b)) {
|
||||
has_update_ = true;
|
||||
publish_value((void *)&value);
|
||||
}
|
||||
}
|
||||
|
||||
// modbus
|
||||
int get_modbus_value(uint8_t tag, const std::string & shortname, std::vector<uint16_t> & result);
|
||||
int modbus_value_to_json(uint8_t tag, const std::string & shortname, const std::vector<uint8_t> & modbus_data, JsonObject jsonValue);
|
||||
|
||||
const char * brand_to_char();
|
||||
std::string to_string();
|
||||
std::string to_string_short();
|
||||
|
||||
enum Handlers : uint8_t { ALL, RECEIVED, FETCHED, PENDING, IGNORED };
|
||||
|
||||
void show_telegram_handlers(uuid::console::Shell & shell) const;
|
||||
char * show_telegram_handlers(char * result, const size_t len, const uint8_t handlers);
|
||||
void show_mqtt_handlers(uuid::console::Shell & shell) const;
|
||||
@@ -227,10 +223,9 @@ class EMSdevice {
|
||||
bool handle_telegram(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
std::string get_value_uom(const std::string & shortname) const;
|
||||
|
||||
bool get_value_info(JsonObject root, const char * cmd, const int8_t id);
|
||||
void get_value_json(JsonObject output, DeviceValue & dv);
|
||||
void get_dv_info(JsonObject json);
|
||||
bool get_value_info(JsonObject root, const char * cmd, const int8_t id);
|
||||
void get_value_json(JsonObject output, DeviceValue & dv);
|
||||
void get_dv_info(JsonObject json);
|
||||
|
||||
enum OUTPUT_TARGET : uint8_t { API_VERBOSE, API_SHORTNAMES, MQTT, CONSOLE };
|
||||
bool generate_values(JsonObject output, const int8_t tag_filter, const bool nested, const uint8_t output_target);
|
||||
@@ -314,23 +309,20 @@ class EMSdevice {
|
||||
|
||||
void read_command(const uint16_t type_id, uint8_t offset = 0, uint8_t length = 0) const;
|
||||
|
||||
bool is_readable(const void * value_p) const;
|
||||
bool is_readonly(const std::string & cmd, const int8_t id) 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_all_values();
|
||||
|
||||
void mqtt_ha_entity_config_create();
|
||||
|
||||
bool is_readable(const void * value_p) const;
|
||||
bool is_readonly(const std::string & cmd, const int8_t id) 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_all_values();
|
||||
void mqtt_ha_entity_config_create();
|
||||
const char * telegram_type_name(std::shared_ptr<const Telegram> telegram);
|
||||
|
||||
void fetch_values();
|
||||
void toggle_fetch(uint16_t telegram_id, bool toggle);
|
||||
bool is_fetch(uint16_t telegram_id) const;
|
||||
bool is_received(uint16_t telegram_id) const;
|
||||
bool has_telegram_id(uint16_t id) const;
|
||||
void ha_config_clear();
|
||||
void fetch_values();
|
||||
void toggle_fetch(uint16_t telegram_id, bool toggle);
|
||||
bool is_fetch(uint16_t telegram_id) const;
|
||||
bool is_received(uint16_t telegram_id) const;
|
||||
bool has_telegram_id(uint16_t id) const;
|
||||
void ha_config_clear();
|
||||
|
||||
bool ha_config_done() const {
|
||||
return ha_config_done_;
|
||||
@@ -502,6 +494,7 @@ class EMSdevice {
|
||||
char version_[6];
|
||||
const char * default_name_; // the fixed name the EMS model taken from the device library
|
||||
std::string custom_name_ = ""; // custom name
|
||||
std::string model_ = ""; // model, taken from the 0x01 telegram. see process_deviceName()
|
||||
uint8_t flags_ = 0;
|
||||
uint8_t brand_ = Brand::NO_BRAND;
|
||||
bool active_ = true;
|
||||
|
||||
@@ -972,14 +972,13 @@ void EMSESP::process_deviceName(std::shared_ptr<const Telegram> telegram) {
|
||||
uint8_t len = telegram->offset + telegram->message_length - 27;
|
||||
strlcpy(name, (const char *)&telegram->message_data[27 - telegram->offset], len < 16 ? len : 16);
|
||||
if (strlen(name)) {
|
||||
webCustomizationService.read([&](WebCustomization const & settings) {
|
||||
for (EntityCustomization e : settings.entityCustomizations) {
|
||||
if ((e.device_id == telegram->src) && e.custom_name.empty()) {
|
||||
e.custom_name = name;
|
||||
break;
|
||||
}
|
||||
LOG_DEBUG("Model name received for device 0x%02X: %s", telegram->src, name);
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice->is_device_id(telegram->src)) {
|
||||
emsdevice->model(name);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1204,8 +1203,8 @@ void EMSESP::show_devices(uuid::console::Shell & shell) {
|
||||
for (const auto & device_class : EMSFactory::device_handlers()) {
|
||||
for (const auto & emsdevice : emsdevices) {
|
||||
if (emsdevice && (emsdevice->device_type() == device_class.first)) {
|
||||
shell.printf("%s: %s", emsdevice->device_type_name(), emsdevice->to_string().c_str());
|
||||
shell.println();
|
||||
// print header, with device type translated
|
||||
shell.printfln("%s: %s (%d)", emsdevice->device_type_2_device_name_translated(), emsdevice->to_string().c_str(), emsdevice->count_entities());
|
||||
emsdevice->show_telegram_handlers(shell);
|
||||
|
||||
#if defined(EMSESP_DEBUG)
|
||||
|
||||
23
src/mqtt.cpp
23
src/mqtt.cpp
@@ -934,7 +934,7 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
char config_topic[70];
|
||||
snprintf(config_topic, sizeof(config_topic), "%s/%s_%s/config", mqtt_basename_.c_str(), device_name, entity_with_tag);
|
||||
|
||||
bool readonly_sensors = true;
|
||||
bool add_ha_classes = true; // default we'll add the "unit_of_meas", "stat_cla" and "dev_cla" attributes
|
||||
|
||||
// create the topic
|
||||
// depending on the type and whether the device entity is writable (a command)
|
||||
@@ -953,7 +953,6 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
// older Domoticz does not support number, use sensor
|
||||
if (discovery_type() == discoveryType::HOMEASSISTANT || discovery_type() == discoveryType::DOMOTICZ_LATEST) {
|
||||
snprintf(topic, sizeof(topic), "number/%s", config_topic);
|
||||
readonly_sensors = false;
|
||||
} else {
|
||||
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
|
||||
}
|
||||
@@ -961,11 +960,11 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
case DeviceValueType::BOOL:
|
||||
// switch - https://www.home-assistant.io/integrations/switch.mqtt
|
||||
snprintf(topic, sizeof(topic), "switch/%s", config_topic);
|
||||
readonly_sensors = false;
|
||||
add_ha_classes = false;
|
||||
break;
|
||||
case DeviceValueType::ENUM:
|
||||
snprintf(topic, sizeof(topic), "select/%s", config_topic);
|
||||
readonly_sensors = false;
|
||||
add_ha_classes = false;
|
||||
break;
|
||||
case DeviceValueType::CMD: // hardcoded commands are always ENUMS
|
||||
// select - https://www.home-assistant.io/integrations/select.mqtt
|
||||
@@ -976,22 +975,19 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
} else {
|
||||
snprintf(topic, sizeof(topic), "sensor/%s", config_topic);
|
||||
}
|
||||
readonly_sensors = false;
|
||||
add_ha_classes = false;
|
||||
break;
|
||||
case DeviceValueType::STRING:
|
||||
// text - https://www.home-assistant.io/integrations/text.mqtt
|
||||
snprintf(topic, sizeof(topic), "text/%s", config_topic); // e.g. set_datetime, set_holiday, set_wwswitchtime
|
||||
readonly_sensors = false;
|
||||
add_ha_classes = false;
|
||||
break;
|
||||
default:
|
||||
// plain old sensor, and make it read-only
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// For read-only sensors there are either sensor or binary_sensor
|
||||
// for both we also set the device class and state class
|
||||
if (readonly_sensors) {
|
||||
} else {
|
||||
// it is not a command and a read-only sensor. Use then either sensor or binary_sensor
|
||||
snprintf(topic, sizeof(topic), (type == DeviceValueType::BOOL) ? "binary_sensor/%s" : "sensor/%s", config_topic); // binary sensor (for booleans)
|
||||
}
|
||||
|
||||
@@ -1127,8 +1123,9 @@ bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdev
|
||||
add_ha_sections_to_doc(nullptr, stat_t, doc, false, val_cond); // no name, since the "dev" has already been adde
|
||||
}
|
||||
|
||||
// Add the state class, device class and sometimes the icon. Used only for read-only sensors like Sensor and Binary Sensor
|
||||
if (readonly_sensors) {
|
||||
// Add the state class, device class and sometimes the icon.
|
||||
// Used only for read-only sensors like Sensor and Binary Sensor but also Numbers
|
||||
if (add_ha_classes) {
|
||||
// first set the catagory for System entities
|
||||
// https://github.com/emsesp/EMS-ESP32/discussions/1459#discussioncomment-7694873
|
||||
if (device_type == EMSdevice::DeviceType::SYSTEM) {
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define EMSESP_APP_VERSION "3.7.1-dev.0"
|
||||
#define EMSESP_APP_VERSION "3.7.1-dev.1"
|
||||
Reference in New Issue
Block a user