Skip to content

Commit

Permalink
Add Samsung SmartThings Arrival Sensor support (Koenkk#118)
Browse files Browse the repository at this point in the history
* Support F-ARR-US-2. Koenkk/zigbee2mqtt#459

* STS-PRS-251 report battery. Koenkk/zigbee2mqtt#459

* Update STS_PRS_251. Koenkk/zigbee2mqtt#459

* Update. Koenkk/zigbee2mqtt#459

* Update fromZigbee.js

* Update fromZigbee.js
  • Loading branch information
Koenkk authored and qosmio committed Dec 25, 2019
1 parent d1587f4 commit b7616b5
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,17 @@ const numberWithinRange = (number, min, max) => {
}
};

const toPercentage = (value, min, max) => {
if (value > max) {
value = max;
} else if (value < min) {
value = min;
}

const normalised = (value - min) / (max - min);
return (normalised * 100).toFixed(2);
};

const numberWithinRange = (number, min, max) => {
if (number > max) {
return max;
Expand Down
18 changes: 18 additions & 0 deletions converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,24 @@ const converters = {
};
},
},
STS_PRS_251_beep: {
key: 'beep',
attr: ['identifyTime'],
convert: (value, message) => {
return {
cid: 'genIdentify',
cmd: 'identify',
type: 'functional',
zclData: {
identifytime: value,
},
cfg: {
manufSpec: 0,
disDefaultRsp: 0,
},
};
},
},
// Ignore converters
ignore_transition: {
key: 'transition',
Expand Down
18 changes: 18 additions & 0 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -6909,6 +6909,24 @@ const devices = [
fromZigbee: [fz.smartthings_contact],
toZigbee: [],
},
{
zigbeeModel: ['tagv4'],
model: 'STS-PRS-251',
vendor: 'SmartThings',
description: 'SmartThings arrival sensor',
supports: 'presence',
fromZigbee: [fz.STS_PRS_251_presence, fz.STS_PRS_251_battery, fz.ignore_power_change, fz.STS_PRS_251_beeping],
toZigbee: [tz.STS_PRS_251_beep],
configure: (ieeeAddr, shepherd, coordinator, callback) => {
const device = shepherd.find(ieeeAddr, 1);
const actions = [
(cb) => device.report('genBinaryInput', 'presentValue', 10, 30, 1, cb),
(cb) => device.report('genPowerCfg', 'batteryVoltage', 1800, 3600),
];

execute(device, actions, callback);
},
},

// Trust
{
Expand Down

0 comments on commit b7616b5

Please sign in to comment.