Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for accelerometer axes in Samsung Smartthings Multipurpose Sensor (F-MLT-US-2) #2260

Merged
merged 5 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.moving(), e.x_axis(), e.y_axis(), e.z_axis(),
],
},
{
zigbeeModel: ['multi'],
Expand Down
4 changes: 4 additions & 0 deletions lib/exposes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
},
};