Commit Graph
28019 Commits
Author SHA1 Message Date
J. Nick Koston 096721f1d5 Merge remote-tracking branch 'upstream/templatable-int-fix' into integration 2026-04-26 04:25:17 -05:00
J. Nick Koston bd1dd68d6b [rotary_encoder][at581x] Fix templatable int field types
The TEMPLATABLE_VALUE C++ fields are typed `int`, but Python codegen
was passing `cg.int32` (`int32_t`). On ESP-IDF/xtensa toolchains where
`int32_t` is `long`, the codegen-generated lambda's function-pointer
type `int32_t (*)(...)` does not match `int (*)(...)`, causing
`TemplatableFn` to select its deprecated casting-trampoline overload
and emit a `-Wdeprecated-declarations` warning at every call site.

Use `cg.int_` so the lambda's return type matches the field exactly.
2026-04-26 04:24:59 -05:00
J. Nick Koston a8d767cc5c Merge remote-tracking branch 'upstream/dev' into integration 2026-04-26 04:16:55 -05:00
J. Nick Koston 9028cc8c3e Merge remote-tracking branch 'origin/git_shallow_fetch' into integration 2026-04-26 04:13:13 -05:00
68625a1b76 [core] Isolate generated build metadata (#16007)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-04-26 09:11:09 +00:00
J. Nick Koston e907e71101 [git] Address PR review feedback
- Add `--` terminator before submodule paths (both clone and refresh
  paths) so a path beginning with `-` cannot be parsed as a git option.
- Reword the refresh-fetch comment: this fetch also runs when ref is
  None, in which case it pulls the remote default branch.
2026-04-26 04:08:43 -05:00
J. Nick Koston b3a57d1395 [git] Make ref fetches and submodule updates shallow
Fixes esphome/esphome#11550

When clone_or_update is called with a ref or submodules, the initial
clone uses --depth=1 but the subsequent git fetch and git submodule
update commands run deep, pulling the full history on every refresh.
This causes excess network traffic and disk usage for external_components,
packages, and dashboard imports.

Add --depth=1 to all four call sites (initial fetch, initial submodule
init, refresh fetch, refresh submodule update). Shallow fetches still
advance the local clone to the current remote tip when it moves, so the
refresh path keeps working as before.
2026-04-26 03:57:35 -05:00
J. Nick Koston dc57969afd [host] Use integer math in millis()/micros() (#15994) 2026-04-26 08:39:24 +00:00
J. Nick Koston f092e619d8 [rtttl] Gate on_finished_playback callback storage behind define (#16003) 2026-04-26 00:03:59 -05:00
J. Nick Koston 58f6ad2d0c [safe_mode] Use StaticCallbackManager for on_safe_mode (#16002) 2026-04-26 00:01:21 -05:00
Keith BurzinskiandJ. Nick Koston bc33260c61 [ir_rf_proxy] Extend for RF (#15744)
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-04-25 22:33:02 -05:00
J. Nick Koston 4cab262ef8 [ci] Trigger CodSpeed benchmarks on host platform changes (#15995) 2026-04-25 17:18:21 -04:00
J. Nick Koston b1f7a39252 Merge remote-tracking branch 'origin/dev' into integration 2026-04-25 16:02:21 -05:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 9ad820c921 Bump esphome-dashboard from 20260408.1 to 20260425.0 (#16006)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-25 20:59:01 +00:00
J. Nick Koston 4f8feb86f0 [dashboard] Add --no-states support to logs WebSocket handler (#15993) 2026-04-25 15:43:05 -05:00
J. Nick Koston 7702f8a6e7 Merge branch 'bh1750-illuminance-logv' into integration 2026-04-25 15:26:28 -05:00
J. Nick Koston d2baa0437a m 2026-04-25 15:26:26 -05:00
J. Nick Koston 827163d502 [bh1750] Downgrade per-reading Illuminance log to verbose
The base sensor already logs the published state via the [S]
publish line, so the component-level [D] line was redundant
log spam on every update. Drop it to ESP_LOGV.
2026-04-25 15:25:41 -05:00
J. Nick Koston 00cad4333e Merge branch 'safe-mode-static-callback-manager' into integration 2026-04-25 14:47:41 -05:00
J. Nick Koston ea0a6df1fb Merge remote-tracking branch 'upstream-ssh/rtttl-gate-callback-manager' into integration 2026-04-25 14:47:36 -05:00
J. Nick Koston 12f744bbbe [rtttl] Gate on_finished_playback callback storage behind define
Wrap the on_finished_playback CallbackManager storage, registration
method and call site behind USE_RTTTL_FINISHED_PLAYBACK_CALLBACK so
configs without an on_finished_playback automation pay zero RAM and
zero flash for it.

Keeps CallbackManager rather than switching to StaticCallbackManager
because rtttl is MULTI_CONF — a per-class compile-time N would force
every instance to reserve max(callbacks_per_instance) slots.
2026-04-25 14:26:23 -05:00
J. Nick Koston d7a69979e7 [safe_mode] Use StaticCallbackManager for on_safe_mode
safe_mode is a single-instance component, so a compile-time-sized
StaticVector backing for the callback list is a clean fit. Drop the
std::vector reallocation machinery (_M_realloc_insert) and size the
storage to the exact number of on_safe_mode automations via
ESPHOME_SAFE_MODE_CALLBACK_COUNT.
2026-04-25 14:23:31 -05:00
J. Nick Koston 9dfad8ba86 Merge remote-tracking branch 'upstream-ssh/bluetooth-proxy-redundant-bda-write' into integration 2026-04-25 13:54:14 -05:00
J. Nick Koston a2a9145a87 [bluetooth_proxy] Drop redundant remote_bda_ write in connect handler
get_connection_(msg.address, true) already populates remote_bda_ via
set_address(): either the slot was found because get_address() == msg.address
(so address_ and remote_bda_ already encode it), or a free slot was reserved
and set_address(msg.address) was called, which writes remote_bda_[0..5] from
the same bytes. The follow-up uint64_to_bd_addr(msg.address, connection->remote_bda_)
just rewrites the identical bytes.
2026-04-25 13:47:52 -05:00
J. Nick Koston be849f0a1a merge 2026-04-25 13:25:04 -05:00
J. Nick Koston 1e5a753e0e Merge branch 'output-power-scaling-optional' into integration 2026-04-25 13:10:27 -05:00
J. Nick Koston 4432516614 [output] Address Copilot review + add static_assert stubs for documented lambda API
- Replace inverted comments in set_min_power/set_max_power clamp lines
  (MIN>=MAX>=1.0 → min_power <= max <= 1.0) — pre-existing bug.
- Update FloatOutput class docstring to describe the conditional scaling
  behavior under USE_OUTPUT_FLOAT_POWER_SCALING.
- Reword the zero_means_zero codegen comment to explain why we gate on
  the value (schema default=False would otherwise force the define on).
- Add templated static_assert stubs for set_min_power/set_max_power/
  set_zero_means_zero in the #else branch so calls from lambdas
  (documented at esphome.io/components/output/#output-set_min_power_action)
  produce a clear compile error pointing at the user's lambda site, with
  the migration instruction inline (add 'min_power: 0%' / 'max_power: 100%'
  / 'zero_means_zero: true' to one output entry to enable scaling).

Templating on a default-false bool means the assert only fires on
instantiation (i.e. when the user actually calls the method), not on
every parse — so unused stubs in TUs that include the header (e.g.
output/automation.cpp when scaling actions aren't registered) don't
break the build.

Verified: a lambda calling id(out).set_min_power(0.2) without min_power
in YAML now fails compilation with a pointer at the lambda line and the
inline migration message; adding min_power: 0% to the output entry makes
the same config build clean.
2026-04-25 13:07:12 -05:00
J. Nick Koston f797090f1d Merge remote-tracking branch 'origin/output-power-scaling-optional' into integration 2026-04-25 12:42:52 -05:00
J. Nick Koston 15cb2c0580 [output] Gate FloatOutput power scaling fields behind USE_OUTPUT_FLOAT_POWER_SCALING
The min_power / max_power / zero_means_zero scaling support on FloatOutput
costs 12 bytes per instance (max_power_, min_power_, zero_means_zero_ +
alignment padding) on every PWM channel, DAC channel, LEDC output, and
dimmer-chip channel — even on configs that never touch the feature.

Repo-wide usage is ~17 YAML lines, mostly in test fixtures and a couple
of LED-driver chip tests; the runtime set_min_power / set_max_power
actions added in #8934 have no usage outside the action's own test.

Add USE_OUTPUT_FLOAT_POWER_SCALING and gate the fields and scaling math
in FloatOutput::set_level() behind it, mirroring the USE_POWER_SUPPLY
pattern already used in BinaryOutput. Python codegen flips the define on
whenever:
- a min_power / max_power / zero_means_zero key is set on any output, or
- a non-default zero_means_zero value is provided, or
- an output.set_min_power / output.set_max_power action is registered

The action class templates (SetMinPowerAction, SetMaxPowerAction) are
also gated on the same define so their non-dependent member access on
FloatOutput::set_min_power doesn't fail to parse when the methods aren't
compiled in. zero_means_zero_ now has a default initializer (was UB
before — it was always written from setup, but only because the schema
default forced it).

For configs without scaling: 12 B .bss saved per FloatOutput instance,
plus a small flash saving from the elided multiply/subtract in
set_level(). For configs with scaling: behavior is unchanged.

Verified on tests/components/esp8266_pwm (no scaling): pstorage 0x28 → 0x1c
per output (40 B → 28 B). Verified on tests/components/output (uses
set_min_power/set_max_power actions): builds correctly with the define on.
2026-04-25 12:39:32 -05:00
b5ccd55f4e [packages] Fix premature substitution of vars in remote package files (#15997)
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-04-25 17:06:58 +00:00
J. Nick Koston 4f51057fc2 [api] Clarify fence comment per review
Plain non-atomic load on the fast path is not a 'relaxed load' in the
C++ atomic sense; describe what the fence accomplishes instead.
2026-04-25 11:00:18 -05:00
J. Nick Koston df86f3aa0d Merge remote-tracking branch 'upstream-ssh/api-idle-once-per-loop-fence' into integration 2026-04-25 10:54:50 -05:00
J. Nick Koston f9ad090bf9 [api] Hoist memw out of socket ready check to once per main-loop iter
On Xtensa under default -mserialize-volatile, GCC emits a memw before
every volatile load. esphome_lwip_socket_has_data() is called once per
socket per main-loop iteration (one for the listening socket in
APIServer::loop and one per connected client in APIConnection::loop),
making per-call memw a measurable cost on the idle path.

Replace the per-call memw with a single std::atomic_thread_fence
(memory_order_acquire) at the top of Application::loop. The fence pairs
with the TCP/IP thread's existing SYS_ARCH_UNPROTECT release on
rcvevent. The wake path (xTaskNotifyGive in the lwip event_callback
hook, ulTaskNotifyTake at the bottom of the loop) is independent of
rcvevent visibility and is non-losing, so writes that land between the
fence and sleep are picked up by the next iteration.

Gated on ESPHOME_THREAD_MULTI_ATOMICS so that BK72xx (which lacks
LDREX/STREX and is built without libatomic) keeps the original volatile
load path. ESP32, RTL87xx and LN882x get the optimization; ESP8266,
RP2040 and host use the socket_ready_fd fallback and are unaffected.

Disassembly (ESP32, gatetrigger): APIServer::loop -8 B, APIConnection
::loop -5 B; loop_task gains one memw for the fence. Net per idle
iteration with N clients: save N memw on ready paths, add 1 for the
fence (savings scale with client count and other Socket::ready callers
like AsyncClient and CaptivePortal DNS).
2026-04-25 10:47:41 -05:00
J. Nick Koston 2a02136752 Merge remote-tracking branch 'upstream/dashboard-logs-no-states' into integration 2026-04-25 08:49:04 -05:00
J. Nick Koston 1b059f7fb2 Log post-append cmd in EsphomeLogsHandler so debug shows --no-states 2026-04-25 08:07:55 -05:00
J. Nick Koston 1574cf6256 [dashboard] Add --no-states support to logs WebSocket handler
EsphomeLogsHandler.build_command now appends --no-states to the
spawned `esphome logs` argv when the WebSocket spawn message
includes `no_states: true`. This lets the dashboard frontend
suppress entity-state log lines for OTA log sessions without
requiring users to drop to the CLI.

Adds three unit tests covering the truthy, missing, and explicit-False
cases.
2026-04-25 07:52:50 -05:00
J. Nick Koston c73311bf8b Merge remote-tracking branch 'upstream/bluetooth_proxy_revert_set_interval' into int_rev 2026-04-25 05:18:30 -05:00
J. Nick Koston b33878f71e [bluetooth_proxy] Restore inlined flush helper, verbose-log gating, and 100ms-gated cleanup
Keeps the structural improvements from #15347 while reverting only the
loop()->set_interval move that became a pessimization after #15792.

- flush_pending_advertisements_() inlined in header (was: out-of-line .cpp)
- log_advertisement_flush_() out-of-line, gated by ESPHOME_LOG_LEVEL_VERBOSE
- loop() gates both halves (flush + connection cleanup) at 100ms cadence
  rather than running cleanup at every Phase B tick

This is now a partial revert of #15347 rather than a full revert.
2026-04-25 05:18:08 -05:00
J. Nick Koston 95d7335b61 Revert "[bluetooth_proxy] Replace loop() with set_interval for advertisement flushing (#15347)"
This reverts commit 27c662e73f.
2026-04-25 05:01:04 -05:00
J. Nick Koston 1416574b04 Revert "[bluetooth_proxy] Replace loop() with set_interval for advertisement flushing (#15347)"
This reverts commit 27c662e73f.
2026-04-25 04:55:25 -05:00
J. Nick Koston 5558702c46 Merge remote-tracking branch 'upstream-ssh/ble-mac-varint-48bit' into integration 2026-04-25 04:47:46 -05:00
J. Nick Koston 5f8e991ed8 [api] Populate schema defaults for transitive cpp test deps; add json override
- script/build_helpers.py: when injecting a non-MULTI_CONF component
  into the post-validation config, run its CONFIG_SCHEMA with {} so
  defaults are populated. Without this, socket got config = {} and
  socket.FILTER_SOURCE_FILES crashed with KeyError on
  'implementation' (the schema's defaulted key was never filled in).
  Falls back to {} if the schema can't validate empty input.

- tests/components/json/__init__.py: enable codegen for json so its
  to_code runs during cpp unit test builds, registering the
  ArduinoJson library. Required for any api dep test, since
  json_util.cpp #includes <ArduinoJson.h>.

Locally verified 'script/cpp_unit_test.py api' now compiles and runs;
ProtoMacVarint test suite (9 cases) passes.
2026-04-25 04:44:35 -05:00
J. Nick Koston 45525c8a82 [api] Make api a buildable cpp unit test target
Three fixes so 'script/cpp_unit_test.py api' actually compiles instead
of crashing in build setup:

1. script/build_helpers.py: when adding transitive component
   dependencies to the post-validation config, use {} (dict) instead
   of [] (list) for non-MULTI_CONF components. socket's
   FILTER_SOURCE_FILES (and any other code that subscripts
   CORE.config[component] with a string key) was crashing because
   socket got config = [] from setdefault.

2. esphome/components/api/api_pb2_service.cpp + the codegen in
   script/api_protobuf/api_protobuf.py: wrap the generated
   APIConnection::read_message_ definition in #ifdef USE_API. The
   class itself is only declared inside #ifdef USE_API in
   api_connection.h, so without the guard the .cpp fails to compile
   in any build that pulls in the api source files without setting
   USE_API (e.g. cpp unit tests of api dependencies).
2026-04-25 04:41:17 -05:00
J. Nick Koston 68ffd3b221 [api] Fix CI errors in MAC varint unit tests
- Test file: declare proto_debug_end_ locally instead of misusing
  PROTO_ENCODE_DEBUG_INIT (which expands to a comma+expression for
  appending to a function call, not a standalone statement). Add
  NOLINTNEXTLINE on the deterministic mt19937_64 seed so clang-tidy
  cert-msc32-c stops failing the build (the seed is intentional for
  reproducible test runs).

- socket FILTER_SOURCE_FILES: tolerate non-dict CORE.config['socket']
  (e.g. C++ unit-test builds where socket isn't validated as a
  mapping). Returning [] is safe -- all impl files are guarded by
  USE_SOCKET_IMPL_* defines so only the selected one contributes
  code.
2026-04-25 04:36:32 -05:00
J. Nick Koston 946af91821 [api] Add unit tests for 48-bit MAC varint encoder
Verifies encode_varint_raw_48bit and calc_uint64_48bit_force for the
8 corner-case MAC addresses requested in review:

  00:00:00:00:00:00, 11:00:00:00:00:00, 00:AA:00:00:00:00,
  00:00:BB:00:00:00, 00:00:00:CC:00:00, 00:00:00:00:DD:00,
  00:00:00:00:00:EE, FF:FF:FF:FF:FF:FF

For each value the test asserts byte-identical output to the reference
encode_varint_raw_64 loop, the expected encoded byte length, agreement
with calc_uint64_48bit_force, and round-trip through a generic varint
decoder. Adds a 100-value deterministic-random sample across the full
48-bit space for additional coverage.
2026-04-25 04:22:39 -05:00
J. Nick Koston 7ab701e162 [api] Gate 48-bit MAC range check behind ESPHOME_DEBUG_API
Copilot flagged that encode_varint_raw_48bit/calc_uint64_48bit_force
would silently truncate for uint64 values >= 2^48. In practice the
(mac_address) option is only applied to fields populated by the BLE
stack, which always fits in 48 bits -- so the runtime upper-bound
check added in ba362a7c95 regressed CodSpeed by up to 8.7pp on
CalculateSize_BLERawAdvs12 for a scenario that can't happen.

Move the value-fits-in-48-bits check to a debug assert guarded by
ESPHOME_DEBUG_API, and express 48 via MAC_ADDRESS_SIZE * 8 so the
threshold tracks the existing MAC size constant. Release builds are
back to the original fast path; debug builds catch misuse.
2026-04-25 04:13:30 -05:00
J. Nick Koston ba362a7c95 [api] Narrow 48-bit MAC varint fast path to values < 2^48
Per Copilot review: encode_varint_raw_48bit and calc_uint64_48bit_force
would silently truncate bits 48..63 if ever called with a uint64 that
doesn't fit in 48 bits. Real MAC addresses always fit, but since the
helpers are exposed and the (mac_address) option is generic, narrow
the fast path to [1<<42, 1<<48) so values outside that range fall back
to the general encoder/size helpers.

Re-verified byte-identical output and decoder round-trip across the
1<<48 boundary and all bit positions up to 63.
2026-04-24 21:43:28 -05:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> a437b3086b Bump cryptography from 46.0.7 to 47.0.0 (#15990)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-25 02:30:10 +00:00
J. Nick Koston 45cddcd379 Merge branch 'dev' into ble-mac-varint-48bit 2026-04-24 21:29:01 -05:00
dependabot[bot]anddependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> c27f9e512b Bump aioesphomeapi from 44.21.0 to 44.22.0 (#15989)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-04-25 02:28:04 +00:00