diff --git a/lib/extension/bridgeConfig.js b/lib/extension/bridgeConfig.js index fa3efd65..0676c4cb 100644 --- a/lib/extension/bridgeConfig.js +++ b/lib/extension/bridgeConfig.js @@ -87,7 +87,7 @@ class BridgeConfig extends BaseExtension { async reset(topic, message) { try { - await this.zigbee.softReset(); + await this.zigbee.reset('soft'); logger.info('Soft resetted ZNP'); } catch (error) { logger.error('Soft reset failed'); diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 7056afc0..2d4a978b 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -912,6 +912,9 @@ const mapping = { '3300-P': [cfg.sensor_temperature, cfg.binary_sensor_contact, cfg.sensor_battery], 'GL-B-008ZS': [cfg.light_brightness_colortemp_colorxy], 'T1829': [cfg.light_brightness_colortemp], + '929002240401': [cfg.switch], + 'HGZB-20-UK': [cfg.switch], + 'MCT-340 SMA': [cfg.binary_sensor_contact, cfg.binary_sensor_battery_low], }; Object.keys(mapping).forEach((key) => { diff --git a/lib/extension/softReset.js b/lib/extension/softReset.js index dee3f515..31c96e74 100644 --- a/lib/extension/softReset.js +++ b/lib/extension/softReset.js @@ -40,7 +40,7 @@ class SoftReset extends BaseExtension { logger.warn('Soft reset timeout triggered'); try { - await this.zigbee.softReset(); + await this.zigbee.reset('soft'); logger.warn('Soft resetted ZNP due to timeout'); } catch (error) { logger.warn('Soft reset failed, trying stop/start'); diff --git a/lib/util/settings.js b/lib/util/settings.js index bed07bf3..01a73b1f 100644 --- a/lib/util/settings.js +++ b/lib/util/settings.js @@ -126,7 +126,7 @@ const schema = { serial: { type: 'object', properties: { - port: {type: 'string'}, + port: {type: ['string', 'null']}, disable_led: {type: 'boolean'}, }, required: ['port'], diff --git a/lib/zigbee.js b/lib/zigbee.js index 26ed2b17..77f15324 100644 --- a/lib/zigbee.js +++ b/lib/zigbee.js @@ -81,8 +81,8 @@ class Zigbee extends events.EventEmitter { return this.herdsman.getCoordinatorVersion(); } - async softReset() { - await this.herdsman.softReset(); + async reset(type) { + await this.herdsman.reset(type); } async stop() { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index d6470d5a..8447c501 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -6053,9 +6053,9 @@ } }, "zigbee-herdsman": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.8.2.tgz", - "integrity": "sha512-6Txmlms/4ugYHLKPsVzYPaAtjGk5MkmKfhZ0XwVGLU5W48XiEiEIg25vckdkFMe+6GxfisvUkndm756dqgoytA==", + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/zigbee-herdsman/-/zigbee-herdsman-0.9.0.tgz", + "integrity": "sha512-xHAaMHCR/QzN7aoHOUoO6uUnB3s37ChFnQBdqqXf6g4Rjkdwr6czBfz9tWCNFwVQqD6rT7cgOjfIUR8OkHnppA==", "requires": { "debug": "^4.1.1", "fast-deep-equal": "^2.0.1", @@ -12559,9 +12559,9 @@ } }, "zigbee-herdsman-converters": { - "version": "11.1.20", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-11.1.20.tgz", - "integrity": "sha512-Nk9+687IHm1hUM/MpDxU59034IW44DSracQIT0pxjJH5yiIm3nVueWEvycglB7fuQ6q6335yD0FERxkNwtw4UA==", + "version": "11.1.21", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-11.1.21.tgz", + "integrity": "sha512-pMIn6Uuu2r+bvhND26yWutsZfI08MdDbujipabo+9N2ZrLOmiTbvW3r3zUzIQ/UakEDTHIkr0i7SkGPIHykBdQ==", "requires": { "debounce": "^1.2.0" } diff --git a/package.json b/package.json index 41d0cb01..0c4df133 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,8 @@ "rimraf": "*", "semver": "*", "winston": "*", - "zigbee-herdsman": "0.8.2", - "zigbee-herdsman-converters": "11.1.20" + "zigbee-herdsman": "0.9.0", + "zigbee-herdsman-converters": "11.1.21" }, "devDependencies": { "eslint": "*", diff --git a/test/bridgeConfig.test.js b/test/bridgeConfig.test.js index 390eedc3..89ac9fd7 100644 --- a/test/bridgeConfig.test.js +++ b/test/bridgeConfig.test.js @@ -114,14 +114,16 @@ describe('Bridge config', () => { }); it('Should allow to reset', async () => { - zigbeeHerdsman.softReset.mockClear(); + zigbeeHerdsman.reset.mockClear(); MQTT.events.message('zigbee2mqtt/bridge/config/reset', ''); await flushPromises(); - expect(zigbeeHerdsman.softReset).toHaveBeenCalledTimes(1); - zigbeeHerdsman.softReset.mockImplementationOnce(() => {throw new Error('')}); + expect(zigbeeHerdsman.reset).toHaveBeenCalledTimes(1); + expect(zigbeeHerdsman.reset).toHaveBeenCalledWith('soft'); + zigbeeHerdsman.reset.mockImplementationOnce(() => {throw new Error('')}); MQTT.events.message('zigbee2mqtt/bridge/config/reset', ''); await flushPromises(); - expect(zigbeeHerdsman.softReset).toHaveBeenCalledTimes(2); + expect(zigbeeHerdsman.reset).toHaveBeenCalledTimes(2); + expect(zigbeeHerdsman.reset.mock.calls[1][0]).toBe('soft'); }); it('Should allow to set last_seen', async () => { diff --git a/test/stub/zigbeeHerdsman.js b/test/stub/zigbeeHerdsman.js index b3095c71..3142a02d 100644 --- a/test/stub/zigbeeHerdsman.js +++ b/test/stub/zigbeeHerdsman.js @@ -151,7 +151,7 @@ const mock = { return Object.values(groups).find((d) => d.groupID === groupID); }), getPermitJoin: jest.fn().mockReturnValue(false), - softReset: jest.fn(), + reset: jest.fn(), createGroup: jest.fn().mockImplementation((groupID) => { const group = new Group(groupID); groups[`group_${groupID}`] = group