Automating an Entire Day


It’s a custom of some Jewish people to avoid controlling electronic devices on Shabbat (a full day starting on Friday night.) Pre-programing is ok, which makes it one of the older home automation challenges.


To understand how the solution was born, let’s start with a short description of the older solutions out there and their disadvantages (i.e. the requirements):

  1. There are switches and electric outlets with built-in timers (e.g. for lights, A/C, windows, blinds, etc’). Their disadvantages:

    • Programing is typically cumbersome and time-consuming.
    • Each timer needs to be programmed separately.
    • Each timer needs to be enabled and disabled manually.
  2. There are timers which can be installed in the breaker box. Their disadvantages:

    • Space inside the breaker box is limited, and so is the amount of timers which can be installed.
    • There is a need for a direct line for each timer (e.g. kitchen lights should be controlled, but the refrigerator should never stop.) Therefore, it’s an option only during construction.


Based on the above, the following goals were set for the project:

  1. The timers should be enabled and disabled automatically (when Shabbat starts and ends.)
  2. Programming the timers should be very simple, and can be done by a 10-years old kid. This way each household member can set the timers for their room.
  3. The amount of timers shouldn’t have a limit.
  4. A timer can control any number of devices, including different types (e.g. lights and windows.) This grouping simplifies the programming burden.

Enable / Disable Automation

Home Assistant has the Jewish Calendar integration, which includes the binary sensor issur_melacha_in_effect. This is the flag needed to know when the timers should be enabled and disabled (the flag is set to true during Shabbat and to false otherwise.)

There were a few inaccuracies with its logic, but we fixed those (PR1, PR2, PR3).

There are cases when the entire automation should be disabled. For example, when the family is away from home. Therefore, manual flags are also needed. We decided to create a global flag, as well as a per-room flag. So, the automation should run when all 3 flags are set (issur_melacha_in_effect, the global flag, the room’s flag). We use the HA’s group integration with the all option for achieving this AND logic. Here is how it looks:

    - binary_sensor.jewish_calendar_issur_melacha_in_effect
    - input_boolean.shabbat_timers
  all: true

    - group.shabbat_timers_in_effect
    - input_boolean.shabbat_timers_main_floor
  all: true

The Timers

HA didn’t have a scheduler element for the job which supports a list of time ranges. We created a proposal for a new integration input_timetable (PR1, PR2, PR3). However, after discussions of HA internal team it was decided to go with a weekly version, which is now the schedule integration.

Since we need a daily scheduler (and not weekly), we moved the code to HACS and added a daily_schedule integration and its corresponding Lovelace card.


A typical automation rule with input_timetable looks like this:

- id: shabbat_hot_plate
  alias: shabbat_hot_plate
    - platform: state
      entity_id: group.shabbat_timers_in_effect_main_floor, input_timetable.shabbat_hot_plate
  condition: "{{ is_state('group.shabbat_timers_in_effect_main_floor', 'on') }}"
    - service: switch.{{ iif(is_state('input_timetable.shabbat_hot_plate', 'on'), 'turn_on', 'turn_off') }}
      entity_id: switch.hot_plate

Since the rule is not trivial, we decided to wrap it with a simple script for generating unified automation rules. The script can be found here, the input file is here, and the output file is here. Since we do have other automation rules, we use the following directive in the configuration.yaml to merge the 2 files:

automation: !include_dir_merge_list automations


The solution is used for over a year now, and it achieved the original objectives:

  1. The timers are enabled and disabled automatically.
  2. Programming the timers is straightforward through the timetable UI.
  3. The amount of timers (timetable entities) is not limited.
  4. A timer (timetable entity) can control any number of devices, including different types.

Hopefully you found some of the techniques applicable for your home automation projects. Enjoy!