Smart Building Technician

Case File: The Heating That Switched Off at Midnight

The night-time heating schedule of a depot office works every evening and switches off at midnight on Fridays. Decide which automation rules are active at a list of moments, with the exact rules for a window that crosses midnight (its morning part belongs to the day after the listed one), a start that is included and an end that is not, and a window with equal start and end that is empty. Find the most active rule and the overlaps. Run it on schedules that you cannot see. The rules are generated for you alone.

50 min

Sabi Logistics · Building 1

The Heating That Switched Off at Midnight

The office was cold on Saturday morning, and the Friday night heating was said to run all night

Amaka Facilities manager ·

Amaka. The depot office heating is on a schedule: from 22:00 to 06:00, for the days that the night shift works. On Saturday morning the office was freezing and the heating had been off since midnight. The schedule says Friday, from 22:00 to 06:00. The supplier says that it is “working as designed”.

I have the list of rules (name, days, start, end) and a list of moments that I want checked: a day and a time. Please tell me which rules are active at each moment. I need to be told the exact rule that you apply to a window that crosses midnight, because I think that is where our schedule breaks.

The brief

What you need to know first.

  • Minutes since midnight. minutes("22:30") is 22 * 60 + 30 = 1350. Comparing numbers is far safer than comparing text, and it makes the arithmetic of windows easy. Days are numbers: 0 is Monday, 6 is Sunday.
  • A normal window. When start < end (08:00 to 17:00), the rule is active on a listed day when start <= m < end: the start is included and the end is not. At 17:00 exactly the rule has already ended.
  • A window that crosses midnight. When start > end (22:00 to 06:00) there are two parts. The evening part (from the start to midnight) belongs to the listed day. The morning part (from midnight to the end) belongs to the day after a listed day: a rule that starts on Friday evening is still running on Saturday at 05:59, even though Saturday is not in its list. The day before day d is (d + 6) % 7 (Monday, 0, is preceded by Sunday, 6).
  • An empty window. When start == end the window is empty: never active.
  • Fill in minutes, is_active, schedule(req) returning {"active": [sorted names for each query], "most_active", "n_overlaps"}, then result and n_crossing. The checks run schedule on requests that you cannot see: Friday night into Saturday morning, an empty window, exactly the start and the end time, Monday morning for a rule that starts on Sunday, and an empty request.

The lab gives you the data for this case, invented and generated for you alone.

Preparing your data…

On the bench

The lab checked the rule with a script. These are the checks and measurements that show the same thing in a real building.

You want toDo thisWhat you see
test a schedule that crosses midnightSet the test clock or the automation test mode to the start minute, the last minute, the end minute and the first minute of the next day, and read the device state each timethe state at each edge moment, to compare with your table
see which rules are active nowOpen the automation trace or the log of the hub for the last daywhich rule ran at which time and what it did
check the time zone of the controllerRead the time and time zone setting of the hub and compare it with a trusted clocka controller on the wrong zone, which shifts every schedule

Never work on mains wiring or on systems that you are not trained and permitted to touch.

🔒 The debrief unlocks when you close the case. Finish the lab above.

Write the schedule note

Write the note for the facilities manager: the rules for a normal window and for a window that crosses midnight (start included, end excluded, the morning part belongs to the day after the listed day, an empty window is never active), which rules are active at the moments in the case and how many rules cross midnight, why the office was cold on Saturday morning (the supplier's schedule ended Friday's window at midnight), and how to prevent it (test the four edge moments, write two rules instead of one that crosses midnight, time zones and daylight saving, one place for the schedule, a visible week table).

0 words

🧪 Want to practise this on your own computer? See how to set up your lab →

📝

Knowledge Check

1 of 4

A rule runs 22:00 to 06:00 on Friday. Is it active on Saturday at 05:59?

Report a problem

About: /lessons/case-the-midnight-schedule