Skip to content

Recipe - Seasonal Greetings

Purpose

Add a Xmas, Halloween or whatever else flavour to messages;

Implementation

A scenario using Home Assistant date conditions that applies a message template with Amazon SSML only to specific delivery config, in this case one called alexa_general, and to the email text.

The enabled: with null value is used so that the delivery will be overridden only if its has already been selected before this scenario was applied, otherwise the scenario would add on these deliveries to every notification during the date condition period.

Example Configuration

Use a scenario with a condition to identify when in a date range.

The speech markup requires use of the speak rather than announce entities provided by Alexa Devices integration.

scenarios:
    xmas:
      alias: Christmas season
      conditions:
        condition: or
        conditions:
          - "{{ (12,24) <= (now().month, now().day) <= (12,31) }}"
          - "{{ (1,1) <= (now().month, now().day) <= (1,1) }}"
      delivery:
       email_general:
            data:
              message_template: '{{notification_message}} Ho Ho Ho!'
       alexa_general:
            enabled:
            data:
              message_template: '{{notification_message}}<break time="1s"><say-as interpret-as="interjection">bah humbug</say-as>'

    halloween:
      alias: Spooky season
      conditions:
        condition: and
        conditions:
          - "{{ (10,31) == (now().month, now().day) }}"
      delivery:
          alexa_general:
            enabled:
            data:
              message_template: '{{notification_message}}<break time="1s"><audio src="soundbank://soundlibrary/horror/horror_04"/>'

    birthdays:
      alias: Family birthdays
      conditions:
        condition: or
        conditions:
          - "{{ (5,23) == (now().month, now().day) }}"
          - "{{ (11,9) == (now().month, now().day) }}"
      delivery:
       alexa_general:
            enabled:
            data:
              message_template: '{{notification_message}}<break time="1s"><say-as interpret-as="interjection">hip hip hooray</say-as>'

Variations

The Chime Transport Adaptor has lots more ways of doing this.

Set up aliases for common chimes, and a secondary seasonal version, in the Chime transport defaults:

transports:
  chime:
    delivery_defaults:
      options:
        chime_aliases:
          doorbell:
            alexa_devices: amzn_sfx_doorbell_chime_02
            switch:
              target: switch.chime_ding_dong
          xmas_doorbell: christmas_05
delivery:
  doorbell_rang:
    transport: chime
    data:
      chime_tune: doorbell

Then create a date condition scenario, that overrides the chime alias for your doorbell_rang delivery:

scenarios:
    xmas:
      alias: Christmas season
      conditions:
        condition: or
        conditions:
          - "{{ (12,24) <= (now().month, now().day) <= (12,31) }}"
          - "{{ (1,1) <= (now().month, now().day) <= (1,1) }}"
      delivery:
        doorbell_rang:
          enabled:
          data:
            chime_tune: xmas_doorbell

Christmas Package

A Home Assistant package is a single YAML file that can hold settings for several integrations. This one has the Christmas scenario, plus the helpers to tune it, so that once it is in place you can change these from the Home Assistant UI, with no more YAML:

  • How many days before the 25th Christmas starts, and how many days after it ends
  • Which tune the doorbell plays
  • The greeting added to the end of messages. Leave it blank for none.

Critical and high priority notifications don't get the greeting, so that a smoke alarm doesn't wish you a merry Christmas.

Setting it up

  1. If you don't have packages already, create a packages directory next to configuration.yaml, and add this to configuration.yaml. If there is a homeassistant: section already, add only the packages line to it.

    configuration.yaml
    homeassistant:
      packages: !include_dir_named packages
    
  2. Save the file below as packages/supernotify_xmas.yaml, or download it.

  3. Change doorbell_rang to the name of your own chime delivery. If you don't have one, remove doorbell_rang and the three lines below it. A scenario that names a delivery which doesn't exist is ignored altogether, with a repair to say so.
  4. If you already have a scenario called xmas, remove it or rename it, since the same name can't be in both places.
  5. Restart Home Assistant.
  6. Find the helpers by searching for Christmas in Settings → Devices & services → Helpers, or add them to a dashboard, and set them. Until you do, Christmas is only the 25th, with no greeting.
packages/supernotify_xmas.yaml
# Christmas doorbell and greeting for Supernotify, tuned from the Home Assistant UI
# https://supernotify.rhizomatics.org.uk/recipes/seasonal_greetings/

input_number:
  xmas_days_before:
    name: Christmas starts, days before the 25th
    icon: mdi:calendar-start
    min: 0
    max: 24
    step: 1
    mode: box
  xmas_days_after:
    name: Christmas ends, days after the 25th
    icon: mdi:calendar-end
    min: 0
    max: 12
    step: 1
    mode: box

input_select:
  xmas_tune:
    name: Christmas doorbell tune
    icon: mdi:music
    options:
      - christmas_05
      - bell_02
      - amzn_sfx_church_bell_1x_02

input_text:
  xmas_greeting:
    name: Christmas greeting
    icon: mdi:pine-tree

supernotify:
  scenarios:
    xmas:
      alias: Christmas season
      conditions:
        - >-
          {% set today = now().date() %}
          {% set this_xmas = today.replace(month=12, day=25) %}
          {% set last_xmas = this_xmas.replace(year=today.year - 1) %}
          {% set before = states('input_number.xmas_days_before') | int(0) %}
          {% set after = states('input_number.xmas_days_after') | int(0) %}
          {{ -before <= (today - this_xmas).days <= after or (today - last_xmas).days <= after }}
      delivery:
        doorbell_rang: # change this to the name of your own chime delivery
          enabled:
          data:
            chime_tune: "{{ states('input_select.xmas_tune') }}"
        .*: # every other delivery
          enabled:
          data:
            message_template: >-
              {{ notification_message }}
              {%- if has_value('input_text.xmas_greeting') and notification_priority not in ('critical', 'high') %}
              {{ states('input_text.xmas_greeting') }}
              {%- endif %}

Changes to the helpers apply from the next notification. To switch Christmas off early, turn off the xmas scenario's switch.

The tunes are the ones that Home Assistant's Alexa Devices integration has for Christmas and for bells. Add others to the options list, such as your own chime aliases or tunes for other kinds of device, then use Developer tools → YAML → Input selects to reload it.

The scenario only changes deliveries that are already selected, so it never causes a notification to be sent anywhere new.