-
-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: ensure settings contains default and do not throw errors (#2328)
* fix: ensure settings contains default and do not throw errors * fix: json store tests * fix: ensure mqtt doesn't throw in gateway * fix: typo * fix: ensure mqtt is defined * fix: ensure driver is not inited when port is not defined * fix: catch possible error when driver is not enabled
- Loading branch information
1 parent
777725f
commit 010f22e
Showing
6 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,41 @@ | ||
// config/store.js | ||
|
||
import { GatewayConfig } from "../lib/Gateway"; | ||
import { MqttConfig } from "../lib/MqttClient"; | ||
import { ZwaveConfig } from "../lib/ZwaveClient"; | ||
import { GatewayConfig } from '../lib/Gateway' | ||
import { MqttConfig } from '../lib/MqttClient' | ||
import { ZwaveConfig, deviceConfigPriorityDir } from '../lib/ZwaveClient' | ||
|
||
export type StoreKeys = "settings" | "scenes" | "nodes" | "users"; | ||
export type StoreKeys = 'settings' | 'scenes' | 'nodes' | 'users' | ||
|
||
export interface StoreFile { | ||
file: string; | ||
default: any | ||
file: string | ||
default: any | ||
} | ||
|
||
export interface User { | ||
username: string, | ||
passwordHash: string, | ||
token?: string | ||
username: string | ||
passwordHash: string | ||
token?: string | ||
} | ||
|
||
export interface Settings { | ||
mqtt?: MqttConfig, | ||
zwave?: ZwaveConfig, | ||
gateway?: GatewayConfig | ||
mqtt?: MqttConfig | ||
zwave?: ZwaveConfig | ||
gateway?: GatewayConfig | ||
} | ||
|
||
const store: Record<StoreKeys, StoreFile> = { | ||
settings : { file: 'settings.json', default: {} }, | ||
scenes : { file: 'scenes.json', default: [] }, | ||
nodes : { file: 'nodes.json', default: [] }, | ||
users : { file: 'users.json', default: [] } | ||
settings: { | ||
file: 'settings.json', | ||
default: { | ||
zwave: { | ||
deviceConfigPriorityDir, | ||
enableSoftReset: true, | ||
}, | ||
}, | ||
}, | ||
scenes: { file: 'scenes.json', default: [] }, | ||
nodes: { file: 'nodes.json', default: [] }, | ||
users: { file: 'users.json', default: [] }, | ||
} | ||
|
||
export default store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.