Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-11-29 18:36:33 -06:00
10 changed files with 33 additions and 45 deletions
+2 -4
View File
@@ -3,8 +3,7 @@
#include "esphome/core/automation.h"
#include "climate.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
template<typename... Ts> class ControlAction : public Action<Ts...> {
public:
@@ -58,5 +57,4 @@ class StateTrigger : public Trigger<Climate &> {
}
};
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+2 -4
View File
@@ -3,8 +3,7 @@
#include "esphome/core/controller_registry.h"
#include "esphome/core/macros.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
static const char *const TAG = "climate";
@@ -762,5 +761,4 @@ void Climate::dump_traits_(const char *tag) {
}
}
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+2 -4
View File
@@ -8,8 +8,7 @@
#include "climate_mode.h"
#include "climate_traits.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
#define LOG_CLIMATE(prefix, type, obj) \
if ((obj) != nullptr) { \
@@ -345,5 +344,4 @@ class Climate : public EntityBase {
const char *custom_preset_{nullptr};
};
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+2 -4
View File
@@ -1,7 +1,6 @@
#include "climate_mode.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
const LogString *climate_mode_to_string(ClimateMode mode) {
switch (mode) {
@@ -107,5 +106,4 @@ const LogString *climate_preset_to_string(ClimatePreset preset) {
}
}
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+2 -4
View File
@@ -3,8 +3,7 @@
#include <cstdint>
#include "esphome/core/log.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
/// Enum for all modes a climate device can be in.
/// NOTE: If adding values, update ClimateModeMask in climate_traits.h to use the new last value
@@ -132,5 +131,4 @@ const LogString *climate_swing_mode_to_string(ClimateSwingMode mode);
/// Convert the given PresetMode to a human-readable string.
const LogString *climate_preset_to_string(ClimatePreset preset);
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
@@ -1,7 +1,6 @@
#include "climate_traits.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
int8_t ClimateTraits::get_target_temperature_accuracy_decimals() const {
return step_to_accuracy_decimals(this->visual_target_temperature_step_);
@@ -11,5 +10,4 @@ int8_t ClimateTraits::get_current_temperature_accuracy_decimals() const {
return step_to_accuracy_decimals(this->visual_current_temperature_step_);
}
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+2 -4
View File
@@ -6,8 +6,7 @@
#include "esphome/core/finite_set_mask.h"
#include "esphome/core/helpers.h"
namespace esphome {
namespace climate {
namespace esphome::climate {
// Type aliases for climate enum bitmasks
// These replace std::set<EnumType> to eliminate red-black tree overhead
@@ -292,5 +291,4 @@ class ClimateTraits {
std::vector<const char *> supported_custom_presets_;
};
} // namespace climate
} // namespace esphome
} // namespace esphome::climate
+11 -11
View File
@@ -13,25 +13,25 @@ static const char *const TAG = "cover";
const float COVER_OPEN = 1.0f;
const float COVER_CLOSED = 0.0f;
const char *cover_command_to_str(float pos) {
const LogString *cover_command_to_str(float pos) {
if (pos == COVER_OPEN) {
return "OPEN";
return LOG_STR("OPEN");
} else if (pos == COVER_CLOSED) {
return "CLOSE";
return LOG_STR("CLOSE");
} else {
return "UNKNOWN";
return LOG_STR("UNKNOWN");
}
}
const char *cover_operation_to_str(CoverOperation op) {
const LogString *cover_operation_to_str(CoverOperation op) {
switch (op) {
case COVER_OPERATION_IDLE:
return "IDLE";
return LOG_STR("IDLE");
case COVER_OPERATION_OPENING:
return "OPENING";
return LOG_STR("OPENING");
case COVER_OPERATION_CLOSING:
return "CLOSING";
return LOG_STR("CLOSING");
default:
return "UNKNOWN";
return LOG_STR("UNKNOWN");
}
}
@@ -87,7 +87,7 @@ void CoverCall::perform() {
if (traits.get_supports_position()) {
ESP_LOGD(TAG, " Position: %.0f%%", *this->position_ * 100.0f);
} else {
ESP_LOGD(TAG, " Command: %s", cover_command_to_str(*this->position_));
ESP_LOGD(TAG, " Command: %s", LOG_STR_ARG(cover_command_to_str(*this->position_)));
}
}
if (this->tilt_.has_value()) {
@@ -169,7 +169,7 @@ void Cover::publish_state(bool save) {
if (traits.get_supports_tilt()) {
ESP_LOGD(TAG, " Tilt: %.0f%%", this->tilt * 100.0f);
}
ESP_LOGD(TAG, " Current Operation: %s", cover_operation_to_str(this->current_operation));
ESP_LOGD(TAG, " Current Operation: %s", LOG_STR_ARG(cover_operation_to_str(this->current_operation)));
this->state_callback_.call();
#if defined(USE_COVER) && defined(USE_CONTROLLER_REGISTRY)
+2 -1
View File
@@ -3,6 +3,7 @@
#include "esphome/core/component.h"
#include "esphome/core/entity_base.h"
#include "esphome/core/helpers.h"
#include "esphome/core/log.h"
#include "esphome/core/preferences.h"
#include "cover_traits.h"
@@ -86,7 +87,7 @@ enum CoverOperation : uint8_t {
COVER_OPERATION_CLOSING,
};
const char *cover_operation_to_str(CoverOperation op);
const LogString *cover_operation_to_str(CoverOperation op);
/** Base class for all cover devices.
*
+6 -5
View File
@@ -41,6 +41,10 @@ namespace web_server {
static const char *const TAG = "web_server";
// Longest: HORIZONTAL (10 chars + null terminator, rounded up)
static constexpr size_t PSTR_LOCAL_SIZE = 16;
#define PSTR_LOCAL(mode_s) ESPHOME_strncpy_P(buf, (ESPHOME_PGM_P) ((mode_s)), PSTR_LOCAL_SIZE - 1)
#ifdef USE_WEBSERVER_PRIVATE_NETWORK_ACCESS
static const char *const HEADER_PNA_NAME = "Private-Network-Access-Name";
static const char *const HEADER_PNA_ID = "Private-Network-Access-ID";
@@ -908,7 +912,8 @@ std::string WebServer::cover_json(cover::Cover *obj, JsonDetail start_config) {
set_json_icon_state_value(root, obj, "cover", obj->is_fully_closed() ? "CLOSED" : "OPEN", obj->position,
start_config);
root["current_operation"] = cover::cover_operation_to_str(obj->current_operation);
char buf[PSTR_LOCAL_SIZE];
root["current_operation"] = PSTR_LOCAL(cover::cover_operation_to_str(obj->current_operation));
if (obj->get_traits().get_supports_position())
root["position"] = obj->position;
@@ -1272,10 +1277,6 @@ std::string WebServer::select_json(select::Select *obj, const char *value, JsonD
}
#endif
// Longest: HORIZONTAL (10 chars + null terminator, rounded up)
static constexpr size_t PSTR_LOCAL_SIZE = 16;
#define PSTR_LOCAL(mode_s) ESPHOME_strncpy_P(buf, (ESPHOME_PGM_P) ((mode_s)), PSTR_LOCAL_SIZE - 1)
#ifdef USE_CLIMATE
void WebServer::on_climate_update(climate::Climate *obj) {
if (!this->include_internal_ && obj->is_internal())