/
CastControl.yaml
112 lines (108 loc) · 2.78 KB
/
CastControl.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
blueprint:
name: CastControl
description: Control TVs that are connected to a Chromecast based on status
domain: automation
input:
chromecast:
name: Chromecast
description: This is the Chromecast to be syncronized to the TV.
selector:
entity:
integration: cast
domain: media_player
time_to_wait_cc:
name: Time To Wait (Chromecast)
description: Time to wait for Things to Timeout in seconds.
default: 300
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
tv_switch:
name: TV Switch
description: This is the TV to be controled by the Chromecast.
selector:
entity:
domain: switch
time_to_wait_tv:
name: Time To Wait (TV)
description: Time to wait for Things to Timeout in seconds.
default: 600
selector:
number:
min: 0
max: 3600
unit_of_measurement: seconds
mode: restart
max_exceeded: silent
trigger:
- platform: state
id: "CC-ON"
entity_id: !input chromecast
to: "playing"
# - platform: state
# id: "CC-OFF"
# entity_id: !input chromecast
# from: "playing"
# - platform: state
# id: "CC-ON-TIMED"
# entity_id: !input chromecast
# to: "playing"
# for: !input time_to_wait_cc
- platform: state
id: "CC-OFF-TIMED"
entity_id: !input chromecast
from: "playing"
for: !input time_to_wait_cc
# - platform: state
# id: "TV-ON"
# entity_id: !input tv_switch
# to: "on"
# - platform: state
# id: "TV-OFF"
# entity_id: !input tv_switch
# to: "off"
- platform: state
id: "TV-OFF-TIMED"
entity_id: !input tv_switch
to: "off"
for: !input time_to_wait_tv
# - platform: state
# id: "TV-ON-TIMED"
# entity_id: !input tv_switch
# to: "on"
# for: !input time_to_wait_tv
action:
- choose:
- conditions:
- condition: trigger
id: "CC-ON"
- condition: state
entity_id: !input tv_switch
state: "off"
sequence:
- service: switch.turn_on
target:
entity_id: !input tv_switch
- conditions:
- condition: trigger
id: "CC-OFF-TIMED"
- condition: state
entity_id: !input tv_switch
state: "on"
sequence:
- service: switch.turn_off
target:
entity_id: !input tv_switch
- conditions:
- condition: trigger
id: "TV-OFF-TIMED"
- condition: state
entity_id: !input chromecast
state: "playing"
sequence:
- service: media_player.turn_off
target:
entity_id: !input chromecast
default: []