Automating an Entire Day

Context

Some Jewish communities follow the custom of avoiding the use of electronic devices on Shabbat (25 hours beginning on Friday night). Pre-programming devices, however, is permitted, making this one of the earliest home automation challenges.

Pre-IoT Solutions

To understand the motivation for our solution, let’s review older approaches and their limitations:

  1. Standalone timers in switches and outlets (e.g., for lights, A/C, blinds, etc.):

    • Programming is cumbersome and time-consuming.
    • Each timer must be programmed individually.
    • Timers must be manually enabled and disabled.
  2. Breaker box timers:

    • Space in the breaker box is limited, restricting the number of timers that can be installed.
    • Each timer requires a dedicated circuit (e.g., kitchen lights may be controlled, but the refrigerator must stay powered).
    • Installation is only practical during construction.

Requirements

From these limitations, we defined the following goals:

  1. Timers should automatically get enabled/disabled at Shabbat start and end, respectively.
  2. Programming must be simple - easy enough for a 10-year-old to set up their own room.
  3. There should be no limit on the number of timers.
  4. A single timer should be able to control multiple devices, even of different types (e.g., lights and windows), reducing the programming burden.
  5. The solution must be highly reliable since manual intervention is not allowed.

Enable / Disable Automation

Home Assistant’s Jewish Calendar integration provides the binary sensor issur_melacha_in_effect, which indicates when Shabbat restrictions apply (true during Shabbat, false otherwise).

We identified and fixed several inaccuracies in its logic (PR1, PR2, PR3).

In practice, there are times when automation should be disabled altogether - for example, when the family is away. To handle this, we introduced a global manual flags:

template:
  - binary_sensor:
    - name: shabbat_timers_in_effect
      state: >-
        {{ 
          is_state('binary_sensor.jewish_calendar_issur_melacha_in_effect', 'on') and
          is_state('input_boolean.shabbat_timers', 'on')
        }}

The Timers

At the time, HA lacked a scheduler that supported multiple time ranges. We initially proposed a new integration, input_timetable (PR1, PR2, PR3). After discussion, HA’s core team opted for a weekly-based solution, now released as the schedule integration.

Since we required a daily scheduler, we moved our implementation to HACS as daily_schedule, along with its Lovelace card.

Since the automation rules are non-trivial, we created a script to generate them automatically from a template. All related files (script, template, input, and output) are available here. The generated automations are included in configuration.yaml via:

automation timers: !include timers/automations.yaml

Reliability

The reliability of the automation is critical since it’s not allowed to manually turn a device on or off. However, in such a distributed system with dozens of devices, there are intermediate glitches which can cause a command to get lost. To improve the reliability we introduced a new integration retry which keeps trying to bring the device to the desired state (see also this post). In addition, the automations are running every 15 minutes to add another layer of assurance. We saw a drastic reliability improvement by implementing the above.

Summary

The solution meets the original objectives:

  1. Timers are enabled/disabled automatically at Shabbat start/end.
  2. Programming is simple, with a clear and friendly UI.
  3. There is no practical limit to the number of timers.
  4. Timers can control multiple devices, even across different types.
  5. The solution is highly trustworthy.

Hopefully, some of these techniques will inspire your own home automation projects.

Enjoy!

5 Likes