mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-21 14:38:15 +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
|
dist
|
||||||
.idea
|
.idea
|
||||||
*.log
|
*.log
|
||||||
cbpi.egg-info
|
/cbpi4.egg-info
|
||||||
cbpi4.egg-info
|
|
||||||
log
|
log
|
||||||
venv
|
venv
|
||||||
cbpi/extension/ui
|
cbpi/extension/ui
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
__version__ = "4.1.7.rc1"
|
__version__ = "4.1.7.rc2"
|
||||||
__codename__ = "Groundhog Day"
|
__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.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,40 +86,44 @@ class HTTPSensor(CBPiSensor):
|
||||||
await asyncio.sleep(1)
|
await asyncio.sleep(1)
|
||||||
|
|
||||||
async def logvalue(self):
|
async def logvalue(self):
|
||||||
now=time.time()
|
if self.reducedfrequency != 0:
|
||||||
if self.kettle is not None:
|
now=time.time()
|
||||||
try:
|
if self.kettle is not None:
|
||||||
kettlestatus=self.kettle.instance.state
|
try:
|
||||||
except:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=False
|
except:
|
||||||
if kettlestatus:
|
kettlestatus=False
|
||||||
self.log_data(self.value)
|
if kettlestatus:
|
||||||
logging.info("Kettle Active")
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("Kettle Inactive")
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("Kettle Active")
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("Kettle Inactive")
|
||||||
|
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:
|
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)
|
|
||||||
logging.info("Fermenter Active")
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("Fermenter Inactive")
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("Fermenter Active")
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("Fermenter Inactive")
|
||||||
|
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):
|
def get_state(self):
|
||||||
# return the current state of the sensor
|
# 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"),
|
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,42 +79,43 @@ 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):
|
||||||
self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None
|
if self.reducedfrequency == 0:
|
||||||
self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None
|
self.kettle = self.get_kettle(self.kettleid) if self.kettleid is not None else None
|
||||||
now=time.time()
|
self.fermenter = self.get_fermenter(self.fermenterid) if self.fermenterid is not None else None
|
||||||
if self.kettle is not None:
|
now=time.time()
|
||||||
try:
|
if self.kettle is not None:
|
||||||
kettlestatus=self.kettle.instance.state
|
try:
|
||||||
except:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=False
|
except:
|
||||||
if kettlestatus:
|
kettlestatus=False
|
||||||
self.log_data(self.value)
|
if kettlestatus:
|
||||||
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("MQTTSensor {} Kettle Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("MQTTSensor {} Kettle Inactive".format(self.sensor.name))
|
||||||
|
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:
|
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)
|
|
||||||
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("MQTTSensor {} Fermenter Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("MQTTSensor {} Fermenter Inactive".format(self.sensor.name))
|
||||||
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
|
self.log_data(self.value)
|
||||||
|
self.lastlog = time.time()
|
||||||
|
logging.info("Logged with reduced freqency")
|
||||||
|
pass
|
||||||
|
|
||||||
async def run(self):
|
async def run(self):
|
||||||
while self.running:
|
while self.running:
|
||||||
|
|
|
@ -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,41 +123,42 @@ class OneWire(CBPiSensor):
|
||||||
await asyncio.sleep(self.interval)
|
await asyncio.sleep(self.interval)
|
||||||
|
|
||||||
async def logvalue(self):
|
async def logvalue(self):
|
||||||
now=time.time()
|
if self.reducedfrequency == 0:
|
||||||
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
now=time.time()
|
||||||
if self.kettle is not None:
|
logging.info("OneWire {} logging subroutine".format(self.sensor.name))
|
||||||
try:
|
if self.kettle is not None:
|
||||||
kettlestatus=self.kettle.instance.state
|
try:
|
||||||
except:
|
kettlestatus=self.kettle.instance.state
|
||||||
kettlestatus=False
|
except:
|
||||||
if kettlestatus:
|
kettlestatus=False
|
||||||
self.log_data(self.value)
|
if kettlestatus:
|
||||||
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("OneWire {} Kettle Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("OneWire {} Kettle Inactive".format(self.sensor.name))
|
||||||
|
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:
|
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)
|
|
||||||
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
|
||||||
self.lastlog = time.time()
|
|
||||||
else:
|
|
||||||
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
|
||||||
if now >= self.lastlog + self.reducedfrequency:
|
|
||||||
self.log_data(self.value)
|
self.log_data(self.value)
|
||||||
|
logging.info("OneWire {} Fermenter Active".format(self.sensor.name))
|
||||||
self.lastlog = time.time()
|
self.lastlog = time.time()
|
||||||
logging.info("Logged with reduced freqency")
|
else:
|
||||||
pass
|
logging.info("OneWire {} Fermenter Inactive".format(self.sensor.name))
|
||||||
|
if now >= self.lastlog + self.reducedfrequency:
|
||||||
|
self.log_data(self.value)
|
||||||
|
self.lastlog = time.time()
|
||||||
|
logging.info("Logged with reduced freqency")
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue