some tweaks

This commit is contained in:
avollkopf 2023-03-25 14:56:04 +01:00
parent 3186c182f7
commit 6e066282c4
3 changed files with 6 additions and 10 deletions

View file

@ -1,3 +1,3 @@
__version__ = "4.1.7.a9"
__version__ = "4.1.7.a10"
__codename__ = "Groundhog Day"

View file

@ -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:

View file

@ -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: