mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-23 07:28:13 +01:00
fixed another bug in case of no logging during inactivity
This commit is contained in:
parent
7df48bdf08
commit
0364769573
3 changed files with 78 additions and 78 deletions
|
@ -86,44 +86,42 @@ class HTTPSensor(CBPiSensor):
|
|||
await asyncio.sleep(1)
|
||||
|
||||
async def logvalue(self):
|
||||
if self.reducedfrequency != 0:
|
||||
now=time.time()
|
||||
if self.kettle is not None:
|
||||
try:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("Kettle Active")
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("Kettle Inactive")
|
||||
now=time.time()
|
||||
if self.kettle is not None:
|
||||
try:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("Kettle Active")
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("Kettle Inactive")
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
logging.info("Logged with reduced freqency")
|
||||
pass
|
||||
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("Fermenter Active")
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("Fermenter Inactive")
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("Fermenter Active")
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("Fermenter Inactive")
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
logging.info("Logged with reduced freqency")
|
||||
pass
|
||||
else:
|
||||
logging.warning("No logging")
|
||||
pass
|
||||
|
||||
def get_state(self):
|
||||
# return the current state of the sensor
|
||||
|
|
|
@ -79,38 +79,39 @@ class MQTTSensor(CBPiSensor):
|
|||
logging.error("MQTT Sensor Error {}".format(e))
|
||||
|
||||
async def logvalue(self):
|
||||
if self.reducedfrequency != 0:
|
||||
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:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
||||
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:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
logging.info("Logged with reduced freqency")
|
||||
pass
|
||||
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
|
|
|
@ -123,37 +123,38 @@ class OneWire(CBPiSensor):
|
|||
await asyncio.sleep(self.interval)
|
||||
|
||||
async def logvalue(self):
|
||||
if self.reducedfrequency != 0:
|
||||
now=time.time()
|
||||
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
||||
if self.kettle is not None:
|
||||
try:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
||||
now=time.time()
|
||||
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
||||
if self.kettle is not None:
|
||||
try:
|
||||
kettlestatus=self.kettle.instance.state
|
||||
except:
|
||||
kettlestatus=False
|
||||
if kettlestatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
logging.info("Logged with reduced freqency")
|
||||
pass
|
||||
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
||||
if self.fermenter is not None:
|
||||
try:
|
||||
fermenterstatus=self.fermenter.instance.state
|
||||
except:
|
||||
fermenterstatus=False
|
||||
if fermenterstatus:
|
||||
self.log_data(self.value)
|
||||
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
||||
self.lastlog = time.time()
|
||||
else:
|
||||
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
||||
if self.reducedfrequency != 0:
|
||||
if now >= self.lastlog + self.reducedfrequency:
|
||||
self.log_data(self.value)
|
||||
self.lastlog = time.time()
|
||||
|
|
Loading…
Reference in a new issue