monitor.py is responsible for monitoring the conditions and generating events for the event queue. This is one of the more complex pieces of code, but essentially it is parsing the set and reset expressions for all conditions, and placing events in the event queue. The parser has to process expressions which may contain:

time-of-day [‘TOD’]

time-of-weekday [‘TOWD’]

time-of-weekend [‘TOWE’]

sensor values [‘S1’]

actuator timers [‘T1’ or ‘t1’]

All this complexity is hidden from the user however, because a database trigger converts from simple expression formats into a common complex format which is processed by the monitor.

To make this work uncomment the code on lines 32 and 185 of main_sched.py. Now we have the monitor module installed, we can also uncomment the call to truncate_samples() on line 200.

Restart the controller.

In the next post we will install the website pages for conditions and condition graphs, allowing us to add and test them.