/
MMM-Openhab.js
52 lines (41 loc) · 1.13 KB
/
MMM-Openhab.js
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
/* Magic Mirror
* Module: MMM-Openhab
* By tbbear
*/
Module.register("MMM-Openhab", {
// Module config defaults.
defaults: {
updateInterval: 30 * 60 * 1000, // every 10 minutes
url: "http://wr-pi-openhab:8080/basicui/app?sitemap=MMM",
initialLoadDelay: 300, // delay
retryDelay: 1500,
maxWidth: "100%",
},
// Define required scripts.
getScripts: function() {
return ["moment.js"];
},
getStyles: function() {
return ["MMM-Openhab.css", "font-awesome.css"];
},
// Define start sequence.
start: function() {
Log.info("Starting module: " + this.name);
// Schedule update interval.
var self = this;
setInterval(function() {
self.updateDom();
}, this.config.updateInterval);
},
getDom: function() {
var wrapper = document.createElement("div");
wrapper.style.maxWidth = this.config.maxWidth;
var iframe = document.createElement("iframe");
iframe.style.frameborder = "0";
iframe.style.scrolling = "no";
iframe.classList.add("ifr");
iframe.src = this.config.url;
wrapper.appendChild(iframe);
return wrapper;
}
});