Conditional Controller Timeout value not recognized

Version: 8.12.9
Pi 4B 8 GB

Hi,

i am successfully using Mycodo for monitoring a heater in the basement with a Mijia thermometer
and some functions to analyze the temp values.

Now i want to add a new condition that checks every 60 seconds (Period option) if a measurement of Temp greater a specific degree and if true the defined action (email) should be triggered. Then in this case the condition function has to pause for 3600 seconds which i set as value in the Timeout option.

My problem is that if measurement has reached the defined Temp i get the triggered action email every 60 seconds as defined in Period option and not with a pause of at least 3600 seconds as defined in Timeout option. Is there something i missed to properly configure my use case?

Best Regards
Frank

It may help to paste some of the live code you are using/have modified, or pictures of the parameters you set on your dashboard.

Here my code:

if not hasattr(self, "loop_count"):  # Initialize objects saved across executions
    self.loop_count = 1
else:
    self.loop_count += 1

measurement = self.condition("{31cd771b}") # Measurements from MI Temp Sensor

if measurement is not None and measurement > 30:
    self.logger.info("MI SENSOR: TEMP VALUE GREATER 30 DEGREES FOUND")
    self.message += "HEATING ACTIVATED"
    self.run_all_actions(message=self.message)  # Run all actions sequentially

Options:
image

Timeout is for Pyro5, which is how functions communicate between themselves. The Pyro5 connection is aborted if it hasn’t closed in the timeout period.

You will need to either 1) increase the period or 2) code a check if an email was sent recently, if you want to limit how many are sent in any given range of time.

1 Like

You can save values, e.g.

import time

temp = self.condition("{31cd771b}")
next_email_allowed = self.get_custom_option("next_email_allowed")  # Returns None if not set

if temp is not None and temp > 30 and (not next_email_allowed or time.now() > next_email_allowed):
    self.logger.info("MI SENSOR: TEMP VALUE GREATER 30 DEGREES FOUND")
    self.message += "HEATING ACTIVATED"
    self.run_all_actions(message=self.message)
    self.set_custom_option("next_email_allowed", time.now() + 3600)
1 Like

At first i tried time.sleep() in my condition and that worked also. But i thought that sleep-functions are not the appropriate way for waiting the condition when there is a Timeout-Function, but now i know for what this option is. Thank you for your clarification and your code snippet.

PS: The Timeout-function and description is missing in your Manual.

1 Like

Thanks, I’ll update it.

1 Like