-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deurbel.yaml
115 lines (104 loc) · 4.07 KB
/
deurbel.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
- id: doorbell_press_action
alias: Deurbel wordt ingedrukt
description: |
Wanneer er op de deurbel gedrukt wordt:
- Stuur een melding naar Sander wanneer hij aan het thuiswerken is.
- Stuur een melding naar de tv en start de stream wanneer de tv aan staat.
- Pauzeer de tv als Jellyfin, Netflix of Youtube aan staat.
- Pauzeer Ziggo wanneer die geen lineaire tv afspeelt.
mode: single
triggers:
- trigger: state
entity_id: binary_sensor.deurbel_ringing
from: "off"
to: "on"
actions:
- variables:
message_title: Ding dong!
message_text: Iemand staat bij de deur
tv_sources_to_pause:
- Jellyfin
- Netflix
- YouTube
tv_current_source: "{{ state_attr('media_player.lg_c9', 'source') }}" # Will be None when the tv is off.
internal_url: !secret internal_url
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.tt_macbook_in_thuis_kantoor_en_aan
state: "on"
sequence:
- alias: Notify Sander when he's working from home, he might not hear the doorbell as he's really busy
action: notify.sander
data:
title: "{{ message_title }}"
message: "{{ message_text }}"
data:
group: deurbel
entity_id: camera.deurbel
url: /dashboard-buiten/voortuin
- choose:
- conditions:
- condition: state
entity_id: media_player.lg_c9
state: "on"
sequence:
- alias: Notify tv when on
action: notify.lg_c9
data:
message: "{{ message_title }} {{ message_text }}"
- choose:
- conditions:
- "{{ state_attr('media_player.lg_c9', 'source') in tv_sources_to_pause }}"
sequence:
- alias: Pause tv for given sources
action: media_player.media_pause
entity_id: media_player.lg_c9
- conditions:
- "{{ not is_state('media_player.mediabox', ['idle', 'off', 'unavailable', 'unknown']) }}"
- "{{ is_state_attr('media_player.lg_c9', 'source', 'Ziggo') }}"
- "{{ not state_attr('media_player.mediabox', 'play_mode') in [null, 'linear'] }}"
sequence:
- alias: Pause Ziggo, but not when watching linear tv
action: media_player.media_pause
entity_id: media_player.mediabox
# - alias: Start the camera stream
# action: button.press
# target:
# entity_id: button.deurbel_start_p2p_stream
# - alias: Wait till the stream is ready
# wait_for_trigger:
# - trigger: state
# entity_id: sensor.deurbel_stream_status
# to: StreamStatus.STREAMING
# timeout:
# seconds: 5
# continue_on_timeout: false
# - alias: Show camera stream in the web browser on the tv
# action: webostv.command
# data:
# entity_id: media_player.lg_c9
# command: system.launcher/open
# payload:
# target: "{{ internal_url }}/api/camera_proxy_stream/camera.deurbel?token={{ state_attr('camera.deurbel', 'access_token') }}"
# - alias: Wait a little
# delay:
# seconds: 15
# - alias: Stop the camera stream
# action: button.press
# target:
# entity_id: button.deurbel_stop_p2p_stream
# - choose:
# - conditions:
# - "{{ is_state_attr('media_player.lg_c9', 'source', 'Webbrowser') }}"
# - "{{ tv_current_source != None }}"
# sequence:
# - alias: Return to the previous source on the tv
# action: media_player.select_source
# data:
# source: "{{ tv_current_source }}"
# target:
# entity_id: media_player.lg_c9
# Don't trigger again for a few seconds.
- delay:
seconds: 5