-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
webUI.html
201 lines (180 loc) · 6.48 KB
/
webUI.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
<!--
webUI.html
TConnect - ESP32 based interface for Toshiba air conditioners
Developed by Vpow 2021-
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<link rel="icon" href="data:,">
<style>
table.GeneratedTable {
width: 90%;
background-color: #ffffff;
border-collapse: collapse;
border-width: 2px;
border-color: #2383e2;
border-style: solid;
color: #000000;
text-align: center;
font-family: Verdana, Geneva, sans-serif;
font-size:30px;
margin-left: auto;
margin-right: auto;
}
table.GeneratedTable td, table.GeneratedTable th {
border-width: 2px;
border-color: #2383e2;
border-style: solid;
padding: 3px;
}
table.GeneratedTable thead {
background-color: #1c74df;
}
.button{display: inline-block; background-color: #e7bd3b; border: none; border-radius: 4px; color: white; padding: 10px 10px; text-decoration: none; font-size: 30px; margin: 1%; cursor: pointer; width:22%; height:150px;vertical-align:top;}
.buttonswing {background-color: #008CBA;font-size: 24px;}
.buttonmode {background-color: #eb6134;font-size: 24px;width:17%;}
.buttonfan {background-color: #070be6;font-size: 20px;width:11%;}
.buttonsp {background-color: #278749;font-size: 20px;width:8%;}
</style>
<title>Toshiba AC</title>
</head>
<body>
<h1 style="font-family:verdana;font-size:48px;">Toshiba AC</h1>
<table class="GeneratedTable">
<thead>
<tr>
<th>Item</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Wifi connection</td>
<td id='TAC_connected'>-</td>
</tr>
<tr>
<td>Wifi RSSI</td>
<td id='rssi'>-</td>
</tr>
<tr>
<td>State</td>
<td id='state'>-</td>
</tr>
<tr>
<td>Fan mode</td>
<td id='fanmode'>-</td>
</tr>
<tr>
<td>Swing</td>
<td id='swing'>-</td>
</tr>
<tr>
<td>Mode</td>
<td id='mode'>-</td>
</tr>
<tr>
<td>Setpoint</td>
<td id='setpoint'>-</td>
</tr>
<tr>
<td>Room temperature</td>
<td id='roomtemp'>-</td>
</tr>
<tr>
<td>Outdoor temperature</td>
<td id='outdoortemp'>-</td>
</tr>
</tbody>
</table>
<p>
<button class="button" onclick="myFunction(`CMD_STATE`, `STATE_ON`)">ON</button>
<button class="button" onclick="myFunction(`CMD_STATE`, `STATE_OFF`)">OFF</button>
<button class="button buttonswing" onclick="myFunction(`CMD_SWING`, `SWING_ON`)">SWING ON</button>
<button class="button buttonswing" onclick="myFunction(`CMD_SWING`, `SWING_OFF`)">SWING OFF</button>
</p>
<p>
<button class="button buttonmode" onclick="myFunction(`CMD_MODE`, `MODE_AUTO`)">AUTO</button>
<button class="button buttonmode" onclick="myFunction(`CMD_MODE`, `MODE_COOL`)">COOL</button>
<button class="button buttonmode" onclick="myFunction(`CMD_MODE`, `MODE_HEAT`)">HEAT</button>
<button class="button buttonmode" onclick="myFunction(`CMD_MODE`, `MODE_DRY`)">DRY</button>
<button class="button buttonmode" onclick="myFunction(`CMD_MODE`, `MODE_FAN`)">FAN</button>
</p>
<p>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_AUTO`)">AUTO</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_QUIET`)">QUIET</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_1`)">1</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_2`)">2</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_3`)">3</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_4`)">4</button>
<button class="button buttonfan" onclick="myFunction(`CMD_FAN`, `FANMODE_5`)">5</button>
</p>
<p>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `18`)">18</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `19`)">19</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `20`)">20</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `21`)">21</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `22`)">22</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `23`)">23</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `24`)">24</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `25`)">25</button>
<button class="button buttonsp" onclick="myFunction(`CMD_SETPOINT`, `26`)">26</button>
</p>
<script>
var noresponsecounter = 0;
requestData(); //get initial data
setInterval(requestData, 4000); //request data update interval
function myFunction(a,b) {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'command');
xhr.timeout = 3000;
xhr.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
xhr.onload = function() { //if response code is 200, success
console.log('myfync response: ' + xhr.status + xhr.responseText);
}
console.log('{"'+ a + '":"' + b +'"}');
xhr.send('{"'+ a + '":"' + b +'"}');
}
function requestData() {
var xhr = new XMLHttpRequest();
xhr.open('GET', 'status');
xhr.timeout = 3000;
//console.log('PING');
xhr.onload = function() {
//console.log('ONLOAD');
if((xhr.status === 200) && (xhr.responseText)){ //return ok and there is data
var data = JSON.parse(xhr.responseText);
//console.log('OK. ' + xhr.status + JSON.stringify(data));
for(var key in data) {
//console.log(key + data[key])
var element = document.getElementById(key);
if(element != null) {
element.innerText = data[key];
}
}
noresponsecounter = 0;
} else { // a problem occurred
console.log('Request failed. ' + xhr.status);
if(noresponsecounter < 5) {
noresponsecounter = noresponsecounter + 1;
}
}
};
xhr.ontimeout = function (e) {
console.log('TIMEOUT');
if(noresponsecounter < 5) {
noresponsecounter = noresponsecounter + 1;
}
};
if(noresponsecounter >= 5) {
document.getElementById("TAC_connected").innerText = "Not connected!";
}
else {
document.getElementById("TAC_connected").innerText = "Connected";
}
xhr.send();
}
</script>
</body>
</html>