From 86e882f56bb333e2c5a23490f75478b9a61abe33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20Buss=C3=A9?= Date: Mon, 3 Jul 2023 09:38:25 +0200 Subject: [PATCH] Select sensor ignores out of range indices --- src/entity.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/entity.py b/src/entity.py index 161a71b..677658f 100644 --- a/src/entity.py +++ b/src/entity.py @@ -189,6 +189,10 @@ def __init__(self, entitytype: str, systemname: str, attribute: str, systemlabel self._options = self._split(data[FORMAT]) def set_okfval(self, v): + iv = int(v) + if iv < 0 or iv >= len(self._options): + llog.info( f"{self._entityname}: option not available ({iv} out of {len(self._options)}). Ignored.") + return super().set_okfval(self._options[int(v)]) @property