Skip to content

Docs: keep the temperature source after an ESP restart (YAML snippet) - #24

Merged
samphonic merged 2 commits into
muart-group:mainfrom
keithajmani:restore-temp-after-restart-snippet
Nov 29, 2026
Merged

samphonic merged 2 commits into
muart-group:mainfrom
keithajmani:restore-temp-after-restart-snippet

Conversation

@keithajmani

Copy link
Copy Markdown
Contributor

Written by Claude (Anthropic's AI assistant) for me. I've reviewed it.

After an ESP restart there's no remote temperature to send until the selected source reports again: about a minute for an MHK2, longer for a HA sensor that only pushes on change. Units that revert quickly fall back to their internal sensor in the meantime, and if that sensor is somewhere cold they start an unneeded heat run.

This adds an "After an ESP restart" section to Dealing with Infrequent Sensor Updates, as Sam suggested on Discord. It's a short YAML-only fix for a single source that works on current main: a restore_value global keeps the source's last temperature, and after boot a while loop re-sends it with temperature_source_report() every 5 s, until the source sensor has a state, for at most 3 min.

It also adds a short tip on Adding Extra Temperature Sources that links to the new section.

How I tested it. I installed the snippet exactly as written on stock main, on my PVA-A42AA7 / PUZ-HA42NKA1 with an MHK2 (ESP32-C3, ESPHome 2026.11.1). The unit was in Fan mode, with "Thermostat" selected and a device log capture running:

  1. First boot after install: nothing was saved yet, so nothing was re-sent and the unit reported its internal sensor (19.0 °C), as expected. As soon as the MHK2 reported, the value went into the global.
  2. Clean restart (ESPHome restart button): the saved 20.0 °C was sent with temperature_source_report() every 5 s from +5.6 s. The MHK2 reconnected at +73 s. The unit reported 20.0 °C throughout and never reported its internal sensor, and the loop stopped by itself once thermostat_temperature had a state.
  3. Without the snippet, on the same unit, it reverted to the internal sensor about 55–60 s after a restart.

The snippet as written also compiles in a minimal config. Not tested: a real power cut, which relies on the periodic flash write instead of the sync at shutdown.

A built-in, opt-in alternative is proposed in muart-group/esphome-components#80, with its docs in #23. This snippet is useful either way, for anyone not running that version.

…(YAML snippet)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@keithajmani
keithajmani force-pushed the restore-temp-after-restart-snippet branch from ec7af91 to e78d8df Compare November 28, 2026 21:43

@samphonic samphonic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one minor adjustment on the docs and I'll merge this (couldn't quickly do this myself in codespace because it denied me permission to push change-- not sure if that's on me or not)

Comment thread docs/user/configuration/temp-sources.md Outdated
After an ESP restart there is no temperature to send until the source reports again. See
[After an ESP restart](infrequent-sensors.md#after-an-esp-restart).
:::

@samphonic samphonic Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace lines 14-20 with:

component enforces that check. Some units revert much sooner (around a minute), which can cause unexpected timeouts even during an ESP32 reboot/update; see
[Dealing with Infrequent Sensor Updates](infrequent-sensors.md).
:::

(tried to do this myself but don't have permissions to push change to this fork)

…eview suggestion)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@keithajmani

Copy link
Copy Markdown
Contributor Author

Done, thanks! Applied your suggested wording and removed the separate tip.

@samphonic
samphonic merged commit 5af966d into muart-group:main Nov 29, 2026
@samphonic

Copy link
Copy Markdown
Contributor

Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants