mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-23 15:38:14 +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)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def logvalue(self):
|
async def logvalue(self):
|
||||||
if self.reducedfrequency != 0:
|
now=time.time()
|
||||||
now=time.time()
|
if self.kettle is not None:
|
||||||
if self.kettle is not None:
|
try:
|
||||||
try:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=self.kettle.instance.state
|
except:
|
||||||
except:
|
kettlestatus=False
|
||||||
kettlestatus=False
|
if kettlestatus:
|
||||||
if kettlestatus:
|
self.log_data(self.value)
|
||||||
self.log_data(self.value)
|
logging.info("Kettle Active")
|
||||||
logging.info("Kettle Active")
|
self.lastlog = time.time()
|
||||||
self.lastlog = time.time()
|
else:
|
||||||
else:
|
logging.info("Kettle Inactive")
|
||||||
logging.info("Kettle Inactive")
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
logging.info("Logged with reduced freqency")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.fermenter is not None:
|
if self.fermenter is not None:
|
||||||
try:
|
try:
|
||||||
fermenterstatus=self.fermenter.instance.state
|
fermenterstatus=self.fermenter.instance.state
|
||||||
except:
|
except:
|
||||||
fermenterstatus=False
|
fermenterstatus=False
|
||||||
if fermenterstatus:
|
if fermenterstatus:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
logging.info("Fermenter Active")
|
logging.info("Fermenter Active")
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
else:
|
else:
|
||||||
logging.info("Fermenter Inactive")
|
logging.info("Fermenter Inactive")
|
||||||
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
logging.info("Logged with reduced freqency")
|
||||||
pass
|
pass
|
||||||
else:
|
|
||||||
logging.warning("No logging")
|
|
||||||
pass
|
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
# return the current state of the sensor
|
# return the current state of the sensor
|
||||||
|
|
|
@ -79,38 +79,39 @@ class MQTTSensor(CBPiSensor):
|
||||||
logging.error("MQTT Sensor Error {}".format(e))
|
logging.error("MQTT Sensor Error {}".format(e))
|
||||||
|
|
||||||
async def logvalue(self):
|
async def logvalue(self):
|
||||||
if self.reducedfrequency != 0:
|
self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None
|
||||||
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
|
||||||
self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None
|
now=time.time()
|
||||||
now=time.time()
|
if self.kettle is not None:
|
||||||
if self.kettle is not None:
|
try:
|
||||||
try:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=self.kettle.instance.state
|
except:
|
||||||
except:
|
kettlestatus=False
|
||||||
kettlestatus=False
|
if kettlestatus:
|
||||||
if kettlestatus:
|
self.log_data(self.value)
|
||||||
self.log_data(self.value)
|
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
||||||
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
self.lastlog = time.time()
|
||||||
self.lastlog = time.time()
|
else:
|
||||||
else:
|
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
||||||
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
logging.info("Logged with reduced freqency")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.fermenter is not None:
|
if self.fermenter is not None:
|
||||||
try:
|
try:
|
||||||
fermenterstatus=self.fermenter.instance.state
|
fermenterstatus=self.fermenter.instance.state
|
||||||
except:
|
except:
|
||||||
fermenterstatus=False
|
fermenterstatus=False
|
||||||
if fermenterstatus:
|
if fermenterstatus:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
else:
|
else:
|
||||||
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
||||||
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
|
|
|
@ -123,37 +123,38 @@ class OneWire(CBPiSensor):
|
||||||
await asyncio.sleep(self.interval)
|
await asyncio.sleep(self.interval)
|
||||||
|
|
||||||
async def logvalue(self):
|
async def logvalue(self):
|
||||||
if self.reducedfrequency != 0:
|
now=time.time()
|
||||||
now=time.time()
|
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
||||||
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
if self.kettle is not None:
|
||||||
if self.kettle is not None:
|
try:
|
||||||
try:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=self.kettle.instance.state
|
except:
|
||||||
except:
|
kettlestatus=False
|
||||||
kettlestatus=False
|
if kettlestatus:
|
||||||
if kettlestatus:
|
self.log_data(self.value)
|
||||||
self.log_data(self.value)
|
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
||||||
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
self.lastlog = time.time()
|
||||||
self.lastlog = time.time()
|
else:
|
||||||
else:
|
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
||||||
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
logging.info("Logged with reduced freqency")
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if self.fermenter is not None:
|
if self.fermenter is not None:
|
||||||
try:
|
try:
|
||||||
fermenterstatus=self.fermenter.instance.state
|
fermenterstatus=self.fermenter.instance.state
|
||||||
except:
|
except:
|
||||||
fermenterstatus=False
|
fermenterstatus=False
|
||||||
if fermenterstatus:
|
if fermenterstatus:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
else:
|
else:
|
||||||
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
||||||
|
if self.reducedfrequency != 0:
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
|
|
Loading…
Reference in a new issue