mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-18 10:57:01 +01:00
Refactor power subscription handling in NSPanelTs
Refactor subscribePowerSubscriptions to use a subscription key for better management of subscriptions.
This commit is contained in:
@@ -8850,7 +8850,11 @@ function unsubscribePowerSubscriptions (): void {
|
||||
* @returns {void}
|
||||
*/
|
||||
function subscribePowerSubscriptions (id: string): void {
|
||||
on({id: id + '.ACTUAL', change: 'ne'}, async function () {
|
||||
const subscriptionKey = 'power_' + id + '.ACTUAL';
|
||||
if (subscriptions.hasOwnProperty(subscriptionKey)) {
|
||||
return;
|
||||
}
|
||||
subscriptions[subscriptionKey] = on({id: id + '.ACTUAL', change: 'ne'}, async function () {
|
||||
(function () {
|
||||
if (timeoutPower) {
|
||||
clearTimeout(timeoutPower);
|
||||
@@ -8863,7 +8867,6 @@ function subscribePowerSubscriptions (id: string): void {
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @function GeneratePowerPage
|
||||
* @description Generates a page with power state and energy usage information.
|
||||
|
||||
Reference in New Issue
Block a user