-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAlexa_Cuckoo_Clock.yaml
62 lines (58 loc) · 1.97 KB
/
Alexa_Cuckoo_Clock.yaml
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
50
51
52
53
54
55
56
57
58
59
60
61
62
#####################################################################
# Modified for Alexa from: https://github.com/CCOSTAN/Home-AssistantConfig
## Checks that target echo devices are set to volume level 0.3 and sets them if needed.
## Plays cuckoos for the hour number at each hour and 1 cuckoo on the half hour.
## Mp3 files must be stored in your Home Assistant www folder.
## Alter the folder addresses in the "variables" section to suit your situation
## Video describing how to use custom Mp3 with Alexa: https://www.youtube.com/watch?v=ZJlH6k9PY4I&t=18s
#####################################################################
#automations.yaml
- alias: Alexa - Notify - Cuckoo Clock
trigger:
- platform: time_pattern
minutes: '30'
- platform: time_pattern
minutes: '0'
id: hour
condition:
- condition: time
after: '08:59:00'
before: '20:31:00'
- condition: or
conditions:
- condition: state
entity_id: group.family
state: home
- condition: state
entity_id: input_boolean.guest_mode
state: 'on'
action:
- variables:
echo_devices:
- media_player.living_room_dot
- media_player.kitchen_dot
- choose:
- conditions: >
{{ (expand(echo_devices)
| map(attribute='attributes.volume_level') | map('float', 0)
| select('ne', 0.3) | list | count) | bool }}
sequence:
- service: media_player.volume_set
data:
entity_id: "{{ echo_devices }}"
volume_level: 0.3
- delay: 3
- service: notify.alexa_media
data:
message: "{{cuckoos}}"
target: "{{ echo_devices }}"
data:
type: tts
mode: restart
variables:
cuckoos: >-
{% if trigger.id != 'hour' %}
{{"<audio src='https://***YOUR_IP_HERE***/local/mp3/config-sounds-cuckoo-clock-01.mp3'/>\"}}
{% else %}
{{"<audio src='https://***YOUR_IP_HERE***/local/mp3/config-sounds-cuckoo-clock-\" + now().strftime(\"%I\") + \".mp3'/>\"}}
{% endif %}