diff --git a/npm-shrinkwrap.json b/npm-shrinkwrap.json index 026d9dba0..45560d0f4 100644 --- a/npm-shrinkwrap.json +++ b/npm-shrinkwrap.json @@ -14711,9 +14711,9 @@ } }, "zigbee-herdsman-converters": { - "version": "12.0.147", - "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.147.tgz", - "integrity": "sha512-WlNkN5xG+HdS1hZ5jTjR2vFii1OfOqTFUEQ+uZg06L7V1TucHRPlQ4AMY0WUQksnX2uuRqwehA3iuyszZjBAOg==", + "version": "12.0.148", + "resolved": "https://registry.npmjs.org/zigbee-herdsman-converters/-/zigbee-herdsman-converters-12.0.148.tgz", + "integrity": "sha512-H/+5UUU+tPyPdqv9ka7gPL8XBlILg+Ve9JtkzdN2w4IiICsGrtlP6EKaiKGDC6sbftJVqa/7YgtTJd2aB1PTqw==", "requires": { "axios": "^0.19.2", "https-proxy-agent": "^5.0.0", diff --git a/package.json b/package.json index 3b3f8baec..6833a1043 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "winston": "^3.3.3", "winston-syslog": "^2.4.4", "zigbee-herdsman": "0.12.108", - "zigbee-herdsman-converters": "12.0.147" + "zigbee-herdsman-converters": "12.0.148" }, "devDependencies": { "eslint": "*", diff --git a/test/publish.test.js b/test/publish.test.js index 25af1f526..4d9923899 100644 --- a/test/publish.test.js +++ b/test/publish.test.js @@ -980,15 +980,28 @@ describe('Publish', () => { // Turn bulb off so that the bulb gets a state. await MQTT.events.message('zigbee2mqtt/bulb_color/set', JSON.stringify({state: 'OFF'})); await flushPromises(); + expect(MQTT.publish).toHaveBeenCalledTimes(1); + expect(MQTT.publish).toHaveBeenNthCalledWith(1, + 'zigbee2mqtt/bulb_color', + JSON.stringify({state: 'OFF', brightness: 0}), + {retain: false, qos: 0}, expect.any(Function) + ); - // Toggle again, now that we have state it should publish state ON + // Toggle again, now that we have state it should publish state ON and retrieve the brightness from the bulb. + endpoint.read.mockImplementationOnce((cluster, attrs) => { + if (cluster === 'genLevelCtrl' && attrs.includes('currentLevel')) { + return {currentLevel: 100}; + } + }); 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', brightness: 0}); - expect(MQTT.publish.mock.calls[1][2]).toStrictEqual({"qos": 0, "retain": false}); + expect(MQTT.publish).toHaveBeenNthCalledWith(2, + 'zigbee2mqtt/bulb_color', + JSON.stringify({state: 'ON', brightness: 100}), + {retain: false, qos: 0}, expect.any(Function) + ); }); it('Should publish messages with options disableDefaultResponse', async () => {