mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-24 07:58:11 +01:00
added sensor disabling with fermenter/kettle inactivity
This commit is contained in:
parent
5a2b0a8bd0
commit
187426eb4a
6 changed files with 108 additions and 97 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,8 +4,7 @@ build
|
|||
dist
|
||||
.idea
|
||||
*.log
|
||||
cbpi.egg-info
|
||||
cbpi4.egg-info
|
||||
/cbpi4.egg-info
|
||||
log
|
||||
venv
|
||||
cbpi/extension/ui
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
__version__ = "4.1.7.rc1"
|
||||
__version__ = "4.1.7.rc2"
|
||||
__codename__ = "Groundhog Day"
|
||||
|
||||
|
|
|
@ -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.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.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):
|
||||
def __init__(self, cbpi, id, props):
|
||||
|
@ -30,6 +30,8 @@ class HTTPSensor(CBPiSensor):
|
|||
|
||||
self.lastlog=0
|
||||
self.reducedfrequency=int(self.props.get("ReducedLogging", 60))
|
||||
if self.reducedfrequency < 0:
|
||||
self.reducedfrequency = 0
|
||||
|
||||
self.kettleid=self.props.get("Kettle", None)
|
||||
self.fermenterid=self.props.get("Fermenter", None)
|
||||
|
@ -84,6 +86,7 @@ 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:
|
||||
|
@ -118,6 +121,9 @@ class HTTPSensor(CBPiSensor):
|
|||
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
|
||||
|
|
|
@ -13,7 +13,7 @@ from datetime import datetime
|
|||
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.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",
|
||||
description="Timeout in seconds to send notification (default:60 | deactivated: 0)")])
|
||||
class MQTTSensor(CBPiSensor):
|
||||
|
@ -34,6 +34,8 @@ class MQTTSensor(CBPiSensor):
|
|||
self.lastlog=0
|
||||
self.sensor=self.get_sensor(self.id)
|
||||
self.reducedfrequency=int(self.props.get("ReducedLogging", 60))
|
||||
if self.reducedfrequency < 0:
|
||||
self.reducedfrequency = 0
|
||||
self.kettleid=self.props.get("Kettle", None)
|
||||
self.fermenterid=self.props.get("Fermenter", None)
|
||||
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))
|
||||
|
||||
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()
|
||||
|
|
|
@ -54,7 +54,7 @@ class ReadThread (threading.Thread):
|
|||
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.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):
|
||||
|
||||
|
@ -69,6 +69,8 @@ class OneWire(CBPiSensor):
|
|||
self.offset = float(self.props.get("offset",0))
|
||||
|
||||
self.reducedfrequency=float(self.props.get("ReducedLogging", 60))
|
||||
if self.reducedfrequency < 0:
|
||||
self.reducedfrequency = 0
|
||||
self.lastlog=0
|
||||
self.sensor=self.get_sensor(self.id)
|
||||
self.kettleid=self.props.get("Kettle", None)
|
||||
|
@ -121,6 +123,7 @@ 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:
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 2.1
|
||||
Name: cbpi4
|
||||
Version: 4.1.7a4
|
||||
Version: 4.1.7rc1
|
||||
Summary: CraftBeerPi4 Brewing Software
|
||||
Home-page: http://web.craftbeerpi.com
|
||||
Author: Manuel Fritsch / Alexander Vollkopf
|
||||
|
|
Loading…
Reference in a new issue