forked from denysdovhan/vacuum-card
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
33 lines (29 loc) · 910 Bytes
/
config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import localize from './localize';
import { VacuumCardConfig } from './types';
export default function buildConfig(
config?: Partial<VacuumCardConfig>
): VacuumCardConfig {
if (!config) {
throw new Error(localize('error.invalid_config'));
}
if (!config.entity) {
throw new Error(localize('error.missing_entity'));
}
const actions = config.actions;
if (actions && Array.isArray(actions)) {
console.warn(localize('warning.actions_array'));
}
return {
entity: config.entity,
map: config.map ?? '',
map_refresh: config.map_refresh ?? 5,
image: config.image ?? 'default',
show_name: config.show_name ?? true,
show_status: config.show_status ?? true,
show_toolbar: config.show_toolbar ?? true,
compact_view: config.compact_view ?? false,
stats: config.stats ?? {},
actions: config.actions ?? {},
shortcuts: config.shortcuts ?? [],
};
}