Sefirat Ha'omer / Omer Counting TTS Reminder Automation

I figured some people might be interested in using this Sefirat Ha’omer reminder automation I put together.

I’m using Google TTS for English-language announcements, and optionally, you can add a Hebrew TTS service to have it recite the Omer in Hebrew.

First, make sure you have TTS service(s) set up in your configuration.yaml:

# Text to speech
tts:
  - platform: google_translate
    service_name: google_say
  - platform: reversotts
    language: 'he-IL-Asaf-Hebrew'

For Hebrew TTS, I am using the ReversoTTS component which can be installed easily via HACS.

You will also need to have the Jewish Calendar integration set up in your configuration.yaml:

# Jewish Calendar
jewish_calendar:

Next you want to create an automation:

alias: Sefirat HaOmer (English and Hebrew)
description: ''
trigger:
  - platform: sun
    event: sunset
    offset: '00:44:00'
condition:
  - condition: numeric_state
    entity_id: sensor.jewish_calendar_day_of_the_omer
    above: '1'
    below: '50'
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.5
    target:
      entity_id: media_player.<YOUR_MEDIA_DEVICE>
  - service: tts.google_say
    data:
      entity_id: media_player.<YOUR_MEDIA_DEVICE>
      message: >
        {% set weeksct = states('sensor.jewish_calendar_day_of_the_omer') | int
        // 7 %} {% set daysct = states('sensor.jewish_calendar_day_of_the_omer') |
        int % 7 %} {%- macro suffix(d) %} {%- set sfx = {1:'st',2:'nd',3:'rd'}
        %} {{- 'th' if 11 <= d <= 13 else sfx.get(d%10, 'th') }} {%- endmacro %}
        {% set date = states('sensor.jewish_calendar_day_of_the_omer') |
        timestamp_custom('%d') |int %} Today is the {{ date }}{{ suffix(date) }}
        day of the Omer which is {{ weeksct }} {% if weeksct == 1 %} week {%
        elif weeksct > 1 %} weeks {% endif %}{% if daysct == 1 %} and {{ daysct }}
        day. {% elif daysct >1 %}and {{ daysct }} days.{% endif %}
mode: single

To have it counted in Hebrew, substitute this service and message in the automation above:

service: tts.reversotts_say
data:
  entity_id: media_player.<YOUR_MEDIA_DEVICE>
  message: >
    {% set OmerDays = states('sensor.jewish_calendar_day_of_the_omer') | int %}
    {% set weeksct = OmerDays | int // 7 %} {% set daysct = OmerDays | int % 7
    %} {% set Base10Ones = OmerDays | int % 10 %} {% set Base10Tens = OmerDays
    |int - Base10Ones %}  הַיּוֹם  {% if OmerDays < 21 %} {{ OmerDays }}   {%
    elif OmerDays > 20 %} {{ Base10Ones }} וְ- {{ Base10Tens }}  {% endif %} 
    יָמִים לָעֹֽמֶר {% if weeksct < 2 %} שֶׁהֵם שָׁבוּעַ אֶחָד {% elif weeksct >
    1 %}  שֶׁהֵם {{ weeksct }} שָׁבוּעוֹת {% endif %} {% if daysct == 1 %}
    וְיוֹם אֶחָד {% elif daysct >1 %} וְ- {{ daysct }} יָמִים{% endif %}

Notes:

  1. This automation triggers 44 minutes after sunset. I have tried multiple times to have it trigger using “jewish_calendar_t_set_hakochavim” but it’s not working for me- does anyone know what I’m doing wrong?
  - platform: template
    value_template: |-
      trigger:
        - platform: template
          value_template: "{{ as_timestamp(states('sensor.jewish_calendar_t_set_hakochavim'))|timestamp_custom('%H:%M', true) == states('sensor.time')  }}"
  1. The Hebrew TTS follows the Sephardic schema:
    Today is the nth day of the Omer, [which is x week(s)] [and y day(s)].

One issue it has is that Hebrew TTS services don’t have a way to specify a gender to use for the number, day or week counts (e.g. חמש or חמישה)

If anyone would like to help refine the Hebrew TTS verbiage, please comment below!

4 Likes

i fixed the first week and used Sfard

{% set totalDays = states('sensor.jewish_calendar_day_of_the_omer') | int %}
{% set weeks = totalDays // 7 %}
{% set daysInWeek = totalDays % 7 %}
{% set lsb = totalDays % 10 %}
{% set msb = totalDays - lsb %}
הַיּוֹם
{% if totalDays == 1 %}
  יוֹם אֶחָד
{% elif totalDays > 1 and  totalDays < 7 %}
  {{ totalDays }} יָמִים
{% else %}
    {% if totalDays < 21  or lsb == 0 %}
        {{ totalDays }}
    {% else %}
        {{ lsb }} וְ- {{ msb }}
    {% endif %}
    {% if totalDays > 10 %}
      יוֹם
    {% else %}
      יָמִים
    {% endif %}
    {% if weeks < 2 %}
        שֶׁהֵם שָׁבוּעַ אֶחָד 
    {% else %} 
        שֶׁהֵם {{ weeks }} שָׁבוּעוֹת
    {% endif %}
    {% if daysInWeek == 1 %}
        וְיוֹם אֶחָד
    {% elif daysInWeek > 1 %}
        וְ- {{ daysInWeek }} יָמִים
    {% endif %}
{% endif %}

this is for edot hamizrach

{% set totalDays = states('sensor.jewish_calendar_day_of_the_omer') | int %}
{% set weeks = totalDays // 7 %}
{% set daysInWeek = totalDays % 7 %}
{% set lsb = totalDays % 10 %}
{% set msb = totalDays - lsb %}
הַיּוֹם
{% if totalDays == 1 %}
  יוֹם אֶחָד לָעֹֽמֶר
{% elif totalDays > 1 and  totalDays < 7 %}
  {{ totalDays }} יָמִים לָעֹֽמֶר
{% else %}
    {% if totalDays < 21  or lsb == 0 %}
        {{ totalDays }}
    {% else %}
        {{ lsb }} וְ- {{ msb }}
    {% endif %}
    {% if totalDays > 10 %}
      יוֹם
    {% else %}
      יָמִים
    {% endif %}
    לָעֹֽמֶר
    {% if weeks < 2 %}
        שֶׁהֵם שָׁבוּעַ אֶחָד 
    {% else %} 
        שֶׁהֵם {{ weeks }} שָׁבוּעוֹת
    {% endif %}
    {% if daysInWeek == 1 %}
        וְיוֹם אֶחָד
    {% elif daysInWeek > 1 %}
        וְ- {{ daysInWeek }} יָמִים
    {% endif %}
{% endif %}

1 Like

I wanted to expand your code to include the proper hebrew phrase, but this turned out to be a good example of xkcd 1205 where it was easier to hardcode an array rather then generate it programmatically.

Creating a “Helper → Template Sensor”:

{% set omer_days = {
  1: "יוֹם אֶחָד",
  2: "שְׁנֵי יָמִים",
  3: "שְׁלֹשָׁה יָמִים",
  4: "אַרְבָּעָה יָמִים",
  5: "חֲמִשָּׁה יָמִים",
  6: "שִׁשָּׁה יָמִים",
  7: "שִׁבְעָה יָמִים שֶׁהֵם שָׁבוּעַ אֶחָד",
  8: "שְׁמוֹנָה יָמִים שֶׁהֵם שָׁבוּעַ אֶחָד וְיוֹם אֶחָד",
  9: "תִּשְׁעָה יָמִים שֶׁהֵם שָׁבוּעַ אֶחָד וּשְׁנֵי יָמִים",
  10: "עֲשָׂרָה יָמִים שֶׁהֵם שָׁבוּעַ אֶחָד וּשְׁלֹשָׁה יָמִים",
  11: "אַחַד עָשָׂר יוֹם שֶׁהֵם שָׁבוּעַ אֶחָד וְאַרְבָּעָה יָמִים",
  12: "שְׁנֵים עָשָׂר יוֹם שֶׁהֵם שָׁבוּעַ אֶחָד וַחֲמִשָּׁה יָמִים",
  13: "שְׁלוֹשָׁה עָשָׂר יוֹם שֶׁהֵם שָׁבוּעַ אֶחָד וְשִׁשָּׁה יָמִים",
  14: "אַרְבָּעָה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת",
  15: "חֲמִשָּׁה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וְיוֹם אֶחָד",
  16: "שִׁשָּׁה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וּשְׁנֵי יָמִים",
  17: "שִׁבְעָה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וּשְׁלֹשָׁה יָמִים",
  18: "שְׁמוֹנָה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וְאַרְבָּעָה יָמִים",
  19: "תִּשְׁעָה עָשָׂר יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וַחֲמִשָּׁה יָמִים",
  20: "עֶשְׂרִים יוֹם שֶׁהֵם שְׁנֵי שָׁבוּעוֹת וְשִׁשָּׁה יָמִים",
  21: "אֶחָד וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת",
  22: "שְׁנַיִם וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וְיוֹם אֶחָד",
  23: "שְׁלֹשָׁה וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וּשְׁנֵי יָמִים",
  24: "אַרְבָּעָה וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וּשְׁלֹשָׁה יָמִים",
  25: "חֲמִשָּׁה וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וְאַרְבָּעָה יָמִים",
  26: "שִׁשָּׁה וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וַחֲמִשָּׁה יָמִים",
  27: "שִׁבְעָה וְעֶשְׂרִים יוֹם שֶׁהֵם שְׁלֹשָׁה שָׁבוּעוֹת וְשִׁשָּׁה יָמִים",
  28: "שְׁמוֹנָה וְעֶשְׂרִים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת",
  29: "תִּשְׁעָה וְעֶשְׂרִים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וְיוֹם אֶחָד",
  30: "שְׁלֹשִׁים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וּשְׁנֵי יָמִים",
  31: "אֶחָד וּשְׁלֹשִׁים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וּשְׁלֹשָׁה יָמִים",
  32: "שְׁנַיִם וּשְׁלֹשִׁים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וְאַרְבָּעָה יָמִים",
  33: "שְׁלֹשָׁה וּשְׁלֹשִׁים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וַחֲמִשָּׁה יָמִים",
  34: "אַרְבָּעָה וּשְׁלֹשִׁים יוֹם שֶׁהֵם אַרְבָּעָה שָׁבוּעוֹת וְשִׁשָּׁה יָמִים",
  35: "חֲמִשָּׁה וּשְׁלֹשִׁים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת",
  36: "שִׁשָּׁה וּשְׁלֹשִׁים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וְיוֹם אֶחָד",
  37: "שִׁבְעָה וּשְׁלֹשִׁים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וּשְׁנֵי יָמִים",
  38: "שְׁמוֹנָה וּשְׁלֹשִׁים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וּשְׁלֹשָׁה יָמִים",
  39: "תִּשְׁעָה וּשְׁלֹשִׁים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וְאַרְבָּעָה יָמִים",
  40: "אַרְבָּעִים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וַחֲמִשָּׁה יָמִים",
  41: "אֶחָד וְאַרְבָּעִים יוֹם שֶׁהֵם חֲמִשָּׁה שָׁבוּעוֹת וְשִׁשָּׁה יָמִים",
  42: "שְׁנַיִם וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת",
  43: "שְׁלֹשָׁה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וְיוֹם אֶחָד",
  44: "אַרְבָּעָה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וּשְׁנֵי יָמִים",
  45: "חֲמִשָּׁה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וּשְׁלֹשָׁה יָמִים",
  46: "שִׁשָּׁה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וְאַרְבָּעָה יָמִים",
  47: "שִׁבְעָה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וַחֲמִשָּׁה יָמִים",
  48: "שְׁמוֹנָה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁשָּׁה שָׁבוּעוֹת וְשִׁשָּׁה יָמִים",
  49: "תִּשְׁעָה וְאַרְבָּעִים יוֹם שֶׁהֵם שִׁבְעָה שָׁבוּעוֹת",
} %}
{% set omer_day = states('sensor.jewish_calendar_day_of_the_omer') | int %}
{% if omer_day in omer_days %}
  הַיּוֹם {{ omer_days[omer_day] }} לָעֹֽמֶר/בָּעֹֽמֶר
{% else %}
  Unknown Omer Day
{% endif %}
1 Like

I don’t know if you still care 3 years later lol, but:
{{ now() >= states('sensor.jewish_calendar_t_set_hakochavim') | as_datetime + timedelta(minutes=10)}}

This is what I think it is – where10 being how many minutes in addition, I just put that as trigger and seems to work

1 Like