# Sleep-Timer Aktualwert nicht gefunden

**URL:** <https://forum.espuino.de/t/sleep-timer-aktualwert-nicht-gefunden/3174>\
**Category:** Software\
**Created:** [14. August 2024 um 11:29 UTC](https://forum.espuino.de/t/sleep-timer-aktualwert-nicht-gefunden/3174 "2024-08-14T11:29:00Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![biologist](https://forum.espuino.de/user_avatar/forum.espuino.de/biologist/32/66_2.png) [@biologist](https://forum.espuino.de/u/biologist)\
**Post date:** [27. August 2026 um 18:37 UTC](https://forum.espuino.de/t/sleep-timer-aktualwert-nicht-gefunden/3174/18 "2026-08-27T18:37:23Z")

</div>

So, ich habe das jetzt mit folgenden Commits in dev umgesetzt:

> <https://github.com/biologist79/ESPuino/commit/4181a781189c5dada8fda6f67de1917e2483142a>
>
> Three small, independent fixes in the topicSleepTimer path:
> \- On reconnect, topi…cSleepTimer published System\_GetSleepTimerTimeStamp()
> -- the internal millis() start-timestamp, a meaningless huge number --
> instead of the configured minutes. Publish the configured value (or 0).
> \- The idle-rejection and the "0" disable branches published to topicSleep
> (the power on/off state topic) instead of topicSleepTimer, so cancelling
> a timer or rejecting one while idle emitted a spurious power-state value.
> 
> Co-Authored-By: Claude Opus 4.8 \<noreply@anthropic.com\>

> <https://github.com/biologist79/ESPuino/commit/7761b55d370ad4ed72ed34a2084a2e395e57910f>
>
> Publishes the live sleep-timer status as a single JSON object on the new
> non-ret…ained state topic sleep\_timer\_state, e.g.
> {"mode":"MINUTES","remainingMinutes":29,"remainingTracks":0}
> mode is OFF/MINUTES/EOT/EOP/EO5T. This lets a home-automation system show
> the remaining time (minute-timer, counted down once per minute) or the
> remaining tracks (EOT/EO5T/EOP, updated on track change).
> 
> Design:
> \- One JSON topic rather than several scalar topics, keeping the flat topic
> scheme uncluttered.
> \- Non-retained, matching every other ESPuino state topic (nothing stale
> lives in the broker; the reconnect handler re-publishes current state,
> and a clean OFF is emitted before shutdown).
> \- Single publisher: System\_SleepHandler() calls the self-deduplicating
> Mqtt\_PublishSleepTimerState() every loop, so a timer set from any source
> (MQTT, RFID modification card, button) is reflected within one iteration
> without instrumenting each set-site.
> \- New System\_GetSleepTimerRemainingMinutes() helper avoids duplicating the
> countdown math.
> \- Web-UI MQTT topic preview and the README MQTT table list the new topic.
> 
> Reimplemented from the idea in #446 (TMHEINE).
> 
> Co-Authored-By: Claude Opus 4.8 \<noreply@anthropic.com\>

Das Ganze funktioniert jetzt mit einem zusätzlichen Topic, welches eine JSON-Payload hat:

`sleep_timer_state {"mode":"OFF","remainingMinutes":0,"remainingTracks":0}`

Mode kann hierbei `OFF`/`MINUTES`/`EOT`/`EOP`/`EO5T` sein. Das Feld remainingMinutes ist nur gesetzt, wenn mode=MINUTES. remainingTracks entsprechend, wenn mode=EOT oder EOP oder EO5T. Die alten Topics habe ich, zwecks Abwärtskompatibilität, unverändert gelassen.

@Joe91 Bei der Gelegenheit ist mir noch ein Bug aufgefallen, den ich bisher noch nicht getriggert hatte:

> <https://github.com/biologist79/ESPuino/commit/4ff8889291ba1a2bc83b442ce1ff966d7aa9eeb9>
>
> Mqtt\_Init() resolves the \<MAC\> token in the device id before the WiFi
> driver is …up, and WiFi.macAddress() returns 00:00:00:00:00:00 until then,
> so topics used ESPuino-000000000000. Read the STA MAC from eFuse via
> esp\_read\_mac() in Wlan\_GetMacAddress() instead -- always available and the
> same value WiFi.macAddress() returns once connected (the web interface was
> already correct because it reads the MAC later, at request time).
> 
> Co-Authored-By: Claude Opus 4.8 \<noreply@anthropic.com\>

---

_[View the full topic](https://forum.espuino.de/t/sleep-timer-aktualwert-nicht-gefunden/3174)._
