-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.html
239 lines (217 loc) · 12.1 KB
/
index.html
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Broadlink RM Random Code Generator</title>
<script src="hex.js"></script>
<script src="generator.js"></script>
<script src="index.js"></script>
<script src="pageActions.js"></script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"
integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"
integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ"
crossorigin="anonymous"></script>
<style>
td {
word-break: break-all;
min-width: 90px;
}
.card {
border-top: 0;
}
.highlight {
padding: 9px 14px;
margin-bottom: 14px;
background-color: #f7f7f9;
border: 1px solid #e1e1e8;
border-radius: 4px;
}
</style>
</head>
<body>
<div class="container-fluid mt-4">
<h1>Random Broadlink RM Code Generator</h1>
<ul class="nav nav-tabs mt-4">
<li class="nav-item">
<a class="nav-link active" id="tab1" href="#" onclick="showRandomCodeTab()">Generate Random Code</a>
</li>
<li class="nav-item">
<a class="nav-link" id="tab2" href="#" onclick="showLivoloTab()">Generate Random Livolo Code</a>
</li>
<li class="nav-item">
<a class="nav-link" id="tab3" href="#" onclick="showEnergenieTab()">Generate Random Energenie Set</a>
</li>
<li class="nav-item">
<a class="nav-link" id="tab4" href="#" onclick="showRepeatsTab()">Change Repeats</a>
</li>
</ul>
<div id="random-code-section">
<div class="card">
<div class="card-body col-12">
<h3>Generate Random Code</h3>
<div class="row mt-4">
<label for="signal_type" class="badge-pill col col-2">type:</label>
<select id="signal_type" class="custom-select col col-2">
<option value="RF433">RF433</option>
<option value="RF315">RF315</option>
</select>
</div>
<button type="button" class="btn btn-success mt-2" onclick="startGenerate()">Generate</button>
</div>
</div>
<div class="table-responsive mt-4">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Type</th>
<th scope="col">Regular code</th>
<th scope="col">same code with long repeat (for learning)</th>
</tr>
</thead>
<tbody id="restable">
</tbody>
</table>
</div>
</div>
<div id="livolo-section">
<div class="card">
<div class="card-body col-12">
<h3>Generate Random Livolo Code</h3>
<form class="form-horizontal mt-4">
<div class="form-group">
<label for="remoteId">Remote ID:</label>
<input type="text" class="form-control" id="remoteId" placeholder="7400">
<label>Working sample eg. 7400, 6550, 10550. Range 1 - 65500. Usually divisible by 4</label>
</div>
<div class="form-group">
<label for="liv_btn" class="badge-pill col">Button:</label>
<select id="liv_btn" class="custom-select">
<option value='90'>On Only(scn1)</option>
<option value='40'>On/Off (toggle/button10)</option>
<option value='106'>Off Only</option>
<option value='0'>Button 1</option>
<option value='96'>Button 2</option>
<option value='120'>Button 3</option>
<option value='24'>Button 4</option>
<option value='108'>Button 5</option>
<option value='80'>Button 6</option>
<option value='48'>Button 7</option>
<option value='12'>Button 8</option>
<option value='72'>Button 9</option>
<option value='40'>Button 10</option>
<option value='90'>Scene 1</option>
<option value='114'>Scene 2</option>
<option value='10'>Scene 3</option>
<option value='18'>Scene 4</option>
</select>
<br>
</div>
<button type="button" class="btn btn-success" onclick="startGenerateLivolo()">Generate</button>
</form>
<div class="table-responsive mt-4">
<table class="table table-striped table-hover" <thead>
<tr>
<th scope="col">Type</th>
<th scope="col">Code</th>
</tr>
</thead>
<tbody id="livtable">
</tbody>
</table>
</div>
</div>
</div>
</div>
<div class="card" id="energenie-section">
<div class="card-body col-12">
<h3>Generate Random Energenie Socket Set</h3>
<figure class="highlight mt-4">
<p>
While I've written this for my Energenie remote-control sockets, it should work for any "Type D" socket as defined in the <a href="https://github.com/sui77/rc-switch/wiki/HowTo_OperateLowCostOutlets">rc-switch wiki</a> - i.e, 433mhz learning sockets.<br/>
Many thanks to Energenie for <a href="https://energenie4u.co.uk/res/pdfs/ENER314%20UM.pdf">documenting their accessories</a>; extremely helpful.</p>
<p>
Here's what I sniffed using rc-switch/figured out by bashing my head against IHC for iOS backups:<br/>
<code>RF HIGH BIT: 1507, RF LOW BIT: 0815, RF FOOTER: 08dc000000000000</code><br/>
<code>Format: RF (b2), Repeats: 08 (8), Data: 20 pairs (remote ID), 4 pairs (socket command), 4 pairs (footer)</code>
</p>
<p>
I was thrown for a while looking at RF dumps as <code>HIGH</code> (1507) could come in as 1506 or 1508, and <code>LOW</code> (0816) could be 0815 or 0817. Realise now that's just the radios being vague, not actual important information. Once we had that figured out (and rounded off!), here's the steps to this generation:
<ol>
<li>Generate 20 random binary bits. This is our shiny new remote group ID!</li>
<li>Construct the transmission hexadecimal: <code>RF + REPEATS + DATA LENGTH + DATA + FOOTER</code>.
<ol>
<li>RF: <code>b2</code>, which is RF433 in the world of Broadlink</li>
<li>REPEATS: <code>08</code>, 8 repeats; this is what IHC for iOS recorded when I pressed the buttons, but it's probably a bit conservative for a good transmission.</li>
<li>DATA LENGTH: <code>34 00</code>, 52 hex pairs follow (big endian). For us, that's 40 pairs (remote group ID), 4 pairs (socket command), 8 pairs (RF footer)</li>
<li>DATA: <code>1507 0815 (...)</code>, the HIGH/LOW bits to transmit as defined above - remote group, socket command.</li>
<li>FOOTER: <code>08dc000000000000</code>, the footer extracted from the IHC for IOS app backups. Always the same.</li>
</ol>
</li>
<li>Generate commands with the above formula for each switch group entry: <code>1 On, 1 Off, 2 On, 2 Off, 3 On, 3 Off, 4 On, 4 Off, All On, All Off.</code></li>
<li>Optionally, convert the hexadecimal to base64. Done!</li>
</ol>
</p>
</figure>
<button type="button" class="btn btn-success mt-2" onclick="generateEnergenie()">Generate</button>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead>
<tr>
<th scope="col">Type</th>
<th scope="col">Remote ID</th>
<th scope="col">Binary // rc-switch numerical</th>
<th scope="col">Broadlink Regular Code</th>
<th scope="col">Broadlink long repeat (for learning)</th>
</tr>
</thead>
<tbody id="gentable">
</tbody>
</table>
</div>
<div class="m-3">
<h5 class="mb-3">Homebridge JSON, for <a href="https://github.com/lprhodes/homebridge-broadlink-rm">homebridge-broadlink-rm</a></h5>
<figure class="highlight">
<pre id="genjson"></pre>
</figure>
</div>
</div>
<div class="card" id="repeats-section">
<div class="card-body col-12">
<h3>Change number of repeats in existing code (also works for IR codes)</h3>
<br><br>
<form class="form-horizontal">
<div class="form-group">
<label for="usercode">Your code:</label>
<input type="text" class="form-control" id="usercode"
placeholder="sgw0AA0kDSQkDQ0kJA0NJA0kDSQNJCQNJA0NJCQNDSQNJA0kDSQkDSQNDSQNJA0kDSQkDQwAAW8AAAAA"
onchange="calcRepeats()">
<br><label for="repeats">Current Repeats:</label>
<b>
<div id="repeats" placeholder="14 (max 255)">0</div>
</b>
</div>
<input type="text" class="form-control" id="newrepeat" placeholder="New Repeats (max 255)">
<br>
<button type="button" class="btn btn-success" onclick="generateNewRepeat()">Generate</button>
<div class="form-group mt-2">
<input type="text" class="form-control" id="newcode" placeholder="New Code">
</div>
</form>
</div>
</div>
<div class="mt-5 mb-3">
<hr>
You are welcome to contribute: <a
href="https://github.com/dimagoltsman/Random-Broadlink-RM-Code-Generator">https://github.com/dimagoltsman/Random-Broadlink-RM-Code-Generator</a>
</div>
</div>
</body>
</html>