def send_trigger_value(trigger_channel, sensor_value, threshold, send_below_threshold):
global crossed_threshold
if (((sensor_value >= threshold) and not send_below_threshold) or ((sensor_value < threshold) and send_below_threshold)):
if not crossed_threshold:
client.virtualWrite(trigger_channel, 1, "digital_sensor", "d")
crossed_threshold = True
else:
client.virtualWrite(trigger_channel, 0, "digital_sensor", "d")
crossed_threshold = False
while True:
client.loop()
if (time.time() > timestamp + 10):
sensor_value = i
client.celsiusWrite(DATA_CHANNEL, sensor_value)
send_trigger_value(TRIGGER_CHANNEL, sensor_value, THRESHOLD, send_below_threshold)
timestamp = time.time()
i = i + 1
if (i == 12): # Reset the sensor value to test that the trigger gets reset.
i = 0
Im sure. It may not be every 2 seconds… maybe as the code says it is every 12 seconds but still constant notifications.
I need more like
If IO == 1 then send notification
not
While == 1 send notifications
Is this possible?