From 5c962801b4590309920368dc1734e9bf4a83d09d Mon Sep 17 00:00:00 2001 From: Marc Billow Date: Tue, 28 Jul 2026 13:29:49 +0000 Subject: [PATCH] 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_' 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. --- .../registry/capabilities/airconditioner.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_components/localthings/registry/capabilities/airconditioner.py b/custom_components/localthings/registry/capabilities/airconditioner.py index 5ccfae7..07ff46e 100644 --- a/custom_components/localthings/registry/capabilities/airconditioner.py +++ b/custom_components/localthings/registry/capabilities/airconditioner.py @@ -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_` option token.""" + """Tropical night mode level (0-16) from the `Sleep_` 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):