-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgencodes.py
53 lines (49 loc) · 4.73 KB
/
gencodes.py
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
import tinytuya
from tinytuya.Contrib import RFRemoteControlDevice
buttons={
"play/pause": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJtaGRTQkljQlVnU0hBWWNCVWdSTkFWSUVod0ZTQkljQlVnUk5BVklFaHdGU0JJY0JVZ1JTQkljQlVnU0hBWWNCVWdSU0JJY0JVZ1NIQVljQlVnUlNCSWNCaHdGU0JGSUVod0dIQVZJRVVnU0hBVklFaHdGU0JJY0Jod0ZTQkljQlVnUlNCSWNCaHdGU0JJY0JVZ1NIQVZJRVVnUk5BVklFIiwibHYiOlswXX0=",
"1": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJYaHBTQkljQlVnU0hBWWNCVWdTSEFWSUVod0ZTQkljQlVnU0hBVklFaHdGU0JJY0JVZ1JTQkV3QlVnU0hBWWNCVWdSU0JJY0JVZ1NIQVljQlVnUlNCSWNCaHdGU0JGSUVUQUdIQVZJRVVnU0hBVklFaHdGU0JJY0JVZ1NIQVZJRWh3R0hBVklFVWdTSEFZY0JVZ1NIQVZJRWh3RlNCSWNCIiwibHYiOlswXX0=",
"2": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJmUmRGQklNQlJRUlZBWU1CUlFTREFVVUVnd0ZvQkZVQmFBU0RBVVVFZ3dGRkJJTUJhQVJGQklNQlJRU0RBWU1CUlFSRkJJTUJSUVNEQVlNQmFBUkZCSU1CZ3dGb0JFVUVnd0dEQVVVRWFBU0RBVVVFZ3dGRkJJTUJSUVNEQVlNQlJRU0RBV2dFUlFTREFZTUJSUVNEQVVVRWd3RkZCRVVFIiwibHYiOlswXX0=",
"3": "eyJudW0iOjEsImZlcS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lVCSWdCaUFGVUJGUUVpQUZVQklnQlZBU0lBVXNCIiwibHYiOlswXX0=",
"4h": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJPUnBQQkh3QlR3UjhBWHdCVHdSOEFVOEVmQUZQQkh3QlR3UjhBVThFZkFGUEJId0JUd1JQQkh3QlR3UjhBWHdCVHdSUEJId0JUd1I4QVh3QlR3UlBCSHdCZkFGUEJFOEVmQUY4QVU4RVR3UjhBWHdCVHdSOEFVOEVUd1I4QVU4RWZBRlBCSHdCZkFGUEJFOEVmQUZQQkh3QmZBRlBCSHdCIiwibHYiOlswXX0=",
"8h": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJtUmRRQkhzQlVBUjdBWHNCVUFSN0FWQUVld0ZRQkhzQlVBUjdBVkFFZXdGUUJIc0JVQVJRQkhzQlVBUjdBWHNCVUFSUUJIc0JVQVI3QVhzQlVBUlFCSHNCZXdGUUJGQUVld0Y3QVZBRVVBUjdBVkFFZXdGN0FWQUVVQVI3QVhzQlVBUlFCSHNCZXdGUUJIc0JVQVJRQkhzQmV3RlFCRkFFIiwibHYiOlswXX0=",
"luz": "eyJudW0iOjEsImZlcSI6MCwiZGF0YTAiOiJaQnBSQkhzQlVRUjdBWHNCVVFSN0FWRUVld0ZSQkhzQlVRUjdBVkVFZXdGUkJIc0JVUVJSQkhzQlVRUjdBWHNCVVFSUkJIc0JVUVI3QVhzQlVRUlJCSHNCZXdGUkJGRUVld0Y3QVZFRVVRUjdBWHNCVVFSUkJIc0Jld0ZSQkZFRWV3RlJCSHNCZXdGUkJGRUVld0Y3QVZFRVVRUjdBWHNCIiwibHYiOlswXX0=",
}
rf=RFRemoteControlDevice.RFRemoteControlDevice
#c code
#for b in buttons:
# x=rf.rf_print_button(buttons[b])
# pulses=rf.base64_to_pulses(eval(x)['data0'])
# print(b+","+",".join([str(p) for p in pulses]))
#
#esphome yaml
print("button:")
w=10
for b in buttons:
x=rf.rf_print_button(buttons[b])
pulses=rf.base64_to_pulses(eval(x)['data0'])
print(" - platform: template")
print(" name: ",b)
print(" web_server_sorting_weight: ",w)
w=w+10
print(" on_press:")
print(" - output.turn_on: status")
print(" - remote_transmitter.transmit_raw:")
print(" transmitter_id: rf")
print(" repeat:")
print(" times: 7")
print(" wait_time: 0s")
pp=[]
mult=1
for i in range(len(pulses)):
pp.append(str(pulses[i]*mult))
mult=-mult
print(" code: ["+",".join(pp)+"]")
print(" - output.turn_off: status")