From f5a42f41e978e81b9bb2bbbf03afbfda6ac3eb17 Mon Sep 17 00:00:00 2001 From: Codegnosis Date: Mon, 18 Mar 2024 13:33:09 +0000 Subject: [PATCH] add debug output & debug config toggle --- src/config-utils.ts | 3 ++- src/constants.ts | 2 ++ src/givtcp-battery-card.ts | 4 ++++ src/schemas.ts | 8 ++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/config-utils.ts b/src/config-utils.ts index b8ec25a..2a27d6c 100644 --- a/src/config-utils.ts +++ b/src/config-utils.ts @@ -19,7 +19,7 @@ import { DISPLAY_BATTERY_RATES, USE_CUSTOM_DOD, CUSTOM_DOD, - CALCULATE_RESERVE_FROM_DOD, DISPLAY_CUSTOM_DOD_STATS, + CALCULATE_RESERVE_FROM_DOD, DISPLAY_CUSTOM_DOD_STATS, ENABLE_DEBUG_OUTPUT, } from "./constants"; export class ConfigUtils { @@ -47,6 +47,7 @@ export class ConfigUtils { custom_dod: CUSTOM_DOD, calculate_reserve_from_dod: CALCULATE_RESERVE_FROM_DOD, display_custom_dod_stats: DISPLAY_CUSTOM_DOD_STATS, + enable_debug_output: ENABLE_DEBUG_OUTPUT, }; } diff --git a/src/constants.ts b/src/constants.ts index d7acd1a..84bb677 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -39,3 +39,5 @@ export const DISPLAY_UNITS = { WH: "Wh", KWH: "kWh", } + +export const ENABLE_DEBUG_OUTPUT = false; diff --git a/src/givtcp-battery-card.ts b/src/givtcp-battery-card.ts index 19096cc..868bc61 100644 --- a/src/givtcp-battery-card.ts +++ b/src/givtcp-battery-card.ts @@ -341,6 +341,10 @@ export class GivTCPBatteryCard extends LitElement implements LovelaceCard { displayUnit: "%", } + if(this.config.enable_debug_output === true) { + console.log(states); + } + this.calculatedStates = states; } diff --git a/src/schemas.ts b/src/schemas.ts index f863a1f..956032f 100644 --- a/src/schemas.ts +++ b/src/schemas.ts @@ -22,6 +22,14 @@ export const GENERAL_SCHEMA = (invertorList: string[], defaults: LovelaceCardCon } }, }, + { + name: 'enable_debug_output', + label: 'Enable debug output to developer console', + default: defaults.enable_debug_output, + selector: { + boolean: {} + } + }, ]; }