Skip to content

Commit

Permalink
Add support for accelerometer axes in Samsung Smartthings Multipurpos…
Browse files Browse the repository at this point in the history
…e Sensor (F-MLT-US-2)
  • Loading branch information
Declan Shanaghy committed Feb 19, 2021
1 parent 405aca0 commit 8f3e106
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ node_modules/
.remote-sync.json
.eslintrc.js
.vscode
tmp
18 changes: 17 additions & 1 deletion converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
16 changes: 12 additions & 4 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -8132,11 +8132,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.acceleration(),
],
},
{
zigbeeModel: ['multi'],
Expand Down
8 changes: 8 additions & 0 deletions lib/exposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,5 +512,13 @@ 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),
acceleration: () => {
return [
new Binary('moving', access.STATE, true, false),
new Numeric('x_axis', access.STATE).withDescription('Accelerometer X value').withUnit(''),
new Numeric('y_axis', access.STATE).withDescription('Accelerometer Y value').withUnit(''),
new Numeric('z_axis', access.STATE).withDescription('Accelerometer Z value').withUnit(''),
];
},
},
};

0 comments on commit 8f3e106

Please sign in to comment.