forked from sibbl/hass-lovelace-kindle-screensaver
-
Notifications
You must be signed in to change notification settings - Fork 11
/
config.js
56 lines (54 loc) · 2.22 KB
/
config.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
53
54
55
56
function getEnvironmentVariable(key, suffix, fallbackValue) {
const value = process.env[key + suffix];
if (value !== undefined) return value;
return fallbackValue || process.env[key];
}
function getPagesConfig() {
const pages = [];
let i = 0;
while (++i) {
const suffix = i === 1 ? "" : `_${i}`;
const screenShotUrl = process.env[`HA_SCREENSHOT_URL${suffix}`];
if (!screenShotUrl) return pages;
pages.push({
screenShotUrl,
outputPath: getEnvironmentVariable(
"OUTPUT_PATH",
suffix,
`output/cover${suffix}.png`
),
renderingDelay: getEnvironmentVariable("RENDERING_DELAY", suffix) || 0,
renderingScreenSize: {
height: getEnvironmentVariable("RENDERING_SCREEN_HEIGHT", suffix) || 800,
width: getEnvironmentVariable("RENDERING_SCREEN_WIDTH", suffix) || 600,
},
grayscaleDepth: getEnvironmentVariable("GRAYSCALE_DEPTH", suffix) || 8,
removeGamma: getEnvironmentVariable("REMOVE_GAMMA", suffix) || false,
dither: getEnvironmentVariable("DITHER", suffix) || false,
colorMode: getEnvironmentVariable("COLOR_MODE", suffix) || "GrayScale",
prefersColorScheme: getEnvironmentVariable("PREFERS_COLOR_SCHEME", suffix) || "light",
rotation: getEnvironmentVariable("ROTATION", suffix) || 0,
scaling: getEnvironmentVariable("SCALING", suffix) || 1,
batteryWebHook: getEnvironmentVariable("HA_BATTERY_WEBHOOK", suffix) || null,
realTimeCacheSec: getEnvironmentVariable("REAL_TIME_CACHE_SEC", suffix) || 60,
});
}
return pages;
}
module.exports = {
baseUrl: process.env.HA_BASE_URL,
accessToken: process.env.HA_ACCESS_TOKEN,
cronJob: process.env.CRON_JOB || "* * * * *",
useImageMagick: process.env.USE_IMAGE_MAGICK === "true",
pages: getPagesConfig(),
port: process.env.PORT || 5000,
renderingTimeout: process.env.RENDERING_TIMEOUT || 10000,
language: process.env.LANGUAGE || "en",
debug: process.env.DEBUG === "true",
realTime: process.env.REAL_TIME === "true",
ignoreCertificateErrors:
process.env.UNSAFE_IGNORE_CERTIFICATE_ERRORS === "true",
mqttServer: process.env.MQTT_SERVER || null,
mqttUser: process.env.MQTT_USERNAME || null,
mqttPassword: process.env.MQTT_PASSWORD || null,
};