added sensor disabling with fermenter/kettle inactivity

This commit is contained in:
avollkopf 2023-03-27 20:19:37 +02:00
parent 5a2b0a8bd0
commit 187426eb4a
6 changed files with 108 additions and 97 deletions

3
.gitignore vendored
View file

@ -4,8 +4,7 @@ build
dist dist
.idea .idea
*.log *.log
cbpi.egg-info /cbpi4.egg-info
cbpi4.egg-info
log log
venv venv
cbpi/extension/ui cbpi/extension/ui

View file

@ -1,3 +1,3 @@
__version__ = "4.1.7.rc1" __version__ = "4.1.7.rc2"
__codename__ = "Groundhog Day" __codename__ = "Groundhog Day"

View file

@ -14,7 +14,7 @@ cache = {}
Property.Number(label="Timeout", configurable="True",unit="sec",description="Timeout in seconds to send notification (default:60 | deactivated: 0)"), Property.Number(label="Timeout", configurable="True",unit="sec",description="Timeout in seconds to send notification (default:60 | deactivated: 0)"),
Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"), Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"),
Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"), Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"),
Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default is 60 sec)")]) Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default: 60 sec | disabled: 0)")])
class HTTPSensor(CBPiSensor): class HTTPSensor(CBPiSensor):
def __init__(self, cbpi, id, props): def __init__(self, cbpi, id, props):
@ -30,6 +30,8 @@ class HTTPSensor(CBPiSensor):
self.lastlog=0 self.lastlog=0
self.reducedfrequency=int(self.props.get("ReducedLogging", 60)) self.reducedfrequency=int(self.props.get("ReducedLogging", 60))
if self.reducedfrequency < 0:
self.reducedfrequency = 0
self.kettleid=self.props.get("Kettle", None) self.kettleid=self.props.get("Kettle", None)
self.fermenterid=self.props.get("Fermenter", None) self.fermenterid=self.props.get("Fermenter", None)
@ -84,6 +86,7 @@ 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:
@ -118,6 +121,9 @@ class HTTPSensor(CBPiSensor):
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

View file

@ -13,7 +13,7 @@ from datetime import datetime
description="Where to find msg in payload, leave blank for raw payload"), description="Where to find msg in payload, leave blank for raw payload"),
Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"), Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"),
Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"), Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"),
Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default is 60 sec)"), Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default:60 sec | 0 disabled)"),
Property.Number(label="Timeout", configurable=True, unit="sec", Property.Number(label="Timeout", configurable=True, unit="sec",
description="Timeout in seconds to send notification (default:60 | deactivated: 0)")]) description="Timeout in seconds to send notification (default:60 | deactivated: 0)")])
class MQTTSensor(CBPiSensor): class MQTTSensor(CBPiSensor):
@ -34,6 +34,8 @@ class MQTTSensor(CBPiSensor):
self.lastlog=0 self.lastlog=0
self.sensor=self.get_sensor(self.id) self.sensor=self.get_sensor(self.id)
self.reducedfrequency=int(self.props.get("ReducedLogging", 60)) self.reducedfrequency=int(self.props.get("ReducedLogging", 60))
if self.reducedfrequency < 0:
self.reducedfrequency = 0
self.kettleid=self.props.get("Kettle", None) self.kettleid=self.props.get("Kettle", None)
self.fermenterid=self.props.get("Fermenter", None) self.fermenterid=self.props.get("Fermenter", None)
self.reducedlogging = True if self.kettleid or self.fermenterid else False self.reducedlogging = True if self.kettleid or self.fermenterid else False
@ -77,6 +79,7 @@ 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()

View file

@ -54,7 +54,7 @@ class ReadThread (threading.Thread):
Property.Select(label="Interval", options=[1,5,10,30,60], description="Interval in Seconds"), Property.Select(label="Interval", options=[1,5,10,30,60], description="Interval in Seconds"),
Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"), Property.Kettle(label="Kettle", description="Reduced logging if Kettle is inactive (only Kettle or Fermenter to be selected)"),
Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"), Property.Fermenter(label="Fermenter", description="Reduced logging in seconds if Fermenter is inactive (only Kettle or Fermenter to be selected)"),
Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default is 60 sec)") Property.Number(label="ReducedLogging", configurable=True, description="Reduced logging frequency in seconds if selected Kettle or Fermenter is inactive (default: 60 sec | disabled: 0)")
]) ])
class OneWire(CBPiSensor): class OneWire(CBPiSensor):
@ -69,6 +69,8 @@ class OneWire(CBPiSensor):
self.offset = float(self.props.get("offset",0)) self.offset = float(self.props.get("offset",0))
self.reducedfrequency=float(self.props.get("ReducedLogging", 60)) self.reducedfrequency=float(self.props.get("ReducedLogging", 60))
if self.reducedfrequency < 0:
self.reducedfrequency = 0
self.lastlog=0 self.lastlog=0
self.sensor=self.get_sensor(self.id) self.sensor=self.get_sensor(self.id)
self.kettleid=self.props.get("Kettle", None) self.kettleid=self.props.get("Kettle", None)
@ -121,6 +123,7 @@ 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:

View file

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: cbpi4 Name: cbpi4
Version: 4.1.7a4 Version: 4.1.7rc1
Summary: CraftBeerPi4 Brewing Software Summary: CraftBeerPi4 Brewing Software
Home-page: http://web.craftbeerpi.com Home-page: http://web.craftbeerpi.com
Author: Manuel Fritsch / Alexander Vollkopf Author: Manuel Fritsch / Alexander Vollkopf