-
Notifications
You must be signed in to change notification settings - Fork 3
/
ManualLOCAL.html
249 lines (227 loc) · 10.2 KB
/
ManualLOCAL.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
240
241
242
243
244
245
246
247
248
249
<!DOCTYPE html>
<html>
<table border="2" style="height: 100%; width: 100%; border-collapse: collapse; border-style: dashed;">
<body onload="startup()">
<script>
//Created with <3 by Nir K.
function homefunc(id, state) {
var hassaddress="http://"; //Your homeassistant address. Ex: http://192.168.1.10:8123
var hasspass=""; //Your homeassistant long lived token
//Should work on all e-ink devices with a browser that supports Javascript (Kindle 2 (2009) in advanced mode and above)
//LOCAL SETUP
var xmlhttp = new XMLHttpRequest(); // new HttpRequest instance
xmlhttp.open("POST", hassaddress+"/api/services/"+id.substring(0,id.indexOf('.'))+"/"+state);
xmlhttp.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlhttp.setRequestHeader("Content-Type", "application/json");
xmlhttp.send(JSON.stringify({entity_id:id}));
/*
Other request types if the above doesn't work for your device
//POST
var formData = new FormData();
formData.append("entity_id", id);
var request = new XMLHttpRequest();
request.open("POST", "URL");
request.send(JSON.stringify(formData));
//Alternative Javascript posts that might work for other devices
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", hassaddress);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "id");
hiddenField.setAttribute("value", id);
form.appendChild(hiddenField);
hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", "state");
hiddenField.setAttribute("value", state);
form.appendChild(hiddenField);
document.body.appendChild(form);
form.submit();
*/
}
function startup() {
//SET YOUR WEATHER ENTITY_ID HERE
weather("weather.yweather");
//Don't change
sensors("group.sensors", true);
}
function weather(id) {
var hassaddress="http://"; //Your homeassistant address. Ex: http://192.168.1.10:8123
var hasspass=""; //Your homeassistant long lived token
if (id != null)
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status == 200)
{
resp = JSON.parse(xmlHttp.responseText);
var dvTable = document.getElementById("weather");
dvTable.innerHTML = "<p><br>Weather<br /> Temp: "+resp['attributes']['temperature']+" Degrees <br /><p> Humidity: "+resp['attributes']['humidity']+"%</p><button id="+id+" type=button onclick=weather(this.id,false)>Refresh</button></p><br />";
}
}
//SET YOUR WEATHER ENTITY_ID HERE
xmlHttp.open("GET", hassaddress+"/api/states/weather.yweather", true); // true for asynchronous
xmlHttp.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlHttp.setRequestHeader("Content-Type", "application/json");
xmlHttp.send(null);
}
}
function sensors(id, async) {
var hassaddress="http://"; //Your homeassistant address. Ex: http://192.168.1.10:8123
var hasspass=""; //Your homeassistant long lived token
var dvTable = document.getElementById("sensors");
if (id != null)
{
var xmlHttp1 = new XMLHttpRequest();
xmlHttp1.onreadystatechange = function() {
if (xmlHttp1.readyState == 4 && xmlHttp1.status == 200)
{
resp = JSON.parse(xmlHttp1.responseText);
dvTable.innerHTML = "SSL:"+resp['state']+" days";
}
}
//SET YOUR 1ST SENSOR ENTITY_ID HERE
xmlHttp1.open("GET", hassaddress+"/api/states/sensor.ssl_certificate_expiry", async); // true for asynchronous
xmlHttp1.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlHttp1.setRequestHeader("Content-Type", "application/json");
xmlHttp1.send(null);
var xmlHttp2 = new XMLHttpRequest();
xmlHttp2.onreadystatechange = function() {
if (xmlHttp2.readyState == 4 && xmlHttp2.status == 200)
{
resp = JSON.parse(xmlHttp2.responseText);
dvTable.innerHTML = dvTable.innerHTML+ "<br /> Date:"+resp['state'];
}
}
//SET YOUR 2ND SENSOR ENTITY_ID HERE
xmlHttp2.open("GET", hassaddress+"/api/states/sensor.date__time", async); // true for asynchronous
xmlHttp2.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlHttp2.setRequestHeader("Content-Type", "application/json");
xmlHttp2.send(null);
var xmlHttp3 = new XMLHttpRequest();
xmlHttp3.onreadystatechange = function() {
if (xmlHttp3.readyState == 4 && xmlHttp3.status == 200)
{
resp = JSON.parse(xmlHttp3.responseText);
dvTable.innerHTML = dvTable.innerHTML + "<br /> Uptime:"+resp['state']+" days";
}
}
//SET YOUR 3RD SENSOR ENTITY_ID HERE
xmlHttp3.open("GET", hassaddress+"/api/states/sensor.uptime", async); // true for asynchronous
xmlHttp3.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlHttp3.setRequestHeader("Content-Type", "application/json");
xmlHttp3.send(null);
var xmlHttp4 = new XMLHttpRequest();
xmlHttp4.onreadystatechange = function() {
if (xmlHttp4.readyState == 4 && xmlHttp4.status == 200)
{
resp = JSON.parse(xmlHttp4.responseText);
dvTable.innerHTML = dvTable.innerHTML +"<br /> Waze:"+resp['state']+" minutes";
}
}
//SET YOUR 4TH SENSOR ENTITY_ID HERE
xmlHttp4.open("GET", hassaddress+"/api/states/sensor.waze_travel_time", async); // true for asynchronous
xmlHttp4.setRequestHeader('Authorization', "Bearer "+hasspass);
xmlHttp4.setRequestHeader("Content-Type", "application/json");
xmlHttp4.send(null);
}
}
</script>
<tr style="height: 21px;">
<td style="width: 25%; height: 21px; text-align: center;">
<p></p>
<p>Living Room lights <br /> <button id="switch.livingroom_light" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.livingroom_light" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px; text-align: center;">
<p></p>
<p>TV<br /> <button id=" switch.tv_samsung" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.tv_samsung" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px; text-align: center;">
<p></p>
<p>Living room AC <br /> <button id="switch.electrago_on" type="button" onclick="homefunc(this.id, 'turn_on')">On</button><button id="switch.electrago_on" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px; text-align: center;">
<p></p>
<p>Stereo <br /> <button id="switch.stereo" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.stereo" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
</tr>
<tr style="height: 21px; text-align: center;">
<td style="width: 25%; height: 21px;">
<p></p>
<p>Bedroom lights <br /> <button id="switch.bedroom_light" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.bedroom_light" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Desk lamp <br /> <button id="switch.desk_lamp" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.desk_lamp" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Bedroom AC <br /> <button id="switch.hisense_on" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.hisense_on" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Projector <br /> <button id="switch.benq_projector" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.benq_projector" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
</tr>
<tr style="height: 21px; text-align: center;">
<td style="width: 25%; height: 21px;">
<p></p>
<p>Computer <br /> <button id="switch.computer" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.computer" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>LED Lights <br /> <button id="switch.led_light" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.led_light" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Playstation 4 <br /> <button id="media_player.playstation_4" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="media_player.playstation_4" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Xbox One <br /> <button id="switch.xbox" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.xbox" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
</tr>
<tr style="height: 21px; text-align: center;">
<td style="width: 25%; height: 21px;">
<p></p>
<p>Bedroom Fan <br /> <button id="switch.bedroom_fan" type="button" onclick="homefunc(this.id, 'turn_on')">On</button> <button id="switch.bedroom_fan" type="button" onclick="homefunc(this.id, 'turn_off')">Off</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
<p>Spotify<br /> <button id="media_player.spotify" type="button" onclick="homefunc(this.id, 'media_play_pause')">Play</button> <button type="button" id="media_player.spotify" onclick="homefunc(this.id, 'media_play_pause')">Pause</button></p>
<button type="button" id="media_player.spotify" onclick="homefunc(this.id, 'media_previous_track')">Previous</button><button type="button" id="media_player.spotify" onclick="homefunc(this.id, 'media_next_track')">Next</button>
<p></p>
</td>
<td id="weather" style="width: 25%; height: 21px;">
<p></p>
<p>Weather <br /> <button type="button" id="weather.yweather" onclick="weather(this.id)">Refresh</button></p>
<p></p>
</td>
<td style="width: 25%; height: 21px;">
<p></p>
Sensors
<p id="sensors"></p>
<button type="button" id="group.sensors" onclick="sensors(this.id, true)">Refresh</button>
<p></p>
</td>
</tr>
</body>
</table>
</div>
</div>
</div>
</html>