mirror of
https://github.com/Koenkk/zigbee2mqtt.git
synced 2026-07-20 02:21:20 +00:00
Don’t throw error when devices is null. https://github.com/Koenkk/zigbee2mqtt/issues/1973
This commit is contained in:
@@ -14,8 +14,6 @@ const defaults = {
|
||||
serial: {
|
||||
disable_led: false,
|
||||
},
|
||||
devices: {},
|
||||
groups: {},
|
||||
device_options: {},
|
||||
map_options: {
|
||||
graphviz: {
|
||||
@@ -158,6 +156,14 @@ function getWithDefaults() {
|
||||
_settingsWithDefaults = objectAssignDeep.noMutate(defaults, get());
|
||||
}
|
||||
|
||||
if (!_settingsWithDefaults.devices) {
|
||||
_settingsWithDefaults.devices = {};
|
||||
}
|
||||
|
||||
if (!_settingsWithDefaults.groups) {
|
||||
_settingsWithDefaults.groups = {};
|
||||
}
|
||||
|
||||
return _settingsWithDefaults;
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,12 @@ describe('Settings', () => {
|
||||
expect(device).toStrictEqual(expected);
|
||||
});
|
||||
|
||||
it('Should not throw error when devices is null', () => {
|
||||
const content = {devices: null};
|
||||
write(configurationFile, content);
|
||||
settings.getDevice('0x12345678');
|
||||
});
|
||||
|
||||
it('Should read devices form a separate file', () => {
|
||||
const contentConfiguration = {
|
||||
devices: 'devices.yaml',
|
||||
|
||||
Reference in New Issue
Block a user