Parcourir la source

- added config option 'filterUnchanged' so that filtering on state change can be disabled now (pin state is sent by the MCU every minute by default - now this will be published every time on MQTT if filterUnchanged = False)

FloKra il y a 1 an
Parent
commit
73a405161f
3 fichiers modifiés avec 7 ajouts et 3 suppressions
  1. 3 0
      CHANGELOG.txt
  2. 1 0
      ioext/config.py
  3. 3 3
      ioext/ioext.py

+ 3 - 0
CHANGELOG.txt

@@ -1,3 +1,6 @@
+03.07.2023
+	- added config option 'filterUnchanged' so that filtering on state change can be disabled now (pin state is sent by the MCU every minute by default - now this will be published every time on MQTT if filterUnchanged = False)
+	
 30.05.2023
 	separate config in python daemon
 

+ 1 - 0
ioext/config.py

@@ -1,6 +1,7 @@
 # timeout in s to end script when nothing is received (will be restarted by systemd then)
 # must be higher than getStatusInterval 
 quitOnNoReceiveTimeout = 75
+filterUnchanged = False # if True, MQTT updates are only sent if the pin state has changed
 
 # status file - on ramdrive (/tmp on RasPi by default)
 # is "touched" every time a serial message comes in so that working communication can be monitored easily

+ 3 - 3
ioext/ioext.py

@@ -129,7 +129,7 @@ try:
                 elif serLine == "P2=H":
                     newState = "ON"
                     
-                if newState is not None and lastState_tk != newState:
+                if newState is not None and (lastState_tk != newState or not filterUnchanged):
                     lastState_tk = newState
                     mqttc.publish(config.mqtt_topic_tuerkontakt, newState, qos=0, retain=False)
                     
@@ -141,7 +141,7 @@ try:
                 elif serLine == "P3=H":
                     newState = "ON"
                     
-                if newState is not None and lastState_pir1 != newState:
+                if newState is not None and (lastState_pir1 != newState or not filterUnchanged):
                     lastState_pir1 = newState
                     mqttc.publish(config.mqtt_topic_pir1, newState, qos=0, retain=False)
             
@@ -153,7 +153,7 @@ try:
                 elif serLine == "P4=H":
                     newState = "ON"
                 
-                if newState is not None and lastState_pir2 != newState:
+                if newState is not None and (lastState_pir2 != newState or not filterUnchanged):
                     lastState_pir2 = newState
                     mqttc.publish(config.mqtt_topic_pir2, newState, qos=0, retain=False)