This commit is contained in:
Koen Kanters 2019-11-20 19:06:04 +01:00
parent fdc8fcc02b
commit b23276f7f3
2 changed files with 18 additions and 0 deletions

View File

@ -45,6 +45,12 @@ class DeviceConfigure extends BaseExtension {
onZigbeeEvent(type, data, mappedDevice, settingsDevice) { onZigbeeEvent(type, data, mappedDevice, settingsDevice) {
const device = data.device; const device = data.device;
if (type === 'deviceJoined' && device.meta.hasOwnProperty('configured')) {
delete device.meta.configured;
device.save();
}
if (this.shouldConfigure(device, mappedDevice)) { if (this.shouldConfigure(device, mappedDevice)) {
this.configure(device, mappedDevice, settingsDevice); this.configure(device, mappedDevice, settingsDevice);
} }

View File

@ -54,6 +54,18 @@ describe('Device receive', () => {
expectRemoteConfigured(); expectRemoteConfigured();
}); });
it('Should re-configure when device rejoins', async () => {
expectRemoteConfigured();
const device = zigbeeHerdsman.devices.remote;
const endpoint = device.getEndpoint(1);
await flushPromises();
mockClear(device);
const payload = {device};
zigbeeHerdsman.events.deviceJoined(payload);
await flushPromises();
expectRemoteConfigured();
});
it('Should not configure twice', async () => { it('Should not configure twice', async () => {
expectRemoteConfigured(); expectRemoteConfigured();
const device = zigbeeHerdsman.devices.remote; const device = zigbeeHerdsman.devices.remote;