mirror of
https://github.com/joBr99/nspanel-lovelace-ui.git
synced 2026-02-26 19:02:15 +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}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
function subscribePowerSubscriptions (id: string): 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 () {
|
(function () {
|
||||||
if (timeoutPower) {
|
if (timeoutPower) {
|
||||||
clearTimeout(timeoutPower);
|
clearTimeout(timeoutPower);
|
||||||
@@ -8863,7 +8867,6 @@ function subscribePowerSubscriptions (id: string): void {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @function GeneratePowerPage
|
* @function GeneratePowerPage
|
||||||
* @description Generates a page with power state and energy usage information.
|
* @description Generates a page with power state and energy usage information.
|
||||||
|
|||||||
Reference in New Issue
Block a user