ref: use code prettier

This commit is contained in:
leukipp
2025-01-07 16:08:07 +01:00
parent 8d2f3da93e
commit 640156ba87
5 changed files with 193 additions and 252 deletions
+1 -6
View File
@@ -135,12 +135,7 @@ const promptArgs = async (proc) => {
const answer = await read.question(prompt); const answer = await read.question(prompt);
const value = (answer.trim() || fallback.match(/[YN]/)[0]).toLowerCase(); const value = (answer.trim() || fallback.match(/[YN]/)[0]).toLowerCase();
if (!["y", "yes"].includes(value)) { if (!["y", "yes"].includes(value)) {
ignore = ignore.concat([ ignore = ignore.concat(["mqtt_url", "mqtt_user", "mqtt_password", "mqtt_discovery"]);
"mqtt_url",
"mqtt_user",
"mqtt_password",
"mqtt_discovery",
]);
} }
} else if (key === "check") { } else if (key === "check") {
const json = JSON.stringify(args, null, 2); const json = JSON.stringify(args, null, 2);
+6 -2
View File
@@ -49,14 +49,18 @@
] ]
} }
}, },
"prettier": {
"printWidth": 120
},
"devDependencies": { "devDependencies": {
"@electron-forge/cli": "^7.6.0", "@electron-forge/cli": "^7.6.0",
"@electron-forge/maker-deb": "^7.6.0", "@electron-forge/maker-deb": "^7.6.0",
"@electron-forge/maker-zip": "^7.6.0", "@electron-forge/maker-zip": "^7.6.0",
"@electron-forge/publisher-github": "^7.6.0", "@electron-forge/publisher-github": "^7.6.0",
"electron": "^33.2.1" "electron": "^33.3.1",
"prettier": "^3.4.2"
}, },
"dependencies": { "dependencies": {
"mqtt": "^5.10.3" "mqtt": "^5.10.3"
} }
} }
+172 -232
View File
@@ -90,12 +90,12 @@ const init = async (args) => {
updateDisplay(INTEGRATION.client); updateDisplay(INTEGRATION.client);
}); });
// Update heartbeat time periodically // Update heartbeat time periodically (30s)
setInterval(() => { setInterval(() => {
updateHeartbeat(INTEGRATION.client); updateHeartbeat(INTEGRATION.client);
}, 30 * 1000); }, 30 * 1000);
// Update sensor states periodically // Update sensor states periodically (1min)
setInterval(update, 60 * 1000); setInterval(update, 60 * 1000);
return true; return true;
@@ -124,18 +124,15 @@ const update = () => {
*/ */
const initShutdown = (client) => { const initShutdown = (client) => {
const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/shutdown`; const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/shutdown`;
const config = {
name: "Shutdown",
unique_id: `${INTEGRATION.node}_shutdown`,
command_topic: `${root}/execute`,
icon: "mdi:power",
device: INTEGRATION.device,
};
client client
.publish( .publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true })
`${root}/config`,
JSON.stringify({
name: "Shutdown",
unique_id: `${INTEGRATION.node}_shutdown`,
command_topic: `${root}/execute`,
icon: "mdi:power",
device: INTEGRATION.device,
}),
{ qos: 1, retain: true }
)
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === `${root}/execute`) { if (topic === `${root}/execute`) {
console.log("Shutdown system..."); console.log("Shutdown system...");
@@ -153,18 +150,15 @@ const initShutdown = (client) => {
*/ */
const initReboot = (client) => { const initReboot = (client) => {
const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/reboot`; const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/reboot`;
const config = {
name: "Reboot",
unique_id: `${INTEGRATION.node}_reboot`,
command_topic: `${root}/execute`,
icon: "mdi:restart",
device: INTEGRATION.device,
};
client client
.publish( .publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true })
`${root}/config`,
JSON.stringify({
name: "Reboot",
unique_id: `${INTEGRATION.node}_reboot`,
command_topic: `${root}/execute`,
icon: "mdi:restart",
device: INTEGRATION.device,
}),
{ qos: 1, retain: true }
)
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === `${root}/execute`) { if (topic === `${root}/execute`) {
console.log("Rebooting system..."); console.log("Rebooting system...");
@@ -182,18 +176,15 @@ const initReboot = (client) => {
*/ */
const initRefresh = (client) => { const initRefresh = (client) => {
const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/refresh`; const root = `${INTEGRATION.discovery}/button/${INTEGRATION.node}/refresh`;
const config = {
name: "Refresh",
unique_id: `${INTEGRATION.node}_refresh`,
command_topic: `${root}/execute`,
icon: "mdi:web-refresh",
device: INTEGRATION.device,
};
client client
.publish( .publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true })
`${root}/config`,
JSON.stringify({
name: "Refresh",
unique_id: `${INTEGRATION.node}_refresh`,
command_topic: `${root}/execute`,
icon: "mdi:web-refresh",
device: INTEGRATION.device,
}),
{ qos: 1, retain: true }
)
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === `${root}/execute`) { if (topic === `${root}/execute`) {
console.log("Refreshing webview..."); console.log("Refreshing webview...");
@@ -211,27 +202,18 @@ const initRefresh = (client) => {
*/ */
const initKiosk = (client) => { const initKiosk = (client) => {
const root = `${INTEGRATION.discovery}/select/${INTEGRATION.node}/kiosk`; const root = `${INTEGRATION.discovery}/select/${INTEGRATION.node}/kiosk`;
const config = {
name: `Kiosk`,
unique_id: `${INTEGRATION.node}_kiosk`,
command_topic: `${root}/set`,
state_topic: `${root}/status`,
value_template: "{{ value }}",
options: ["Framed", "Fullscreen", "Maximized", "Minimized", "Terminated"],
icon: "mdi:overscan",
device: INTEGRATION.device,
};
client client
.publish( .publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true })
`${root}/config`,
JSON.stringify({
name: `Kiosk`,
unique_id: `${INTEGRATION.node}_kiosk`,
command_topic: `${root}/set`,
state_topic: `${root}/status`,
value_template: "{{ value }}",
options: [
"Framed",
"Fullscreen",
"Maximized",
"Minimized",
"Terminated",
],
icon: "mdi:overscan",
device: INTEGRATION.device,
}),
{ qos: 1, retain: true }
)
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === `${root}/set`) { if (topic === `${root}/set`) {
const status = message.toString(); const status = message.toString();
@@ -275,10 +257,9 @@ const initKiosk = (client) => {
const updateKiosk = (client) => { const updateKiosk = (client) => {
const kiosk = WEBVIEW.status; const kiosk = WEBVIEW.status;
const root = `${INTEGRATION.discovery}/select/${INTEGRATION.node}/kiosk`; const root = `${INTEGRATION.discovery}/select/${INTEGRATION.node}/kiosk`;
client.publish(`${root}/status`, `${kiosk}`, { if (kiosk !== null) {
qos: 1, client.publish(`${root}/status`, `${kiosk}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -288,23 +269,22 @@ const updateKiosk = (client) => {
*/ */
const initDisplay = (client) => { const initDisplay = (client) => {
const root = `${INTEGRATION.discovery}/light/${INTEGRATION.node}/display`; const root = `${INTEGRATION.discovery}/light/${INTEGRATION.node}/display`;
const config = {
name: `Display`,
unique_id: `${INTEGRATION.node}_display`,
command_topic: `${root}/set`,
state_topic: `${root}/status`,
icon: "mdi:monitor-shimmer",
platform: "light",
device: INTEGRATION.device,
};
if (HARDWARE.display.brightness.path !== null) {
config.brightness_scale = 100;
config.brightness_command_topic = `${root}/brightness/set`;
config.brightness_state_topic = `${root}/brightness/status`;
}
client client
.publish( .publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true })
`${root}/config`,
JSON.stringify({
name: `Display`,
unique_id: `${INTEGRATION.node}_display`,
command_topic: `${root}/set`,
state_topic: `${root}/status`,
brightness_command_topic: `${root}/brightness/set`,
brightness_state_topic: `${root}/brightness/status`,
brightness_scale: 100,
icon: "mdi:monitor-shimmer",
platform: "light",
device: INTEGRATION.device,
}),
{ qos: 1, retain: true }
)
.on("message", (topic, message) => { .on("message", (topic, message) => {
if (topic === `${root}/set`) { if (topic === `${root}/set`) {
const status = message.toString(); const status = message.toString();
@@ -330,14 +310,12 @@ const updateDisplay = (client) => {
const status = hardware.getDisplayStatus(); const status = hardware.getDisplayStatus();
const brightness = hardware.getDisplayBrightness(); const brightness = hardware.getDisplayBrightness();
const root = `${INTEGRATION.discovery}/light/${INTEGRATION.node}/display`; const root = `${INTEGRATION.discovery}/light/${INTEGRATION.node}/display`;
client.publish(`${root}/status`, `${status}`, { if (status !== null) {
qos: 1, client.publish(`${root}/status`, `${status}`, { qos: 1, retain: true });
retain: true, }
}); if (brightness !== null) {
client.publish(`${root}/brightness/status`, `${brightness}`, { client.publish(`${root}/brightness/status`, `${brightness}`, { qos: 1, retain: true });
qos: 1, }
retain: true,
});
}; };
/** /**
@@ -347,18 +325,15 @@ const updateDisplay = (client) => {
*/ */
const initModel = (client) => { const initModel = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/model`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/model`;
client.publish( const config = {
`${root}/config`, name: `Model`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_model`,
name: `Model`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_model`, value_template: "{{ value }}",
state_topic: `${root}/status`, icon: "mdi:raspberry-pi",
value_template: "{{ value }}", device: INTEGRATION.device,
icon: "mdi:raspberry-pi", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateModel(client); updateModel(client);
}; };
@@ -370,10 +345,9 @@ const initModel = (client) => {
const updateModel = (client) => { const updateModel = (client) => {
const model = hardware.getModel(); const model = hardware.getModel();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/model`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/model`;
client.publish(`${root}/status`, `${model}`, { if (model !== null) {
qos: 1, client.publish(`${root}/status`, `${model}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -383,18 +357,15 @@ const updateModel = (client) => {
*/ */
const initSerialNumber = (client) => { const initSerialNumber = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/serial_number`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/serial_number`;
client.publish( const config = {
`${root}/config`, name: `Serial Number`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_serial_number`,
name: `Serial Number`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_serial_number`, value_template: "{{ value }}",
state_topic: `${root}/status`, icon: "mdi:hexadecimal",
value_template: "{{ value }}", device: INTEGRATION.device,
icon: "mdi:hexadecimal", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateSerialNumber(client); updateSerialNumber(client);
}; };
@@ -406,10 +377,9 @@ const initSerialNumber = (client) => {
const updateSerialNumber = (client) => { const updateSerialNumber = (client) => {
const serialNumber = hardware.getSerialNumber(); const serialNumber = hardware.getSerialNumber();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/serial_number`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/serial_number`;
client.publish(`${root}/status`, `${serialNumber}`, { if (serialNumber !== null) {
qos: 1, client.publish(`${root}/status`, `${serialNumber}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -419,18 +389,15 @@ const updateSerialNumber = (client) => {
*/ */
const initHostName = (client) => { const initHostName = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/host_name`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/host_name`;
client.publish( const config = {
`${root}/config`, name: `Host Name`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_host_name`,
name: `Host Name`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_host_name`, value_template: "{{ value }}",
state_topic: `${root}/status`, icon: "mdi:console-network",
value_template: "{{ value }}", device: INTEGRATION.device,
icon: "mdi:console-network", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateHostName(client); updateHostName(client);
}; };
@@ -442,10 +409,9 @@ const initHostName = (client) => {
const updateHostName = (client) => { const updateHostName = (client) => {
const hostName = hardware.getHostName(); const hostName = hardware.getHostName();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/host_name`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/host_name`;
client.publish(`${root}/status`, `${hostName}`, { if (hostName !== null) {
qos: 1, client.publish(`${root}/status`, `${hostName}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -455,19 +421,16 @@ const updateHostName = (client) => {
*/ */
const initUpTime = (client) => { const initUpTime = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/up_time`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/up_time`;
client.publish( const config = {
`${root}/config`, name: `Up Time`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_up_time`,
name: `Up Time`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_up_time`, value_template: "{{ (value | float) | round(0) }}",
state_topic: `${root}/status`, unit_of_measurement: "min",
value_template: "{{ (value | float) | round(0) }}", icon: "mdi:timeline-clock",
unit_of_measurement: "min", device: INTEGRATION.device,
icon: "mdi:timeline-clock", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateUpTime(client); updateUpTime(client);
}; };
@@ -479,10 +442,9 @@ const initUpTime = (client) => {
const updateUpTime = (client) => { const updateUpTime = (client) => {
const upTime = hardware.getUpTime(); const upTime = hardware.getUpTime();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/up_time`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/up_time`;
client.publish(`${root}/status`, `${upTime}`, { if (upTime !== null) {
qos: 1, client.publish(`${root}/status`, `${upTime}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -492,19 +454,16 @@ const updateUpTime = (client) => {
*/ */
const initMemorySize = (client) => { const initMemorySize = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_size`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_size`;
client.publish( const config = {
`${root}/config`, name: `Memory Size`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_memory_size`,
name: `Memory Size`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_memory_size`, value_template: "{{ (value | float) | round(2) }}",
state_topic: `${root}/status`, unit_of_measurement: "GiB",
value_template: "{{ (value | float) | round(2) }}", icon: "mdi:memory",
unit_of_measurement: "GiB", device: INTEGRATION.device,
icon: "mdi:memory", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateMemorySize(client); updateMemorySize(client);
}; };
@@ -516,10 +475,9 @@ const initMemorySize = (client) => {
const updateMemorySize = (client) => { const updateMemorySize = (client) => {
const memorySize = hardware.getMemorySize(); const memorySize = hardware.getMemorySize();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_size`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_size`;
client.publish(`${root}/status`, `${memorySize}`, { if (memorySize !== null) {
qos: 1, client.publish(`${root}/status`, `${memorySize}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -529,19 +487,16 @@ const updateMemorySize = (client) => {
*/ */
const initMemoryUsage = (client) => { const initMemoryUsage = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_usage`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_usage`;
client.publish( const config = {
`${root}/config`, name: `Memory Usage`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_memory_usage`,
name: `Memory Usage`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_memory_usage`, value_template: "{{ (value | float) | round(0) }}",
state_topic: `${root}/status`, unit_of_measurement: "%",
value_template: "{{ (value | float) | round(0) }}", icon: "mdi:memory-arrow-down",
unit_of_measurement: "%", device: INTEGRATION.device,
icon: "mdi:memory-arrow-down", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateMemoryUsage(client); updateMemoryUsage(client);
}; };
@@ -553,10 +508,9 @@ const initMemoryUsage = (client) => {
const updateMemoryUsage = (client) => { const updateMemoryUsage = (client) => {
const memoryUsage = hardware.getMemoryUsage(); const memoryUsage = hardware.getMemoryUsage();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_usage`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/memory_usage`;
client.publish(`${root}/status`, `${memoryUsage}`, { if (memoryUsage !== null) {
qos: 1, client.publish(`${root}/status`, `${memoryUsage}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -566,19 +520,16 @@ const updateMemoryUsage = (client) => {
*/ */
const initProcessorUsage = (client) => { const initProcessorUsage = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_usage`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_usage`;
client.publish( const config = {
`${root}/config`, name: `Processor Usage`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_processor_usage`,
name: `Processor Usage`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_processor_usage`, value_template: "{{ (value | float) | round(0) }}",
state_topic: `${root}/status`, unit_of_measurement: "%",
value_template: "{{ (value | float) | round(0) }}", icon: "mdi:cpu-64-bit",
unit_of_measurement: "%", device: INTEGRATION.device,
icon: "mdi:cpu-64-bit", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateProcessorUsage(client); updateProcessorUsage(client);
}; };
@@ -590,10 +541,9 @@ const initProcessorUsage = (client) => {
const updateProcessorUsage = (client) => { const updateProcessorUsage = (client) => {
const processorUsage = hardware.getProcessorUsage(); const processorUsage = hardware.getProcessorUsage();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_usage`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_usage`;
client.publish(`${root}/status`, `${processorUsage}`, { if (processorUsage !== null) {
qos: 1, client.publish(`${root}/status`, `${processorUsage}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -603,19 +553,16 @@ const updateProcessorUsage = (client) => {
*/ */
const initProcessorTemperature = (client) => { const initProcessorTemperature = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_temperature`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_temperature`;
client.publish( const config = {
`${root}/config`, name: `Processor Temperature`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_processor_temperature`,
name: `Processor Temperature`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_processor_temperature`, value_template: "{{ (value | float) | round(0) }}",
state_topic: `${root}/status`, unit_of_measurement: "°C",
value_template: "{{ (value | float) | round(0) }}", icon: "mdi:radiator",
unit_of_measurement: "°C", device: INTEGRATION.device,
icon: "mdi:radiator", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateProcessorTemperature(client); updateProcessorTemperature(client);
}; };
@@ -627,10 +574,9 @@ const initProcessorTemperature = (client) => {
const updateProcessorTemperature = (client) => { const updateProcessorTemperature = (client) => {
const processorTemperature = hardware.getProcessorTemperature(); const processorTemperature = hardware.getProcessorTemperature();
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_temperature`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/processor_temperature`;
client.publish(`${root}/status`, `${processorTemperature}`, { if (processorTemperature !== null) {
qos: 1, client.publish(`${root}/status`, `${processorTemperature}`, { qos: 1, retain: true });
retain: true, }
});
}; };
/** /**
@@ -640,18 +586,15 @@ const updateProcessorTemperature = (client) => {
*/ */
const initHeartbeat = (client) => { const initHeartbeat = (client) => {
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/heartbeat`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/heartbeat`;
client.publish( const config = {
`${root}/config`, name: `Heartbeat`,
JSON.stringify({ unique_id: `${INTEGRATION.node}_heartbeat`,
name: `Heartbeat`, state_topic: `${root}/status`,
unique_id: `${INTEGRATION.node}_heartbeat`, value_template: "{{ value }}",
state_topic: `${root}/status`, icon: "mdi:heart-flash",
value_template: "{{ value }}", device: INTEGRATION.device,
icon: "mdi:heart-flash", };
device: INTEGRATION.device, client.publish(`${root}/config`, JSON.stringify(config), { qos: 1, retain: true });
}),
{ qos: 1, retain: true }
);
updateHeartbeat(client); updateHeartbeat(client);
}; };
@@ -665,10 +608,7 @@ const updateHeartbeat = (client) => {
const local = new Date(now.getTime() - now.getTimezoneOffset() * 60 * 1000); const local = new Date(now.getTime() - now.getTimezoneOffset() * 60 * 1000);
const heartbeat = local.toISOString().replace(/\.\d{3}Z$/, ""); const heartbeat = local.toISOString().replace(/\.\d{3}Z$/, "");
const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/heartbeat`; const root = `${INTEGRATION.discovery}/sensor/${INTEGRATION.node}/heartbeat`;
client.publish(`${root}/status`, `${heartbeat}`, { client.publish(`${root}/status`, `${heartbeat}`, { qos: 1, retain: true });
qos: 1,
retain: true,
});
}; };
module.exports = { module.exports = {
+5 -8
View File
@@ -93,7 +93,7 @@ const windowEvents = (window, zoom) => {
window.blur(); window.blur();
} }
/* This also works, but it doesn't allow to react for screen wake up. /* This also works, but it doesn't allow to react for screen wake up.
window.setIgnoreMouseEvents(getDisplayStatus() === "OFF"); window.setIgnoreMouseEvents(hardware.getDisplayStatus() === "OFF");
*/ */
}); });
window.on("focus", () => { window.on("focus", () => {
@@ -136,13 +136,10 @@ const windowEvents = (window, zoom) => {
const viewEvents = (view) => { const viewEvents = (view) => {
// Enable webview touch emulation // Enable webview touch emulation
view.webContents.debugger.attach("1.1"); view.webContents.debugger.attach("1.1");
view.webContents.debugger.sendCommand( view.webContents.debugger.sendCommand("Emulation.setEmitTouchEventsForMouse", {
"Emulation.setEmitTouchEventsForMouse", enabled: true,
{ configuration: "mobile",
enabled: true, });
configuration: "mobile",
}
);
// Disable webview hyperlinks // Disable webview hyperlinks
view.webContents.setWindowOpenHandler(() => { view.webContents.setWindowOpenHandler(() => {
+9 -4
View File
@@ -1129,10 +1129,10 @@ electron-installer-debian@^3.2.0:
word-wrap "^1.2.3" word-wrap "^1.2.3"
yargs "^16.0.2" yargs "^16.0.2"
electron@^33.2.1: electron@^33.3.1:
version "33.2.1" version "33.3.1"
resolved "https://registry.yarnpkg.com/electron/-/electron-33.2.1.tgz#d0d7bba7a7abf4f14881d0a6e03c498b301a2d5f" resolved "https://registry.yarnpkg.com/electron/-/electron-33.3.1.tgz#26d63b3a110c4a9db639c33633bf806f91b4f649"
integrity sha512-SG/nmSsK9Qg1p6wAW+ZfqU+AV8cmXMTIklUL18NnOKfZLlum4ZsDoVdmmmlL39ZmeCaq27dr7CgslRPahfoVJg== integrity sha512-Z7l2bVgpdKxHQMI4i0CirBX2n+iCYKOx5mbzNM3BpOyFELwlobEXKmzCmEnwP+3EcNeIhUQyIEBFQxN06QgdIw==
dependencies: dependencies:
"@electron/get" "^2.0.0" "@electron/get" "^2.0.0"
"@types/node" "^20.9.0" "@types/node" "^20.9.0"
@@ -2396,6 +2396,11 @@ postject@^1.0.0-alpha.6:
dependencies: dependencies:
commander "^9.4.0" commander "^9.4.0"
prettier@^3.4.2:
version "3.4.2"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.4.2.tgz#a5ce1fb522a588bf2b78ca44c6e6fe5aa5a2b13f"
integrity sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==
proc-log@^2.0.1: proc-log@^2.0.1:
version "2.0.1" version "2.0.1"
resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-2.0.1.tgz#8f3f69a1f608de27878f91f5c688b225391cb685" resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-2.0.1.tgz#8f3f69a1f608de27878f91f5c688b225391cb685"