mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-09 17:29:50 +03:00
Merge branch 'dev' of https://github.com/emsesp/EMS-ESP32 into dev2
This commit is contained in:
@@ -31,7 +31,7 @@ void AnalogSensor::start() {
|
||||
}
|
||||
analogSetAttenuation(ADC_2_5db); // for all channels 1.5V
|
||||
|
||||
LOG_INFO("Starting Analog sensor service");
|
||||
LOG_INFO("Starting Analog Sensor service");
|
||||
|
||||
// Add API calls
|
||||
Command::add(
|
||||
|
||||
@@ -515,7 +515,7 @@ void EMSdevice::add_device_value(uint8_t tag, // to b
|
||||
uint32_t max // max allowed value
|
||||
) {
|
||||
// initialize the device value depending on it's type
|
||||
// ignoring DeviceValueType::CMD and DeviceValueType::TIME
|
||||
// ignoring DeviceValueType::CMD
|
||||
|
||||
if (type == DeviceValueType::STRING) {
|
||||
*(char *)(value_p) = {'\0'}; // this is important for string functions like strlen() to work later
|
||||
|
||||
28
src/mqtt.cpp
28
src/mqtt.cpp
@@ -803,20 +803,20 @@ bool Mqtt::publish_system_ha_sensor_config(uint8_t type, const char * name, cons
|
||||
// MQTT discovery configs
|
||||
// entity must match the key/value pair in the *_data topic
|
||||
// note: some extra string copying done here, it looks messy but does help with heap fragmentation issues
|
||||
bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice::DeviceValueType
|
||||
uint8_t tag, // EMSdevice::DeviceValueTAG
|
||||
const char * const fullname, // fullname, already translated
|
||||
const char * const en_name, // original name in english
|
||||
const uint8_t device_type, // EMSdevice::DeviceType
|
||||
const char * const entity, // same as shortname
|
||||
const uint8_t uom, // EMSdevice::DeviceValueUOM (0=NONE)
|
||||
const bool remove, // true if we want to remove this topic
|
||||
const bool has_cmd,
|
||||
const char * const ** options,
|
||||
uint8_t options_size,
|
||||
const int16_t dv_set_min,
|
||||
const uint32_t dv_set_max,
|
||||
const int8_t num_op,
|
||||
bool Mqtt::publish_ha_sensor_config(uint8_t type, // EMSdevice::DeviceValueType
|
||||
uint8_t tag, // EMSdevice::DeviceValueTAG
|
||||
const char * const fullname, // fullname, already translated
|
||||
const char * const en_name, // original name in english
|
||||
const uint8_t device_type, // EMSdevice::DeviceType
|
||||
const char * const entity, // same as shortname
|
||||
const uint8_t uom, // EMSdevice::DeviceValueUOM (0=NONE)
|
||||
const bool remove, // true if we want to remove this topic
|
||||
const bool has_cmd,
|
||||
const char * const ** options,
|
||||
uint8_t options_size,
|
||||
const int16_t dv_set_min,
|
||||
const uint32_t dv_set_max,
|
||||
const int8_t num_op,
|
||||
const JsonObjectConst dev_json) {
|
||||
// ignore if name (fullname) is empty
|
||||
if (!fullname || !en_name) {
|
||||
|
||||
@@ -42,7 +42,7 @@ void TemperatureSensor::start() {
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
bus_.begin(dallas_gpio_);
|
||||
LOG_INFO("Starting Temperature sensor service");
|
||||
LOG_INFO("Starting Temperature Sensor service");
|
||||
#endif
|
||||
|
||||
char topic[Mqtt::MQTT_TOPIC_MAX_SIZE];
|
||||
|
||||
@@ -332,7 +332,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
||||
ok = true;
|
||||
}
|
||||
|
||||
if (command == "custom_entities") {
|
||||
if (command == "custom") {
|
||||
shell.printfln("Adding custom entities...");
|
||||
|
||||
// add some dummy entities
|
||||
|
||||
@@ -27,8 +27,6 @@
|
||||
|
||||
namespace emsesp {
|
||||
|
||||
// #define EMSESP_DEBUG_DEFAULT "general"
|
||||
|
||||
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
||||
// #define EMSESP_DEBUG_DEFAULT "solar"
|
||||
// #define EMSESP_DEBUG_DEFAULT "web"
|
||||
@@ -48,7 +46,7 @@ namespace emsesp {
|
||||
// #define EMSESP_DEBUG_DEFAULT "lastcode"
|
||||
// #define EMSESP_DEBUG_DEFAULT "2thermostats"
|
||||
// #define EMSESP_DEBUG_DEFAULT "temperature"
|
||||
#define EMSESP_DEBUG_DEFAULT "analog"
|
||||
// #define EMSESP_DEBUG_DEFAULT "analog"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api_values"
|
||||
// #define EMSESP_DEBUG_DEFAULT "mqtt_post"
|
||||
// #define EMSESP_DEBUG_DEFAULT "api_wwmode"
|
||||
@@ -56,10 +54,14 @@ namespace emsesp {
|
||||
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
|
||||
// #define EMSESP_DEBUG_DEFAULT "memory"
|
||||
// #define EMSESP_DEBUG_DEFAULT "coldshot"
|
||||
// #define EMSESP_DEBUG_DEFAULT "custom_entities"
|
||||
// #define EMSESP_DEBUG_DEFAULT "custom"
|
||||
// #define EMSESP_DEBUG_DEFAULT "scheduler"
|
||||
// #define EMSESP_DEBUG_DEFAULT "heat_exchange"
|
||||
|
||||
#ifndef EMSESP_DEBUG_DEFAULT
|
||||
#define EMSESP_DEBUG_DEFAULT "general"
|
||||
#endif
|
||||
|
||||
class Test {
|
||||
public:
|
||||
static void run_test(uuid::console::Shell & shell, const std::string & command, const std::string & id1 = "", const std::string & id2 = "");
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define EMSESP_APP_VERSION "3.6.5-test.11"
|
||||
#define EMSESP_APP_VERSION "3.6.5-test.12"
|
||||
|
||||
@@ -293,10 +293,11 @@ bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd)
|
||||
for (const auto & entity : *customEntityItems) {
|
||||
if (Helpers::toLower(entity.name) == Helpers::toLower(command_s)) {
|
||||
output["name"] = entity.name;
|
||||
output["ram"] = entity.ram;
|
||||
output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number);
|
||||
if (entity.uom > 0) {
|
||||
output["uom"] = EMSdevice::uom_to_string(entity.uom);
|
||||
}
|
||||
output["type"] = entity.value_type == DeviceValueType::BOOL ? "boolean" : entity.value_type == DeviceValueType::STRING ? "string" : F_(number);
|
||||
output["readable"] = true;
|
||||
output["writeable"] = entity.writeable;
|
||||
output["visible"] = true;
|
||||
@@ -311,6 +312,7 @@ bool WebCustomEntityService::get_value_info(JsonObject output, const char * cmd)
|
||||
}
|
||||
}
|
||||
render_value(output, entity, true);
|
||||
|
||||
if (attribute_s) {
|
||||
if (output.containsKey(attribute_s)) {
|
||||
String data = output[attribute_s].as<String>();
|
||||
|
||||
@@ -43,7 +43,8 @@ class CustomEntityItem {
|
||||
|
||||
class WebCustomEntity {
|
||||
public:
|
||||
std::list<CustomEntityItem> customEntityItems;
|
||||
std::vector<CustomEntityItem> customEntityItems;
|
||||
// std::list<CustomEntityItem> customEntityItems;
|
||||
|
||||
static void read(WebCustomEntity & webEntity, JsonObject root);
|
||||
static StateUpdateResult update(JsonObject root, WebCustomEntity & webEntity);
|
||||
@@ -78,8 +79,10 @@ class WebCustomEntityService : public StatefulService<WebCustomEntity> {
|
||||
HttpEndpoint<WebCustomEntity> _httpEndpoint;
|
||||
FSPersistence<WebCustomEntity> _fsPersistence;
|
||||
|
||||
std::list<CustomEntityItem> * customEntityItems; // pointer to the list of entity items
|
||||
bool ha_registered_ = false;
|
||||
std::vector<CustomEntityItem> * customEntityItems; // pointer to the list of entity items
|
||||
// std::list<CustomEntityItem> * customEntityItems; // pointer to the list of entity items
|
||||
|
||||
bool ha_registered_ = false;
|
||||
};
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
@@ -347,7 +347,9 @@ bool WebSchedulerService::command(const char * cmd, const char * data) {
|
||||
uint8_t return_code = Command::process(command_str, true, input, output); // admin set
|
||||
|
||||
if (return_code == CommandRet::OK) {
|
||||
EMSESP::logger().debug("Scheduled command %s with data %s successfully", cmd, data);
|
||||
#if defined(EMSESP_DEBUG)
|
||||
EMSESP::logger().debug("Scheduled command '%s' with data '%s' was successful", cmd, data);
|
||||
#endif
|
||||
if (strlen(data) == 0 && output.size()) {
|
||||
Mqtt::queue_publish("response", output);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user