1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-29 22:24:26 +00:00

Merge branch 'integration' into memory_api

This commit is contained in:
J. Nick Koston
2025-10-16 16:31:27 -10:00
6 changed files with 23 additions and 5 deletions

View File

@@ -54,7 +54,7 @@ def check_max_runs(value):
if value[CONF_MODE] not in [CONF_QUEUED, CONF_PARALLEL]:
raise cv.Invalid(
"The option 'max_runs' is only valid in 'queue' and 'parallel' mode.",
"The option 'max_runs' is only valid in 'queued' and 'parallel' mode.",
path=[CONF_MAX_RUNS],
)

View File

@@ -1,5 +1,7 @@
#pragma once
#include <memory>
#include <tuple>
#include "esphome/core/automation.h"
#include "esphome/core/component.h"
#include "esphome/core/helpers.h"
@@ -137,6 +139,10 @@ template<typename... Ts> class QueueingScript : public Script<Ts...>, public Com
}
void stop() override {
// Clear all queued items to free memory immediately
for (int i = 0; i < this->max_runs_ - 1; i++) {
this->var_queue_[i].reset();
}
this->num_queued_ = 0;
this->queue_front_ = 0;
Script<Ts...>::stop();
@@ -144,11 +150,11 @@ template<typename... Ts> class QueueingScript : public Script<Ts...>, public Com
void loop() override {
if (this->num_queued_ != 0 && !this->is_action_running()) {
// Dequeue: decrement count, read from front, advance read position
// Dequeue: decrement count, move tuple out (frees slot), advance read position
this->num_queued_--;
auto &vars = *this->var_queue_[this->queue_front_];
auto tuple_ptr = std::move(this->var_queue_[this->queue_front_]);
this->queue_front_ = (this->queue_front_ + 1) % (this->max_runs_ - 1);
this->trigger_tuple_(vars, typename gens<sizeof...(Ts)>::type());
this->trigger_tuple_(*tuple_ptr, typename gens<sizeof...(Ts)>::type());
}
}

View File

@@ -696,6 +696,7 @@ CONF_OPEN_DRAIN = "open_drain"
CONF_OPEN_DRAIN_INTERRUPT = "open_drain_interrupt"
CONF_OPEN_DURATION = "open_duration"
CONF_OPEN_ENDSTOP = "open_endstop"
CONF_OPENTHREAD = "openthread"
CONF_OPERATION = "operation"
CONF_OPTIMISTIC = "optimistic"
CONF_OPTION = "option"

View File

@@ -11,6 +11,7 @@ from esphome.const import (
CONF_COMMENT,
CONF_ESPHOME,
CONF_ETHERNET,
CONF_OPENTHREAD,
CONF_PORT,
CONF_USE_ADDRESS,
CONF_WEB_SERVER,
@@ -641,6 +642,9 @@ class EsphomeCore:
if CONF_ETHERNET in self.config:
return self.config[CONF_ETHERNET][CONF_USE_ADDRESS]
if CONF_OPENTHREAD in self.config:
return f"{self.name}.local"
return None
@property

View File

@@ -135,7 +135,7 @@ async def test_script_queued(
api_client_connected() as client,
):
# Get services
entities, services = await client.list_entities_services()
_, services = await client.list_entities_services()
# Test 1: Queue depth limit
test_service = next((s for s in services if s.name == "test_queue_depth"), None)

View File

@@ -570,6 +570,13 @@ class TestEsphomeCore:
assert target.address == "4.3.2.1"
def test_address__openthread(self, target):
target.name = "test-device"
target.config = {}
target.config[const.CONF_OPENTHREAD] = {}
assert target.address == "test-device.local"
def test_is_esp32(self, target):
target.data[const.KEY_CORE] = {const.KEY_TARGET_PLATFORM: "esp32"}