mirror of
https://github.com/esphome/esphome.git
synced 2025-07-29 14:46:40 +00:00
Merge remote-tracking branch 'upstream/api_heap_churn_info' into api_heap_churn_info
This commit is contained in:
commit
20294e9307
@ -52,7 +52,7 @@ void GPS::update() {
|
||||
void GPS::loop() {
|
||||
while (this->available() > 0 && !this->has_time_) {
|
||||
if (!this->tiny_gps_.encode(this->read())) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (this->tiny_gps_.location.isUpdated()) {
|
||||
this->latitude_ = this->tiny_gps_.location.lat();
|
||||
|
@ -127,5 +127,5 @@ async def to_code(config):
|
||||
cg.add(var.set_min_temperature(config[CONF_MIN_TEMPERATURE]))
|
||||
|
||||
cg.add_library("tonia/HeatpumpIR", "1.0.37")
|
||||
if CORE.is_libretiny:
|
||||
if CORE.is_libretiny or CORE.is_esp32:
|
||||
CORE.add_platformio_option("lib_ignore", "IRremoteESP8266")
|
||||
|
@ -1,6 +1,9 @@
|
||||
#include "esphome/core/defines.h"
|
||||
#ifdef USE_OPENTHREAD
|
||||
#include "openthread.h"
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
||||
#include "esp_openthread.h"
|
||||
#endif
|
||||
|
||||
#include <freertos/portmacro.h>
|
||||
|
||||
@ -28,18 +31,6 @@ OpenThreadComponent *global_openthread_component = // NOLINT(cppcoreguidelines-
|
||||
|
||||
OpenThreadComponent::OpenThreadComponent() { global_openthread_component = this; }
|
||||
|
||||
OpenThreadComponent::~OpenThreadComponent() {
|
||||
auto lock = InstanceLock::try_acquire(100);
|
||||
if (!lock) {
|
||||
ESP_LOGW(TAG, "Failed to acquire OpenThread lock in destructor, leaking memory");
|
||||
return;
|
||||
}
|
||||
otInstance *instance = lock->get_instance();
|
||||
otSrpClientClearHostAndServices(instance);
|
||||
otSrpClientBuffersFreeAllServices(instance);
|
||||
global_openthread_component = nullptr;
|
||||
}
|
||||
|
||||
bool OpenThreadComponent::is_connected() {
|
||||
auto lock = InstanceLock::try_acquire(100);
|
||||
if (!lock) {
|
||||
@ -199,6 +190,33 @@ void *OpenThreadSrpComponent::pool_alloc_(size_t size) {
|
||||
|
||||
void OpenThreadSrpComponent::set_mdns(esphome::mdns::MDNSComponent *mdns) { this->mdns_ = mdns; }
|
||||
|
||||
bool OpenThreadComponent::teardown() {
|
||||
if (!this->teardown_started_) {
|
||||
this->teardown_started_ = true;
|
||||
ESP_LOGD(TAG, "Clear Srp");
|
||||
auto lock = InstanceLock::try_acquire(100);
|
||||
if (!lock) {
|
||||
ESP_LOGW(TAG, "Failed to acquire OpenThread lock during teardown, leaking memory");
|
||||
return true;
|
||||
}
|
||||
otInstance *instance = lock->get_instance();
|
||||
otSrpClientClearHostAndServices(instance);
|
||||
otSrpClientBuffersFreeAllServices(instance);
|
||||
global_openthread_component = nullptr;
|
||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
||||
ESP_LOGD(TAG, "Exit main loop ");
|
||||
int error = esp_openthread_mainloop_exit();
|
||||
if (error != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Failed attempt to stop main loop %d", error);
|
||||
this->teardown_complete_ = true;
|
||||
}
|
||||
#else
|
||||
this->teardown_complete_ = true;
|
||||
#endif
|
||||
}
|
||||
return this->teardown_complete_;
|
||||
}
|
||||
|
||||
} // namespace openthread
|
||||
} // namespace esphome
|
||||
|
||||
|
@ -21,6 +21,7 @@ class OpenThreadComponent : public Component {
|
||||
OpenThreadComponent();
|
||||
~OpenThreadComponent();
|
||||
void setup() override;
|
||||
bool teardown() override;
|
||||
float get_setup_priority() const override { return setup_priority::WIFI; }
|
||||
|
||||
bool is_connected();
|
||||
@ -30,6 +31,8 @@ class OpenThreadComponent : public Component {
|
||||
|
||||
protected:
|
||||
std::optional<otIp6Address> get_omr_address_(InstanceLock &lock);
|
||||
bool teardown_started_{false};
|
||||
bool teardown_complete_{false};
|
||||
};
|
||||
|
||||
extern OpenThreadComponent *global_openthread_component; // NOLINT(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
|
@ -143,10 +143,13 @@ void OpenThreadComponent::ot_main() {
|
||||
esp_openthread_launch_mainloop();
|
||||
|
||||
// Clean up
|
||||
esp_openthread_deinit();
|
||||
esp_openthread_netif_glue_deinit();
|
||||
esp_netif_destroy(openthread_netif);
|
||||
|
||||
esp_vfs_eventfd_unregister();
|
||||
this->teardown_complete_ = true;
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
network::IPAddresses OpenThreadComponent::get_ip_addresses() {
|
||||
|
@ -43,6 +43,8 @@ FloatOutputPtr = FloatOutput.operator("ptr")
|
||||
TurnOffAction = output_ns.class_("TurnOffAction", automation.Action)
|
||||
TurnOnAction = output_ns.class_("TurnOnAction", automation.Action)
|
||||
SetLevelAction = output_ns.class_("SetLevelAction", automation.Action)
|
||||
SetMinPowerAction = output_ns.class_("SetMinPowerAction", automation.Action)
|
||||
SetMaxPowerAction = output_ns.class_("SetMaxPowerAction", automation.Action)
|
||||
|
||||
|
||||
async def setup_output_platform_(obj, config):
|
||||
@ -104,6 +106,42 @@ async def output_set_level_to_code(config, action_id, template_arg, args):
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"output.set_min_power",
|
||||
SetMinPowerAction,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.use_id(FloatOutput),
|
||||
cv.Required(CONF_MIN_POWER): cv.templatable(cv.percentage),
|
||||
}
|
||||
),
|
||||
)
|
||||
async def output_set_min_power_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_MIN_POWER], args, float)
|
||||
cg.add(var.set_min_power(template_))
|
||||
return var
|
||||
|
||||
|
||||
@automation.register_action(
|
||||
"output.set_max_power",
|
||||
SetMaxPowerAction,
|
||||
cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_ID): cv.use_id(FloatOutput),
|
||||
cv.Required(CONF_MAX_POWER): cv.templatable(cv.percentage),
|
||||
}
|
||||
),
|
||||
)
|
||||
async def output_set_max_power_to_code(config, action_id, template_arg, args):
|
||||
paren = await cg.get_variable(config[CONF_ID])
|
||||
var = cg.new_Pvariable(action_id, template_arg, paren)
|
||||
template_ = await cg.templatable(config[CONF_MAX_POWER], args, float)
|
||||
cg.add(var.set_max_power(template_))
|
||||
return var
|
||||
|
||||
|
||||
async def to_code(config):
|
||||
cg.add_define("USE_OUTPUT")
|
||||
cg.add_global(output_ns.using)
|
||||
|
@ -40,5 +40,29 @@ template<typename... Ts> class SetLevelAction : public Action<Ts...> {
|
||||
FloatOutput *output_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class SetMinPowerAction : public Action<Ts...> {
|
||||
public:
|
||||
SetMinPowerAction(FloatOutput *output) : output_(output) {}
|
||||
|
||||
TEMPLATABLE_VALUE(float, min_power)
|
||||
|
||||
void play(Ts... x) override { this->output_->set_min_power(this->min_power_.value(x...)); }
|
||||
|
||||
protected:
|
||||
FloatOutput *output_;
|
||||
};
|
||||
|
||||
template<typename... Ts> class SetMaxPowerAction : public Action<Ts...> {
|
||||
public:
|
||||
SetMaxPowerAction(FloatOutput *output) : output_(output) {}
|
||||
|
||||
TEMPLATABLE_VALUE(float, max_power)
|
||||
|
||||
void play(Ts... x) override { this->output_->set_max_power(this->max_power_.value(x...)); }
|
||||
|
||||
protected:
|
||||
FloatOutput *output_;
|
||||
};
|
||||
|
||||
} // namespace output
|
||||
} // namespace esphome
|
||||
|
@ -6,6 +6,12 @@ esphome:
|
||||
- output.set_level:
|
||||
id: light_output_1
|
||||
level: 50%
|
||||
- output.set_min_power:
|
||||
id: light_output_1
|
||||
min_power: 20%
|
||||
- output.set_max_power:
|
||||
id: light_output_1
|
||||
max_power: 80%
|
||||
|
||||
output:
|
||||
- platform: ${output_platform}
|
||||
|
Loading…
x
Reference in New Issue
Block a user