From 0b0a9bca4d4c24caa6e571ef5c110f223f22e6f1 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Sun, 10 Nov 2019 19:53:37 +0100 Subject: [PATCH] Update converters. --- lib/extension/homeassistant.js | 1 + npm-shrinkwrap.json | 18 +++++++++--------- package.json | 2 +- test/entityPublish.test.js | 24 ++++++++++++++++++++++++ test/settings.test.js | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/lib/extension/homeassistant.js b/lib/extension/homeassistant.js index 592773d33..a37cddc3e 100644 --- a/lib/extension/homeassistant.js +++ b/lib/extension/homeassistant.js @@ -967,6 +967,7 @@ const mapping = { 'TERNCY-PP01': [cfg.sensor_temperature, cfg.binary_sensor_occupancy, cfg.sensor_illuminance, cfg.sensor_click], 'CR11S8UZ': [cfg.sensor_action], 'RB 148 T': [cfg.light_brightness_colortemp], + 'STS-OUT-US-2': [cfg.switch], }; Object.keys(mapping).forEach((key) => { diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 807946d8b..ef15ec277 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -4612,9 +4612,9 @@ "dev": true }, "prompts": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.2.1.tgz", - "integrity": "sha512-VObPvJiWPhpZI6C5m60XOzTfnYg/xc/an+r9VYymj9WJW3B/DIH+REzjpAACPf8brwPeP+7vz3bIim3S+AaMjw==", + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.3.0.tgz", + "integrity": "sha512-NfbbPPg/74fT7wk2XYQ7hAIp9zJyZp5Fu19iRbORqqy1BhtrkZ0fPafBU+7bmn8ie69DpT0R6QpJIN2oisYjJg==", "dev": true, "requires": { "kleur": "^3.0.3", @@ -5033,9 +5033,9 @@ } }, "sisteransi": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.3.tgz", - "integrity": "sha512-SbEG75TzH8G7eVXFSN5f9EExILKfly7SUvVY5DhhYLvfhKqhDFY0OzevWa/zwak0RLRfWS5AvfMWpd9gJvr5Yg==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.4.tgz", + "integrity": "sha512-/ekMoM4NJ59ivGSfKapeG+FWtrmWvA1p6FBZwXrqojw90vJu8lBmrTxCMuBCydKtkaUe2zt4PlxeTKpjwMbyig==", "dev": true }, "slash": { @@ -12637,9 +12637,9 @@ } }, "zigbee-herdsman-converters": { - "version": "11.1.40", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-11.1.40.tgz", - "integrity": "sha512-E2raZCAWdTv7MIPvGICJmbo8Bhw4A4eQPCS96p2/oXgwmdYNTCC9iClCqbz7oX9NaeeBuh03s3ctiPOAa9QJyg==" + "version": "11.1.41", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-11.1.41.tgz", + "integrity": "sha512-zNcpbpSOzVaLyWWApKOB+qkNeIzRY2bjTLRVULiX/InvFnY51VupxPF5bw+Ul3kXCZOXcDftBADxQ57WeTpSnQ==" } } } diff --git a/package.json b/package.json index 53a32358b..6399223fd 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "semver": "*", "winston": "*", "zigbee-herdsman": "0.12.3", - "zigbee-herdsman-converters": "11.1.40" + "zigbee-herdsman-converters": "11.1.41" }, "devDependencies": { "eslint": "*", diff --git a/test/entityPublish.test.js b/test/entityPublish.test.js index bdfdae0b1..3eadab267 100644 --- a/test/entityPublish.test.js +++ b/test/entityPublish.test.js @@ -752,6 +752,30 @@ describe('Entity publish', () => { expect(JSON.parse(MQTT.publish.mock.calls[0][1])).toStrictEqual({color: {x: 0.41, y: 0.25}, color_temp: 150, state: 'ON'}); }); + it('Should publish correct state on toggle command to zigbee bulb', async () => { + const endpoint = zigbeeHerdsman.devices.bulb_color.getEndpoint(1); + await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({state: 'TOGGLE'})); + await flushPromises(); + + // At this point the bulb has no state yet, so we cannot determine the next state and therefore shouldn't publish it to MQTT. + expect(endpoint.command).toHaveBeenCalledTimes(1); + expect(endpoint.command).toHaveBeenCalledWith("genOnOff", "toggle", {}, {}); + expect(MQTT.publish).toHaveBeenCalledTimes(0); + + // Turn bulb off so that the bulb gets a state. + await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({state: 'OFF'})); + await flushPromises(); + + // Toggle again, now that we have state it should publish state ON + await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({state: 'TOGGLE'})); + await flushPromises(); + expect(endpoint.command).toHaveBeenCalledTimes(3); + expect(MQTT.publish).toHaveBeenCalledTimes(2); + expect(MQTT.publish.mock.calls[1][0]).toStrictEqual('zigbee2mqtt/bulb_color'); + expect(JSON.parse(MQTT.publish.mock.calls[1][1])).toStrictEqual({state: 'ON'}); + expect(MQTT.publish.mock.calls[1][2]).toStrictEqual({"qos": 0, "retain": false}); + }); + it('Should publish messages with options disableDefaultResponse', async () => { const device = zigbeeHerdsman.devices.GLEDOPTO1112; const endpoint = device.getEndpoint(11); diff --git a/test/settings.test.js b/test/settings.test.js index 6ce094c0c..6a00199b8 100644 --- a/test/settings.test.js +++ b/test/settings.test.js @@ -91,7 +91,7 @@ describe('Settings', () => { settings.getDevice('0x12345678'); }); - it('onlythis Should read MQTT username asn password form a separate file', () => { + it('Should read MQTT username asn password form a separate file', () => { const contentConfiguration = { mqtt: { server: 'my.mqtt.server',