diff --git a/lib/extension/deviceReport.js b/lib/extension/deviceReport.js index 43721fc39..040903ca4 100644 --- a/lib/extension/deviceReport.js +++ b/lib/extension/deviceReport.js @@ -36,10 +36,17 @@ const pollOnMessage = [ key: 1, // On messages that have the cluster and type of below cluster: { - manuSpecificPhilips: ['commandHueNotification'], + manuSpecificPhilips: [ + {type: 'commandHueNotification', data: {button: 2}}, + {type: 'commandHueNotification', data: {button: 3}}, + ], genLevelCtrl: [ - 'commandStep', 'commandStepWithOnOff', 'commandStop', 'commandMoveWithOnOff', 'commandStopWithOnOff', - 'commandMove', + {type: 'commandStep', data: {}}, + {type: 'commandStepWithOnOff', data: {}}, + {type: 'commandStop', data: {}}, + {type: 'commandMoveWithOnOff', data: {}}, + {type: 'commandStopWithOnOff', data: {}}, + {type: 'commandMove', data: {}}, ], }, // Read the following attributes @@ -136,9 +143,9 @@ class DeviceReport extends BaseExtension { * When dimming the bulb via the dimmer switch the state is therefore not reported. * When we receive a message from a Hue dimmer we read the brightness from the bulb (if bound). */ - const polls = pollOnMessage.filter((p) => - p.cluster[message.cluster] && p.cluster[message.cluster].includes(message.type) + p.cluster[message.cluster] && p.cluster[message.cluster].find((c) => c.type === message.type && + utils.equalsPartial(message.data, c.data)) ); if (polls.length) { diff --git a/lib/util/utils.js b/lib/util/utils.js index 4900a7319..2f3a9445b 100644 --- a/lib/util/utils.js +++ b/lib/util/utils.js @@ -1,4 +1,5 @@ const zigbeeHerdsmanConverters = require('zigbee-herdsman-converters'); +const equals = require('fast-deep-equal'); // Xiaomi uses 4151 and 4447 (lumi.plug) as manufacturer ID. const xiaomiManufacturerID = [4151, 4447]; @@ -98,6 +99,16 @@ function objectHasProperties(object, properties) { return true; } +function equalsPartial(object, expected) { + for (const [key, value] of Object.entries(expected)) { + if (!equals(object[key], value)) { + return false; + } + } + + return true; +} + module.exports = { millisecondsToSeconds: (milliseconds) => milliseconds / 1000, secondsToMilliseconds: (seconds) => seconds * 1000, @@ -112,4 +123,5 @@ module.exports = { isRouter: (device) => device.type === 'Router' && !forceEndDevice.includes(device.modelID), isBatteryPowered: (device) => device.powerSource && device.powerSource === 'Battery', formatDate: (date, type, _default=null) => formatDate(date, type, _default), + equalsPartial, };