Commit fa34e222 authored by Peter-Bernd Otte's avatar Peter-Bernd Otte

added feature lux threshold for PIR

parent 28848b2f
......@@ -16,7 +16,7 @@ testraum/testrelais:
toggleTopics: homie/enocean/test/schalter2
inverseSwitchOnTopics: homie/enocean/test/schalter6
prolongateStateTopics: homie/enocean/test/schalter5
luxthreshold: 200 #below this threshold, lights get switched on. Default=100
testraum/testrelais2:
MQTTRelaisTopic: homie/fsr-ww/3
......
......@@ -123,6 +123,11 @@ for section in cfg:
if x.MQTTRelaisTopic == cfg[section]["MQTTRelaisTopic"]:
logger.error("MQTTRelaisTopic: "+str(cfg[section]["MQTTRelaisTopic"])+" does already exist. Will not be added.")
continue
luxthreshold = 100
if "luxthreshold" in cfg[section]:
luxthreshold = cfg[section]["luxthreshold"]
if type(luxthreshold) is not int: luxthreshold = 100
logger.debug("luxthreshold used: "+str(luxthreshold))
defaultTopics = cfg[section]["defaultTopics"] if "defaultTopics" in cfg[section] and isinstance(cfg[section]["defaultTopics"],(list, str)) else []
toggleTopics = cfg[section]["toggleTopics"] if "toggleTopics" in cfg[section] and isinstance(cfg[section]["toggleTopics"],(list, str)) else []
......@@ -147,7 +152,7 @@ for section in cfg:
switchOffTopics=switchOffTopics,
defaultTopics=defaultTopics, inverseSwitchOnTopics=inverseSwitchOnTopics,
prolongateStateTopics=prolongateStateTopics,
defaultSwitchOffTime=defaultSwitchOffTime, debug=debugItem, relaisType=relaisType))
defaultSwitchOffTime=defaultSwitchOffTime, debug=debugItem, relaisType=relaisType, luxthreshold=luxthreshold))
logger.info("Adding successfully.")
......
......@@ -22,10 +22,11 @@ class rLightDesire(Enum):
class relais:
def __init__(self, MQTTClient, MQTTName, MQTTRelaisTopic, defaultTopics=None, toggleTopics=None, dimmTopics=None,
switchOffTopics=None,
inverseSwitchOnTopics=None, prolongateStateTopics=None, defaultSwitchOffTime=None, debug=False, relaisType="relais"):
inverseSwitchOnTopics=None, prolongateStateTopics=None, defaultSwitchOffTime=None, debug=False, relaisType="relais", luxthreshold=100):
self.MQTTname = MQTTName #string
self.type = relaisType # possible: "relais" and "dimmer"
self.debug = debug
self.luxthreshold = luxthreshold #below this threshold in lux the PIR switches on
self.MQTTClient = MQTTClient #object
self.MQTTRelaisTopic = MQTTRelaisTopic #string
......@@ -87,7 +88,8 @@ class relais:
if msg['type'] in ('TFBHSB55', 'FBH63'): # motion sensors
self.timeLastStateConfirm = time.time()
if self.debug: print(self.MQTTname, "Check Motion Sensors")
if msg['v'] > 0:
lux = msg['lux'] if 'lux' in msg else 100
if msg['v'] > 0 and self.luxthreshold > lux:
self.lockingPIRs.add(topic)
self.lightdesire = rLightDesire.lockedDueToPIR
self.setV(1, reason="PIR motion")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment