diff --git a/.gitignore b/.gitignore index 39b2b1e334793..ebe84d023a458 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ node_modules/ .remote-sync.json .eslintrc.js .vscode +tmp diff --git a/converters/fromZigbee.js b/converters/fromZigbee.js index 2ddc6ade5a4f1..40246cdacdc89 100644 --- a/converters/fromZigbee.js +++ b/converters/fromZigbee.js @@ -3406,7 +3406,23 @@ const converters = { cluster: 'manuSpecificSamsungAccelerometer', type: ['attributeReport', 'readResponse'], convert: (model, msg, publish, options, meta) => { - return {moving: msg.data['acceleration'] === 1 ? true : false}; + const payload = {}; + if (msg.data.hasOwnProperty('acceleration')) payload.moving = msg.data['acceleration'] === 1; + + // eslint-disable-next-line + // https://github.com/SmartThingsCommunity/SmartThingsPublic/blob/master/devicetypes/smartthings/smartsense-multi-sensor.src/smartsense-multi-sensor.groovy#L222 + /* + The axes reported by the sensor are mapped differently in the SmartThings DTH. + Preserving that functionality here. + xyzResults.x = z + xyzResults.y = y + xyzResults.z = -x + */ + if (msg.data.hasOwnProperty('z_axis')) payload.x_axis = msg.data['z_axis']; + if (msg.data.hasOwnProperty('y_axis')) payload.y_axis = msg.data['y_axis']; + if (msg.data.hasOwnProperty('x_axis')) payload.z_axis = - msg.data['x_axis']; + + return payload; }, }, byun_smoke_false: { diff --git a/devices.js b/devices.js index cc34f2d2c9bad..907caf7ac9837 100755 --- a/devices.js +++ b/devices.js @@ -8154,11 +8154,19 @@ const devices = [ await endpoint.write('manuSpecificSamsungAccelerometer', {0x0002: {value: 0x0276, type: 0x21}}, options); await reporting.temperature(endpoint); await reporting.batteryVoltage(endpoint); - const payload = reporting.payload('acceleration', 10, repInterval.MINUTE, 1); - await endpoint.configureReporting('manuSpecificSamsungAccelerometer', payload, options); + const payloadA = reporting.payload('acceleration', 10, repInterval.MINUTE, 1); + await endpoint.configureReporting('manuSpecificSamsungAccelerometer', payloadA, options); + const payloadX = reporting.payload('x_axis', 10, repInterval.MINUTE, 1); + await endpoint.configureReporting('manuSpecificSamsungAccelerometer', payloadX, options); + const payloadY = reporting.payload('y_axis', 10, repInterval.MINUTE, 1); + await endpoint.configureReporting('manuSpecificSamsungAccelerometer', payloadY, options); + const payloadZ = reporting.payload('z_axis', 10, repInterval.MINUTE, 1); + await endpoint.configureReporting('manuSpecificSamsungAccelerometer', payloadZ, options); }, - exposes: [e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery(), - exposes.binary('moving', ea.STATE, true, false)], + exposes: [ + e.temperature(), e.contact(), e.battery_low(), e.tamper(), e.battery(), + e.moving(), e.x_axis(), e.y_axis(), e.z_axis(), + ], }, { zigbeeModel: ['multi'], diff --git a/lib/exposes.js b/lib/exposes.js index 02e161194b72d..8228997204269 100644 --- a/lib/exposes.js +++ b/lib/exposes.js @@ -512,5 +512,9 @@ module.exports = { .withFeature(new Numeric('duration', access.SET).withUnit('s').withDescription('Duration in seconds of the alarm')), week: () => new Enum('week', access.STATE_SET, ['5+2', '6+1', '7']).withDescription('Week format user for schedule'), window_detection: () => new Switch().withState('window_detection', true, 'Enables/disables window detection on the device', access.STATE_SET), + moving: () => new Binary('moving', access.STATE, true, false).withDescription('Indicates if the device is moving'), + x_axis: () => new Numeric('x_axis', access.STATE).withDescription('Accelerometer X value'), + y_axis: () => new Numeric('y_axis', access.STATE).withDescription('Accelerometer Y value'), + z_axis: () => new Numeric('z_axis', access.STATE).withDescription('Accelerometer Z value'), }, };