Fix: correct index boundaries for water control

This commit is contained in:
Thomas Klaehn 2022-04-12 09:23:38 +02:00
parent 6d41ebfb01
commit 5be86e7703
2 changed files with 4 additions and 4 deletions

View File

@ -124,7 +124,7 @@ class Control(threading.Thread):
return self.__heat.state() return self.__heat.state()
def get_current_water_state(self, ident: int): def get_current_water_state(self, ident: int):
if ident > 0 and ident < len(self.__water_state): if ident > 0 and ident <= len(self.__water_state):
return self.__water_state[ident -1] return self.__water_state[ident -1]
return None return None
@ -138,7 +138,7 @@ class Control(threading.Thread):
def set_water_state(self, ident: str): def set_water_state(self, ident: str):
ident = int(ident) ident = int(ident)
if ident > 0 and ident < len(self.__water_state): if ident > 0 and ident <= len(self.__water_state):
pin = int(self.__config['water'][ident - 1]['pin']) pin = int(self.__config['water'][ident - 1]['pin'])
self.__water_state[ident - 1] = True self.__water_state[ident - 1] = True
self.__log.info("water on by button") self.__log.info("water on by button")
@ -146,7 +146,7 @@ class Control(threading.Thread):
def clear_water_state(self, ident: str): def clear_water_state(self, ident: str):
ident = int(ident) ident = int(ident)
if ident > 0 and ident < len(self.__water_state): if ident > 0 and ident <= len(self.__water_state):
pin = int(self.__config['water'][ident - 1]['pin']) pin = int(self.__config['water'][ident - 1]['pin'])
self.__water_state[ident - 1] = False self.__water_state[ident - 1] = False
self.__log.info("water off by button") self.__log.info("water off by button")

View File

@ -6,7 +6,7 @@ from setuptools import setup
from setuptools.command.install import install from setuptools.command.install import install
NAME = 'gardencontrol' NAME = 'gardencontrol'
VERSION = '3' VERSION = '4'
AUTHOR = 'Thomas Klaehn' AUTHOR = 'Thomas Klaehn'
EMAIL = 'tkl@blackfinn.de' EMAIL = 'tkl@blackfinn.de'
PACKAGES = ['config', 'control', 'gardencontrol', 'heat', 'remotecontrol'] PACKAGES = ['config', 'control', 'gardencontrol', 'heat', 'remotecontrol']