Skip to content

Commit

Permalink
TuYa TS0216 Sound and flash siren with linear mapped volume (#2631)
Browse files Browse the repository at this point in the history
* Modify TS0216 to map volume 100 -> 0 and 10 -> 100

* Modify TS0216 to map volume 0 -> 100 and 100 -> 10

* Fix extra semicolon
  • Loading branch information
iglu-sebastian authored May 29, 2021
1 parent a15de4c commit a9a2635
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -2014,7 +2014,9 @@ const converters = {
convert: (model, msg, publish, options, meta) => {
const result = {};
if (msg.data.hasOwnProperty('maxDuration')) result['duration'] = msg.data.maxDuration;
if (msg.data.hasOwnProperty('2')) result['volume'] = msg.data['2'];
if (msg.data.hasOwnProperty('2')) {
result['volume'] = mapNumberRange(msg.data['2'], 100, 10, 0, 100);
}
if (msg.data.hasOwnProperty('61440')) {
result['alarm'] = (msg.data['61440'] == 0) ? false : true;
}
Expand Down
2 changes: 1 addition & 1 deletion converters/toZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -4590,7 +4590,7 @@ const converters = {
ts0216_volume: {
key: ['volume'],
convertSet: async (entity, key, value, meta) => {
await entity.write('ssIasWd', {0x0002: {value: value, type: 0x20}});
await entity.write('ssIasWd', {0x0002: {value: utils.mapNumberRange(value, 0, 100, 100, 10), type: 0x20}});
},
convertGet: async (entity, key, meta) => {
await entity.read('ssIasWd', [0x0002]);
Expand Down

0 comments on commit a9a2635

Please sign in to comment.