[api] Store Home Assistant state subscriptions in flash instead of heap (#12008)

This commit is contained in:
J. Nick Koston
2025-12-09 16:26:11 +01:00
committed by GitHub
parent 443f9c3f57
commit 72c74bc0b3
17 changed files with 144 additions and 72 deletions

View File

@@ -38,6 +38,7 @@ async def test_api_custom_services(
custom_service_future = loop.create_future()
custom_args_future = loop.create_future()
custom_arrays_future = loop.create_future()
ha_state_future = loop.create_future()
# Patterns to match in logs
yaml_service_pattern = re.compile(r"YAML service called")
@@ -50,6 +51,9 @@ async def test_api_custom_services(
custom_arrays_pattern = re.compile(
r"Array service called with 2 bools, 3 ints, 2 floats, 2 strings"
)
ha_state_pattern = re.compile(
r"This subscription uses std::string API for backward compatibility"
)
def check_output(line: str) -> None:
"""Check log output for expected messages."""
@@ -65,6 +69,8 @@ async def test_api_custom_services(
custom_args_future.set_result(True)
elif not custom_arrays_future.done() and custom_arrays_pattern.search(line):
custom_arrays_future.set_result(True)
elif not ha_state_future.done() and ha_state_pattern.search(line):
ha_state_future.set_result(True)
# Run with log monitoring
async with (
@@ -198,3 +204,8 @@ async def test_api_custom_services(
},
)
await asyncio.wait_for(custom_arrays_future, timeout=5.0)
# Test Home Assistant state subscription (std::string API backward compatibility)
# This verifies that custom_api_device.h can still use std::string overloads
client.send_home_assistant_state("sensor.custom_test", "", "42.5")
await asyncio.wait_for(ha_state_future, timeout=5.0)