Fix _tropical_night_value, which had the same stale _option_token assumption

Same issue as the beep fix in the previous commit: this also assumed
_option_token returned the full 'Sleep_<N>' token and tried to split
off the prefix itself. With the canonical value-half _option_token,
that always returned None. Read the value directly instead.
This commit is contained in:
Marc Billow committed 2026-07-28 13:29:49 +00:00
1 parent 00c1d78373
commit 5c962801b4
1 file changed
+7 -3
@@ -63,11 +63,15 @@ def _beep_write(payload, rep, href=None):
def _tropical_night_value(rep):
"""Tropical night mode level (0-16) from the `Sleep_<N>` option token."""
"""Tropical night mode level (0-16) from the `Sleep_<N>` option token.
_option_token returns the token's value half already (e.g. '16' for
'Sleep_16'), same convention as _beep_on above.
"""
tok = _option_token(rep, 'Sleep')
if tok is None or '_' not in tok:
if tok is None:
return None
return _int(tok.split('_', 1)[1])
return _int(tok)
def _tropical_night_write(value, rep, href=None):