You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.8 KiB

######################################################################
# @CCOSTAN - Follow Me on X
# For more info visit https://www.vcloudinfo.com/click-here
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
# -------------------------------------------------------------------
# Plays the number of cuckoos per hour and 1 on the half hour - Home Assistant automation behavior.
# Related Issue: 984
# Defines the Plays the number of cuckoos per hour and 1 on the half hour triggers, conditions, and actions.
# -------------------------------------------------------------------
# Notes: More Info and Video: https://www.vcloudinfo.com/2017/11/building-digital-cuckoo-clock-with-home.html
# Notes: Patriotic cuckoos run July 3-4, last Monday in May, and first Monday in September.
# Notes: Clock WAVs are served from /local/sounds so Chromecast fetches them from Home Assistant.
######################################################################
- alias: Cuckoo Clock
id: 33dcd8e2-e87c-4d18-82bc-c7f9b53a1624
mode: restart
trigger:
- platform: time_pattern
minutes: 0
- platform: time_pattern
minutes: 30
condition:
- condition: time
after: '09:00:00'
before: '22:00:00'
- condition: or #Either we are home or Guest_Mode is on.
conditions:
- condition: state
entity_id: group.family
state: 'home'
- condition: state
entity_id: input_boolean.guest_mode
state: 'on'
action:
- service: script.amp_settings
data:
media_player: 'media_player.livingroomcc'
volume_level: 0.22
- wait_template: "{{ not is_state('media_player.livingroomCC', 'playing') }}"
- service: media_player.play_media
data:
entity_id: media_player.livingroomCC
media_content_id: >
{% set month = now().strftime("%B") %}
{% set is_july_celebration = now().month == 7 and now().day in [3, 4] %}
{% set is_memorial_day = now().month == 5 and now().weekday() == 0 and now().day >= 25 %}
{% set is_labor_day = now().month == 9 and now().weekday() == 0 and now().day <= 7 %}
{% set is_patriotic_day = is_july_celebration or is_memorial_day or is_labor_day %}
{% set base = "http://192.168.10.10:8123/local/sounds/" %}
{% if is_patriotic_day %}
{% set folder = 'july-clock' %}
{% elif month == 'October' %}
{% set folder = 'october-clock' %}
{% elif month == 'December' %}
{% set folder = 'december-clock' %}
{% else %}
{% set folder = 'cuckoo-clock' %}
{% endif %}
{% set file = 'cuckoo-clock-01.wav' if now().strftime("%M")|int == 30 else 'cuckoo-clock-' ~ now().strftime("%I") ~ '.wav' %}
{{ base ~ folder ~ '/' ~ file }}
media_content_type: audio/wav

Powered by TurnKey Linux.