Skip to content

Commit

Permalink
add debug output & debug config toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Codegnosis committed Mar 18, 2024
1 parent 5fbca58 commit f5a42f4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/config-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
};
}

Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@ export const DISPLAY_UNITS = {
WH: "Wh",
KWH: "kWh",
}

export const ENABLE_DEBUG_OUTPUT = false;
4 changes: 4 additions & 0 deletions src/givtcp-battery-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 8 additions & 0 deletions src/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
}
},
];
}

Expand Down

0 comments on commit f5a42f4

Please sign in to comment.