-
Notifications
You must be signed in to change notification settings - Fork 1
/
relays.htm
217 lines (217 loc) · 16.1 KB
/
relays.htm
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
<!DOCTYPE html><html><head><title id="Tabs">Lichter verwalten</title><!-- Versions-Monitor: sv 1.14.0.2023.09.14 --><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><meta name="viewport" content="width=device-width, initial-scale=1.0"><link rel="shortcut icon" type="image/x-icon" href="favicon.ico"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"><meta http-equiv="pragma" content="no-cache">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/MaterialDesign-Webfont/5.9.55/css/materialdesignicons.min.css" integrity="sha512-vIgFb4o1CL8iMGoIF7cYiEVFrel13k/BkTGvs0hGfVnlbV6XjAA0M0oEHdWqGdAVRTDID3vIZPOHmKdrMAUChA==" crossorigin="anonymous" /><style type="text/css" media="all">
*{font-family:Avant Garde, verdana, Magneto, Comic Sans MS, arial,sans-serif,Times New Roman,serif; list-style:none; color:rgb(245,245,245);}
body{margin:0;border:0; scrollbar-width: auto; scrollbar-color: rgb(0,0,0) rgb(245,245,245); color: rgb(245,245,245); background-color: #37474f; display:flex; flex-flow:row wrap; font-size:10pt;}
body::-webkit-scrollbar{width:20px;height:20px;}
body::-webkit-scrollbar-track{background-color:#37474f;}
body::-webkit-scrollbar-thumb{background-color:black; border-radius:10px; border:1px solid #00f0f0;}
.room{background-color:#455a64;padding:5px;border-radius:20px;color:#eee;margin-bottom:1px;}
.room > div{display:inline-block;width:88px;height:110px;background-color:#56676f;border-radius:10px;padding:5px;}
.favorit{font-size:2em;cursor:pointer;color:#00FFFF;}
.relay{font-size:3em;cursor:pointer;}
.relay:hover{background-color:#444;}
.relay big {font-size:0.4em;position:absolute;margin-left:-28px;margin-top:30px;opacity:0.7;z-index:0;}
.schalter{cursor:pointer;}
.uhr{font-size:1em;text-align:center;}
h4{margin:0;margin-bottom:3px;text-align:center;background-image: linear-gradient(to left, violet, cornflowerblue, lightblue, lime, yellow, orange, red); -webkit-background-clip: text; color: transparent;}
table{vertical-align:top;margin:0;height:1%;}
form{display:inline;}
form.cloud{display:none;}
fieldset{padding:3px;border-radius:6px;}
label.schreiben{cursor:hand;cursor:pointer;}
td.liste{border-style:solid;border-width:1px;border-color:#f5f5f5;}
textarea{overflow:auto;}
iframe{background-color:#f5f5f5;}
.on{background-color:lime;color:black;}
.stop{background-color:white;color:red;}
.off{background-color:tomato;color:white;}
.knopf{background-color:black;color:white;}
a:hover{color:white;position:relative;right:1px;top:1px;text-decoration:none;}
a{color:#ffffff;text-decoration:none;}
ol{margin:0;}
legend, ul, ol{white-space:nowrap;}
</style><script>
function ToggleShelly(type, id, ip) {
fetch('http://' + ip +'/'+ type +'/' + id + '?turn=toggle')
.then()
.catch(err => alert('Toggle failed'));
}
function vorgestellteNullen(wert) {
if (wert < 10) return "0" + parseInt(wert);
else return parseInt(wert);
}
function Sekundenumwandeln(Sekundenzahl) {
Sekundenzahl = Math.abs(Sekundenzahl)
if(Sekundenzahl > 86400){
return parseInt(Sekundenzahl/60/60/24)+ "d" + vorgestellteNullen((Sekundenzahl/60/60)%24) + ":" + vorgestellteNullen((Sekundenzahl/60)%60) + ":" + vorgestellteNullen(Sekundenzahl%60);
} else if(Sekundenzahl < 60){
return vorgestellteNullen(Sekundenzahl%60) + " sek.";
} else if(Sekundenzahl < 3600){
return vorgestellteNullen((Sekundenzahl/60)%60) + ":" + vorgestellteNullen(Sekundenzahl%60);
} else {
return vorgestellteNullen((Sekundenzahl/60/60)%24) + ":" + vorgestellteNullen((Sekundenzahl/60)%60) + ":" + vorgestellteNullen(Sekundenzahl%60);
}
}
let Dauer = 7;
function loadData() {
let millis = Dauer * 1000;
setInterval(
function() {
Timer(Dauer);
let T1 = 0;
let hoch = "";
let L1 = 0;
let L2 = 0;
let Spannung = 0;
let Volts = 0;
let arr = [];
$("div[data-ip]").each(function(){
var ip = $(this).data('ip');
var name = $(this).data('name');
var linkname = "<a href='http://" + ip + "/' target='new'>" + $(this).data('name') + "</a>";
var power = $(this).data('consumption');
var shellytype = $(this).data('type');
var temptype = $(this).data('temperatur');
var relayindex = $(this).data('relayindex');
var id = $(this).attr('id');
let content = "";
fetch('http://' + ip +'/status')
.then(response => response.json())
.then(function(data) {
if(temptype === "ext_temperature[0]"){
T1 = data.ext_temperature[0].tC;
// hoch = "<span title='aussen'>°C(²außen)</span><br>" + data.ext_temperature[1].tC + "<span title='innen Chip: " + data.tmp.tC + "°C (³)'>°C(²innen)</span>";
hoch = "°C (²)";
} else if(temptype === "tmp"){
T1 = data.tmp.tC;
hoch = "°C (³)";
} else if(temptype === "S1"){
T1 = data.time;
hoch = "<br>Uhrzeit";
} else {
T1 = "";
hoch = "";
}
let Spannung = data.voltage;
let FWN = data.update.new_version;
let FWO = data.update.old_version;
let NFW = "";
if(FWN === FWO){
FWN = "";
NFW = "";
} else {
NFW = "<span style='color:#ff0' title='Gerät nicht mit Internet verbunden oder neue Firmware vorhanden: " + FWN + " Klick für Update, nur wenn NEUE Version in der Info angezeigt wird'><a href='http://" + ip + "/ota?update=1' target='schalter'> <i style='color:#FFFF00;' class='relay-off mdi mdi-rotate-3d-variant'></i></a></span>";
FWN = FWN + "<br>neue Firmware vorhanden";
}
arr.push(Spannung);
content += "<div><nobr>" + linkname + NFW + "</nobr></div>";
if(data.relays[relayindex].ison == true)
if(id == 3)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #FF8F00;" class="relay relay-off mdi mdi-washing-machine"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 4)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #ffa000;" class="relay relay-off mdi mdi-moped"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 7)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #0000ff;" class="relay relay-off mdi mdi-coffee-maker"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 8)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #10ff00;" class="relay relay-off mdi mdi-power-socket-de"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 9 || id == 12)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #ffff00;" class="relay relay-off mdi mdi-white-balance-sunny"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 10)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #ffff00;" class="relay relay-off mdi mdi-white-balance-sunny"><big accesskey="' + id + '"></big></i></div>';
else
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\', '+ relayindex + ' ,\'' + ip + '\');"><i title="Ausschalten accesskey ' + id + '" style="color: #ffff00;" class="relay relay-off mdi mdi-lightbulb-on-outline"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 3)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" class="relay relay-off mdi mdi-power-socket-de"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 4)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" class="relay relay-off mdi mdi-power-socket-de"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 7)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" class="relay relay-off mdi mdi-power-socket-de"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 8)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" class="relay relay-off mdi mdi-power-socket-de"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 9 || id == 12)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" style="color: #a5a5aa;" class="relay relay-off mdi mdi-moon-waning-crescent"><big accesskey="' + id + '"></big></i></div>';
else
if(id == 10)
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" style="color: #aaaaaa;" class="relay relay-off mdi mdi-white-balance-sunny"><big accesskey="' + id + '"></big></i></div>';
else
content += '<div style="width:100%; text-align: center;" onclick="ToggleShelly(\'' + shellytype + '\',' + relayindex + ',\'' + ip + '\');"><i title="Anschalten accesskey ' + id + '" class="relay relay-off mdi mdi-lightbulb-outline"><big accesskey="' + id + '"></big></i></div>';
if(typeof data.meters[relayindex].power !== 'undefined')
L1 = data.meters[relayindex].power;
L2 += L1;
L3 = L2.toFixed(2);
L4 = L2.toFixed(0);
if (Spannung > Volts) {
Volts = Spannung;
}
if (data.relays[relayindex].timer_remaining === 0) {
var SEK = "";
} else {
let wirklicheZeit = Sekundenumwandeln(data.relays[relayindex].timer_remaining);
var SEK = "<span title=\"noch bis An oder Aus\">" + wirklicheZeit + "</span>";
};
content += "<div style=\"text-align: center; padding-top: 1px; \">";
if (data.meters[relayindex].power > 0)
content += "<small title='" + Spannung + " Volt'>" + data.meters[relayindex].power + " Watt<br>" + T1 + hoch + "<br>" + SEK + "</small>";
else
if (data.relays[relayindex].overpower !== false)
content += "<b><small style=\"color: #00ffff;\" title=\"kein PowerMetering\">-</small></b><br><small>" + T1 + hoch + "<br>" + SEK + "</small>";
else
content += "<b><small style=\"color: #10ff00;\" title=\"keine Leistungsabnahme\">•</small></b><br><small>" + T1 + hoch + "</small>";
content += "</div>";
$('#' + id ).html(content);
let Voltage = Volts.toFixed(2);
document.getElementById("Alles").innerHTML = "<b title=\"Maximum von: " + arr + " Volt\" style=\"text-align: center; color: #10ff00;\">" + L3 + " </b>";
document.getElementById("Tabs").innerHTML = "meine Shellys: " + L4 + " Watt";
document.getElementById("Spannend").innerHTML = Voltage;
})
});
}, millis
)
}
function Timer(s) {
document.getElementById("wieoft").innerHTML=s;
s--;
if (s > 0) {
window.setTimeout('Timer(' + s + ')', 999);
} else {
s = Dauer;
}
}
</script></head><body scroll="auto">
<table><tr><!-- bei data-temperatur angeben, welche Temperatur angezeigt wird: tmp für Chiptemperatur, ext_temperature[0] für Tempsensor am Addon, S1 = Shelly 1 ohne Addon (und Shelly 2, wenn relay oder roller) -->
<!-- td><div class="room"><h4>Anbau</h4><div id="1" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Rollo links" data-ip="192.168.178.73"></div></div></td>
<td><div class="room"><h4>Anbau</h4><div id="2" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Rollo rechts" data-ip="192.168.178.77"></div></div></td -->
<td><div class="room"><h4>Anbau</h4><div id="3" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Waschm." data-ip="192.168.178.52"></div></div></td>
<td><div class="room"><h4>Garage</h4><div id="4" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Econelo" data-ip="192.168.178.25"></div></div></td>
<td><div class="room"><h4>Büro</h4><div id="8" data-consumption="true" data-type="relay" data-temperatur="ext_temperature[0]" data-relayindex="0" data-name="USB-Dose" data-ip="192.168.178.84"></div></div></td>
<td><div class="room"><h4>Küche</h4><div id="7" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Kaffeem." data-ip="192.168.178.80"></div></div></td>
<td><div class="room"><h4>Flur</h4><div id="6" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Licht" data-ip="192.168.178.29"></div></div></td>
<td><div class="room"><h4>Flur</h4><div id="12" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="1" data-name="Sonnenuhr" data-ip="192.168.178.29"></div></div></td>
<!-- td><div class="room"><h4>Flur</h4><div id="9" data-consumption="true" data-type="relay" data-temperatur="S1" data-relayindex="0" data-name="Sonnenuhr" data-ip="192.168.178.83"></div></div></td -->
<td><div class="room"><h4>Windfang</h4><div id="5" data-consumption="true" data-type="relay" data-temperatur="S1" data-relayindex="0" data-name="BWM-Licht" data-ip="192.168.178.37"></div></div></td>
<!-- td><div class="room"><h4>Draussen</h4><div id="10" data-consumption="true" data-type="relay" data-temperatur="S1" data-relayindex="0" data-name="LichtSensor" data-ip="192.168.178.34"></div></div></td>
<td><div class="room"><h4>Lesen</h4><div id="11" data-consumption="true" data-type="relay" data-temperatur="tmp" data-relayindex="0" data-name="Button" data-ip="192.168.178.30"></div></div></td -->
</tr><tr>
<td colspan="11"><div class="room"><fieldset><legend>Daten werden nach <span id="wieoft"></span> Sekunden <a href="javascript:location.reload()">aktualisiert</a><iframe src="about:blank" width="0" height="0" name="schalter"></iframe></legend>
<big style="color:#10ff00">• </big><small style="color:#ffff00">keine LeistungsAbnahme</small> • <big style="color:#00ffff">- </big><small style="color:#00ffff">keine LeistungsMessung</small>
° <small>Temperatur <big>² </big> von Addon, <big>³ </big> vom RelaisChip</small><br>
<div style="width:100%; text-align:center;"><table style="width:100%; text-align:center;"><tr><td style="width:50%; text-align:right;"><big id="Alles" style="color:#10ff00"></big></td><td style="width:50%; text-align:left;"><b><big style="color:#10ff00">Watt</big></b></td>
</tr><tr><td style="width:50%; text-align:right;"><b><big id="Spannend" style="color:#0ff"></big></b></td><td style="width:50%; text-align:left;"><b><big style="color:#0ff">Volt</big></b></td>
</tr></table></div>
</fieldset></div></td></tr></table>
<script>
$( document ).ready(function() {
loadData();
Timer(Dauer);
})
</script></body></html>