Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #86

Merged
merged 12 commits into from
Apr 1, 2024
Merged

Dev #86

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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