Grandfather Clock - Chime every 15 Minutes

What it does

This automation will run every 15 minutes and check for the current time. If the time is at 15, 30, 45 or 0 minutes past the hour, it will play one of four sound effects. Personally, I chose the westminster chimes as they remind me the most of the clock in my family home :slight_smile:

What you need

Four MP3 / WAV / SOUND files - one for each 15 minutes past the hour

Why?

Two reasons;

  1. Because it reminds me of home
  2. Because the speakers in my house are annoying and switch off if they don’t hear anything after X minutes (╯°□°)╯︵ ┻━┻
  3. I wanted to figure out how automations & scrpits work in HA; this is basically my hello world script :smiley:

Feedback is welcome but I think it works pretty good!

alias: Grandfather Clock
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.2
    target:
      entity_id: media_player.vlc_telnet
  - choose:
      - conditions:
          - condition: template
            value_template: "{{ now().minute == 15 }}"
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.vlc_telnet
            data:
              media_content_id: media-source://media_source/local/15minutes.wav
              media_content_type: audio/x-wav
            metadata:
              title: 15minutes.wav
              thumbnail: null
              media_class: music
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://media_source
      - conditions:
          - condition: template
            value_template: "{{ now().minute == 30 }}"
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.vlc_telnet
            data:
              media_content_id: media-source://media_source/local/30minutes.wav
              media_content_type: audio/x-wav
            metadata:
              title: 30minutes.wav
              thumbnail: null
              media_class: music
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://media_source
      - conditions:
          - condition: template
            value_template: "{{ now().minute == 45 }}"
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.vlc_telnet
            data:
              media_content_id: media-source://media_source/local/45minutes.wav
              media_content_type: audio/x-wav
            metadata:
              title: 45minutes.wav
              thumbnail: null
              media_class: music
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://media_source
      - conditions:
          - condition: template
            value_template: "{{ now().minute == 0 }}"
        sequence:
          - service: media_player.play_media
            target:
              entity_id: media_player.vlc_telnet
            data:
              media_content_id: media-source://media_source/local/Hour.wav
              media_content_type: audio/x-wav
            metadata:
              title: Hour.wav
              thumbnail: null
              media_class: music
              children_media_class: null
              navigateIds:
                - {}
                - media_content_type: app
                  media_content_id: media-source://media_source
mode: single

5 Likes

I like the idea of this.
I know this would likely be a lot of work, but could an strike option be added? I have a downloaded MP3 of Big Ben striking (12, but can edit to get 1 through to 11 out of it) and would quite like that as an hourly automation, striking the correct hour.
Obviously it would need an option to mute at night time :slight_smile:

2 Likes

This is legitimately an extremely helpful blueprint. This should be built in to home assistant. It’s simple but actually something useful for my ADHD Time Blind self haha

1 Like

Nice idea :rofl:
The first thing I would say is that this is not a blueprint, but an automation.
Read more about blueprints here: Automation blueprint tutorial - Home Assistant

The second thing is the way how you’re detecting whether it’s minute 0/15/30/45.
Instead of having 4 conditions in your automation, you can use the modulo operator: Modulo - Wikipedia

The third thing, with my 2nd thing applied, you can move the condition to the dedicated condition part in the file (which in your example is an empty array).

See this example of your new automation :smile:

alias: Grandfather Clock
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition:
  - condition: template
    value_template: "{{ now().minute % 15 == 0 }}"
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.2
    target:
      entity_id: media_player.vlc_telnet
  - service: media_player.play_media
    target:
      entity_id: media_player.vlc_telnet
    data:
      media_content_id: media-source://media_source/local/15minutes.wav
      media_content_type: audio/x-wav
    metadata:
      title: 15minutes.wav
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
mode: single

At the end of the day, these are just minor “nitpicks” and your automation works just fine as it is.

Oh and then the fourth thing, I think that by using the trigger like this in your automation

trigger:
  - platform: time_pattern
    minutes: /15

it already executes every 15 minutes, which would be 0/15/30/45.
I don’t believe that time_pattern trigger gets executed relative to the Home Assistant start time, but relative to the system time (I’m pretty sure about this actually).
So with that, you may be able to get rid of that condition and just have this:

alias: Grandfather Clock
description: ""
trigger:
  - platform: time_pattern
    minutes: /15
condition: []
action:
  - service: media_player.volume_set
    data:
      volume_level: 0.2
    target:
      entity_id: media_player.vlc_telnet
  - service: media_player.play_media
    target:
      entity_id: media_player.vlc_telnet
    data:
      media_content_id: media-source://media_source/local/15minutes.wav
      media_content_type: audio/x-wav
    metadata:
      title: 15minutes.wav
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
mode: single

I decided to leave my original example in there because it may give you an idea of how useful the modulo operator can be.

And now I need coffee :coffee:

1 Like

This doesn’t allow for the differing chimes at 15, 30, 45 and on the hour as a traditional Westminster chime would do.

1 Like

I told you I needed more coffee … I didn’t see the difference in media_content_id :rofl:
Thanks for waking me up

3 Likes

Interesting idea. Should add a customizable quiet time.

1 Like

Where do I put my .wav files?