Skip to content

Commit

Permalink
Add support for OJB-CR701-YZ Gas and CO sensor (Koenkk#338)
Browse files Browse the repository at this point in the history
* Add statuschange converter for OJB-CR701-YZ

* Add OJB-CR701-YZ to devices.js

* Fix eslint

* amend

* fix: Set proper vendor for OJB-CR701-YZ

* Update devices.js

* Update fromZigbee.js

* Update devices.js

* Update devices.js

* Update fromZigbee.js
  • Loading branch information
FrankZZ authored and qosmio committed Dec 25, 2019
1 parent 2e17649 commit 31fb0bc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions converters/fromZigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -4376,6 +4376,23 @@ const converters = {
};
},
},
OJBCR701YZ_statuschange: {
cid: 'ssIasZone',
type: 'statusChange',
convert: (model, msg, publish, options) => {
const {zoneStatus} = msg.data;
return {
carbon_monoxide: (zoneStatus & 1) > 0, // Bit 0 = Alarm 1: Carbon Monoxide (CO)
gas: (zoneStatus & 1 << 1) > 0, // Bit 1 = Alarm 2: Gas (CH4)
tamper: (zoneStatus & 1 << 2) > 0, // Bit 2 = Tamper
battery_low: (zoneStatus & 1 << 3) > 0, // Bit 3 = Low battery alarm
trouble: (zoneStatus & 1 << 6) > 0, // Bit 6 = Trouble/Failure
ac_connected: !((zoneStatus & 1 << 7) > 0), // Bit 7 = AC Connected
test: (zoneStatus & 1 << 8) > 0, // Bit 8 = Self test
battery_defect: (zoneStatus & 1 << 9) > 0, // Bit 9 = Battery Defect
};
},
},

// Ignore converters (these message dont need parsing).
ignore_onoff_report: {
Expand Down
20 changes: 20 additions & 0 deletions devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -8101,6 +8101,26 @@ const devices = [
toZigbee: [],
},

// Oujiabao
{
zigbeeModel: ['OJB-CR701-YZ'],
model: 'CR701-YZ',
vendor: 'Oujiabao',
description: 'Gas and carbon monoxide alarm',
supports: 'gas and carbon monoxide',
fromZigbee: [fz.OJBCR701YZ_statuschange],
toZigbee: [],
configure: (ieeeAddr, shepherd, coordinator, callback) => {
const device = shepherd.find(ieeeAddr, 1);
const actions = [
(cb) => device.bind('ssIasZone', coordinator, cb),
(cb) => device.functional('ssIasZone', 'enrollRsp', {enrollrspcode: 0, zoneid: 23}, cb),
];

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

// Calex
{
zigbeeModel: ['EC-Z3.0-CCT '],
Expand Down

0 comments on commit 31fb0bc

Please sign in to comment.