From 6e066282c412441bc754275f86e00fc255a7044b Mon Sep 17 00:00:00 2001 From: avollkopf <43980694+avollkopf@users.noreply.github.com> Date: Sat, 25 Mar 2023 14:56:04 +0100 Subject: [PATCH] some tweaks --- cbpi/__init__.py | 2 +- cbpi/extension/httpsensor/__init__.py | 8 +++----- cbpi/extension/mqtt_sensor/__init__.py | 6 ++---- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/cbpi/__init__.py b/cbpi/__init__.py index 50436a0..36da73a 100644 --- a/cbpi/__init__.py +++ b/cbpi/__init__.py @@ -1,3 +1,3 @@ -__version__ = "4.1.7.a9" +__version__ = "4.1.7.a10" __codename__ = "Groundhog Day" diff --git a/cbpi/extension/httpsensor/__init__.py b/cbpi/extension/httpsensor/__init__.py index 0ff1443..e938bb5 100644 --- a/cbpi/extension/httpsensor/__init__.py +++ b/cbpi/extension/httpsensor/__init__.py @@ -32,16 +32,12 @@ class HTTPSensor(CBPiSensor): self.reducedfrequency=int(self.props.get("ReducedLogging", 60)) self.kettleid=self.props.get("Kettle", None) - self.reducedlogging=True self.fermenterid=self.props.get("Fermenter", None) + self.reducedlogging = True if self.kettleid or self.fermenterid else False if self.kettleid is not None and self.fermenterid is not None: self.reducedlogging=False self.cbpi.notify("HTTPSensor", "Sensor '" + str(self.sensor.name) + "' cant't have Fermenter and Kettle defined for reduced logging.", NotificationType.WARNING, action=[NotificationAction("OK", self.Confirm)]) - - self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None - self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None - async def Confirm(self, **kwargs): self.nextchecktime = time.time() + self.timeout @@ -59,6 +55,8 @@ class HTTPSensor(CBPiSensor): In this example the code is executed every second ''' while self.running is True: + self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None + self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None if self.timeout !=0: currenttime=time.time() if currenttime > self.nextchecktime and self.notificationsend == False: diff --git a/cbpi/extension/mqtt_sensor/__init__.py b/cbpi/extension/mqtt_sensor/__init__.py index 155e76f..443ce07 100644 --- a/cbpi/extension/mqtt_sensor/__init__.py +++ b/cbpi/extension/mqtt_sensor/__init__.py @@ -41,11 +41,7 @@ class MQTTSensor(CBPiSensor): if self.kettleid is not None and self.fermenterid is not None: self.reducedlogging=False self.cbpi.notify("MQTTSensor", "Sensor '" + str(self.sensor.name) + "' cant't have Fermenter and Kettle defined for reduced logging.", NotificationType.WARNING, action=[NotificationAction("OK", self.Confirm)]) - - self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None - self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None - async def Confirm(self, **kwargs): self.nextchecktime = time.time() + self.timeout self.notificationsend = False @@ -81,6 +77,8 @@ class MQTTSensor(CBPiSensor): logging.error("MQTT Sensor Error {}".format(e)) async def logvalue(self): + self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None + self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None now=time.time() if self.kettle is not None: try: