Skip to content

Commit

Permalink
Merge pull request #86 from davbauer/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
davbauer committed Apr 1, 2024
2 parents 14f8e92 + 9c2bb96 commit 8889f05
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 290 deletions.
2 changes: 1 addition & 1 deletion backend/classes/ConfigFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default class {
try {
const jsonData = JSON.stringify(config, null, 4);
fs.writeFileSync(this.filePath, jsonData, 'utf-8');
this.cachedConfig = config;
this.cachedConfig = JSON.parse(JSON.stringify(config));
return true;
} catch (error) {
errorLog(`ConfigFile.write: Error writing config: ${error}`);
Expand Down
6 changes: 5 additions & 1 deletion backend/classes/LiveData.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import InterfaceLiveData from '../models/InterfaceLiveData.js';

export default class {
static defaultData: InterfaceLiveData = {
private static defaultData: InterfaceLiveData = {
Timestamp: null,
Inverter: {
Export: -1,
Expand Down Expand Up @@ -32,5 +32,9 @@ export default class {
Power: -1
}
};

static setDefault(): void {
this.data = JSON.parse(JSON.stringify(this.defaultData));
}
static data: InterfaceLiveData = this.defaultData;
}
3 changes: 1 addition & 2 deletions backend/loop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ export default async function (): Promise<void> {
infoLog('\n---------------------------------------------------------------');
infoLog('LOOP (' + ConfigFile.read().CheckSeconds + 's) --------------------|');

LiveData.data = LiveData.defaultData;

LiveData.setDefault();
const config: InterfaceConfig = ConfigFile.read();

infoLog(`Mode: '${config.Mode}'`);
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chargecontroller",
"version": "1.0.13.1",
"version": "1.0.14",
"private": true,
"scripts": {
"dev": "vite dev --host 0.0.0.0",
Expand All @@ -16,10 +16,10 @@
"@sveltejs/adapter-static": "^3.0.1",
"@sveltejs/kit": "^2.5.2",
"@sveltejs/vite-plugin-svelte": "^3.0.2",
"@types/node": "^20.11.19",
"@types/node": "^20.12.2",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.0.2",
"@typescript-eslint/parser": "^7.1.0",
"@typescript-eslint/parser": "^7.4.0",
"autoprefixer": "^10.4.17",
"axios": "^1.6.7",
"daisyui": "^4.7.2",
Expand All @@ -31,12 +31,12 @@
"prettier": "^3.2.5",
"prettier-plugin-svelte": "^3.2.2",
"svelte": "^4.2.12",
"svelte-check": "^3.6.4",
"svelte-check": "^3.6.8",
"svelte-icons": "^2.1.0",
"tailwindcss": "^3.4.1",
"tailwindcss": "^3.4.3",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vite": "^5.1.4"
"vite": "^5.2.7"
},
"type": "module"
}
Loading

0 comments on commit 8889f05

Please sign in to comment.