forked from dashdrum/esphome
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlr_ir.yaml
182 lines (153 loc) · 4.85 KB
/
lr_ir.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
substitutions:
device_name: lr_ir
upper_device_name: Living Room IR
switch_prefix: IR
tv_state_topic: $device_name/living_room_tv/state
esphome:
name: $device_name
platform: ESP8266
board: d1_mini
wifi: !include include/wifi_iot.yaml
captive_portal:
web_server:
port: 80
# Enable logging
logger:
level: INFO
# Enable Home Assistant API
# api:
ota:
mqtt: !include include/mqtt.yaml
output: !include include/onboard_led.yaml
sensor:
- platform: wifi_signal
name: $upper_device_name WiFi Signal
update_interval: 60s
icon: mdi:wifi
text_sensor:
- platform: mqtt_subscribe
id: lr_tv_state
topic: $tv_state_topic
icon: mdi:television
# binary_sensor:
# - platform: template
# name: $upper_device_name TV State
# icon: mdi:television
# lambda: |-
# if (id(lr_tv_state).state == "on") {
# return true;
# } else {
# return false;
# }
script:
# While this script is running the receiver will ignore any power codes
- id: code_repeat_block
then:
- delay: 1.5s
remote_receiver:
pin:
number: GPIO2 # D4
inverted: true
mode:
input: true
pullup: true
# dump: all
on_sony:
lambda: |-
if (x.data == 0xA90){
if ( id(code_repeat_block).is_running() == false){
id(code_repeat_block).execute();
if (id(lr_tv_state).state == "on") {
id(mqtt_client).publish("lr_ir/living_room_tv/state", "off");
} else {
id(mqtt_client).publish("lr_ir/living_room_tv/state", "on");
}
}
}
remote_transmitter:
pin: GPIO0 # D3
carrier_duty_percent: 50%
id: trans
button:
- platform: restart
name: $upper_device_name Restart
- platform: template
name: $upper_device_name Sony TV Power
on_press:
remote_transmitter.transmit_sony:
data: 0xA90
nbits: 12
repeat:
times: 2
- platform: template
name: $upper_device_name Sony TV Mute
on_press:
remote_transmitter.transmit_sony:
data: 0x290
nbits: 12
repeat:
times: 2
- platform: template
name: $upper_device_name TV-Cable On
on_press:
#. TV power on, Cable Menu, Cable power twice
- if:
condition:
# Checks if tv is already on
text_sensor.state:
id: lr_tv_state
state: 'off'
then:
- remote_transmitter.transmit_sony:
data: 0xA90
nbits: 12
repeat:
times: 2
- delay: 300ms
- remote_transmitter.transmit_raw:
code: [ 8989, -4488, 502, -4489, 505, -2225, 505, -2232, 475, -4515,
476, -4518, 500, -2236, 496, -2227, 506, -2228, 505, -2228,
505, -2229, 503, -2229, 502, -2231, 502, -2231, 501, -4491,
500, -4490, 502, -2228, 505]
carrier_frequency: 38kHz
- delay: 300ms
- remote_transmitter.transmit_raw:
code: [ 8900,-4300, 600,-2150, 600,-4300, 600,-2100, 600,-4350, 600,-2150,
600,-2150, 600,-2150, 600,-2100, 600,-2150, 600,-2150, 600,-2150,
600,-2150, 600,-2150, 600,-4300, 600,-4300, 600,-2150, 600]
carrier_frequency: 38kHz
- delay: 300ms
- remote_transmitter.transmit_raw:
code: [ 8900,-4300, 600,-2150, 600,-4300, 600,-2100, 600,-4350, 600,-2150,
600,-2150, 600,-2150, 600,-2100, 600,-2150, 600,-2150, 600,-2150,
600,-2150, 600,-2150, 600,-4300, 600,-4300, 600,-2150, 600]
carrier_frequency: 38kHz
- platform: template
name: $upper_device_name TV-Cable Off
on_press:
#. TV power on, Cable Menu, Cable power one
- if:
condition:
# Only turn off the TV if it is actually on
text_sensor.state:
id: lr_tv_state
state: 'on'
then:
- remote_transmitter.transmit_sony:
data: 0xA90
nbits: 12
repeat:
times: 2
- delay: 300ms
- remote_transmitter.transmit_raw:
code: [ 8989, -4488, 502, -4489, 505, -2225, 505, -2232, 475, -4515,
476, -4518, 500, -2236, 496, -2227, 506, -2228, 505, -2228,
505, -2229, 503, -2229, 502, -2231, 502, -2231, 501, -4491,
500, -4490, 502, -2228, 505]
carrier_frequency: 38kHz
- delay: 300ms
- remote_transmitter.transmit_raw:
code: [ 8900,-4300, 600,-2150, 600,-4300, 600,-2100, 600,-4350, 600,-2150,
600,-2150, 600,-2150, 600,-2100, 600,-2150, 600,-2150, 600,-2150,
600,-2150, 600,-2150, 600,-4300, 600,-4300, 600,-2150, 600]
carrier_frequency: 38kHz