Hi, I’m developing a zigbee lock and a matching homey app. I have got so far as to sen unlock/lock commands to the lock and that is working.
Now I’d like to get attribute reports for closureDoorLock/lockState and battery alarms or measurements but I wont get any callbacks, even if I see the reports in the debug log. (i’m missing the console.log('onLockStateReport ’ + report); calls, see below)
This is probably a rookie javascript error, but I’m stuck so any help is appreciated!
device.js:
'use strict';
const ZigBeeDevice = require('homey-meshdriver').ZigBeeDevice;
class UwLockZigbee extends ZigBeeDevice {
onMeshInit() {
console.log('UwLockZigbee onMeshInit called...');
this.enableDebug();
this.printNode();
this.registerCapability('alarm_battery', 'genPowerCfg');
this.registerCapability('locked', 'closuresDoorLock', {
endpoint: this.getClusterEndpoint('closuresDoorLock'),
set: value => value ? 'lockDoor' : 'unlockDoor',
setParser: () => ({pincodevalue: '1234'}),
});
this.registerAttrReportListener(
'closuresDoorLock', // Cluster
'lockState', // Attr
1, // Min report interval in seconds (must be greater than 1)
0, // Max report interval in seconds (must be zero or greater than 60 and greater than min report interval)
1, // Report change value, if value changed more than this value send a report
this.onLockStateReport.bind(this)) // Callback with value
.then(() => {
// Registering attr reporting succeeded
console.log('registered attr report listener');
})
.catch(err => {
// Registering attr reporting failed
this.error('failed to register attr report listener', err);
});
this.registerAttrReportListener(
'genPowerCfg', // Cluster
'batteryPercentageRemaining', // Attr
1, // Min report interval in seconds (must be greater than 1)
0, // Max report interval in seconds (must be zero or greater than 60 and greater than min report interval)
1, // Report change value, if value changed more than this value send a report
this.onPowerCfgBatteryPercentageRemainingReport.bind(this)) // Callback with value
.then(() => {
// Registering attr reporting succeeded
console.log('registered attr report listener');
})
.catch(err => {
// Registering attr reporting failed
this.error('failed to register attr report listener', err);
});
this.registerAttrReportListener(
'genPowerCfg', // Cluster
'batteryAlarmState', // Attr
1, // Min report interval in seconds (must be greater than 1)
0, // Max report interval in seconds (must be zero or greater than 60 and greater than min report interval)
null, // Report change value, if value changed more than this value send a report
this.onPowerCfgBatteryAlarmStateReport.bind(this)) // Callback with value
.then(() => {
// Registering attr reporting succeeded
console.log('registered attr report listener');
})
.catch(err => {
// Registering attr reporting failed
this.error('failed to register attr report listener', err);
});
}
onLockStateReport(report) {
console.log('onLockStateReport ' + report);
this.setCapabilityValue('locked', report.value === 1);
}
onPowerCfgBatteryPercentageRemainingReport(report) {
console.log('onPowerCfgBatteryPercentageRemainingReport ' + report);
}
onPowerCfgBatteryAlarmStateReport(report) {
console.log('onPowerCfgBatteryAlarmStateReport ' + report);
}
}
module.exports = UwLockZigbee;
app.json
{
"id": "se.unitware.uwlock",
"version": "0.0.1",
"compatibility": ">=1.5.0",
"sdk": 2,
"name": {
"en": "uwlock"
},
"description": {
"en": "Connect the uw lock via zigbee"
},
"category": [
"security"
],
"permissions": [],
"images": {
"large": "/assets/images/large.png",
"small": "/assets/images/small.png"
},
"drivers": [
{
"id": "uwlock",
"name": {
"en": "UwLock Driver"
},
"class": "lock",
"capabilities": [ "locked", "alarm_battery" ],
"energy": {
"batteries": ["AAA", "AAA"]
},
"zigbee": {
"manufacturerName": "unitware",
"productId": [
"uwlock"
],
"deviceId": 10,
"profileId": 260,
"learnmode": {
"image": "/drivers/uwlock/assets/learnmode.svg",
"instruction": {
"en": "Unlock the lock on the keypad, wait for leds to go out, swipe, hold button #4 for a while, enter unlock code again."
}
}
}
}
]
}
log
─────────────── Logging stdout & stderr ───────────────
2020-06-08 16:53:34 [log] [UwLockApp] UwLockApp is running...
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ZigBeeDevice has been inited
UwLockPlugZigbee onMeshInit called...
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ------------------------------------------
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] Node: acf5cb1c-26e4-4aca-a81c-b9aa30258803
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] - Battery: true
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] - Endpoints: 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] -- Clusters:
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- zapp
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- genBasic
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : genBasic
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- zclVersion : 2
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- appVersion : 1
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- stackVersion : 10
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- hwVersion : 11
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- manufacturerName : unitware
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- modelId : uwlock
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- dateCode : 20200420
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- powerSource : 3
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- swBuildId :
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- deviceEnabled : 1
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- locationDesc :
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- physicalEnv : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- genPowerCfg
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : genPowerCfg
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- batteryPercentageRemaining : 36
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- batteryAlarmState : 1
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- genIdentify
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : genIdentify
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- identifyTime : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- genGroups
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : genGroups
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- nameSupport : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- genScenes
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : genScenes
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- count : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- currentScene : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- currentGroup : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sceneValid : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- nameSupport : 0
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] --- closuresDoorLock
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- 1 : 2
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- cid : closuresDoorLock
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- sid : attrs
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- lockState : 2
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- actuatorEnabled : 1
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ---- doorState : 1
2020-06-08 16:53:52 [log] [ManagerDrivers] [uwlock] [0] ------------------------------------------
2020-06-08 16:53:53 [log] [ManagerDrivers] [uwlock] [0] registerAttrReportListener() -> configured attr reporting attrReport_0_closuresDoorLock_lockState
registered attr report listener
2020-06-08 16:53:53 [log] [ManagerDrivers] [uwlock] [0] registerAttrReportListener() -> configured attr reporting attrReport_0_genPowerCfg_batteryPercentageRemaining
registered attr report listener
2020-06-08 16:53:54 [log] [ManagerDrivers] [uwlock] [0] registerAttrReportListener() -> configured attr reporting attrReport_0_genPowerCfg_batteryAlarmState
registered attr report listener
2020-06-08 16:54:11 [log] [ManagerDrivers] [uwlock] [0] [dbg] report {
token: 'acf5cb1c-26e4-4aca-a81c-b9aa30258803',
device: '0xf4ce3674f36f5aed',
endpoint: '8',
cluster: 'genPowerCfg',
attr: 'batteryPercentageRemaining',
value: 36,
event: 'report'
}
2020-06-08 16:54:11 [log] [ManagerDrivers] [uwlock] [0] [dbg] report {
token: 'acf5cb1c-26e4-4aca-a81c-b9aa30258803',
device: '0xf4ce3674f36f5aed',
endpoint: '8',
cluster: 'genPowerCfg',
attr: 'batteryAlarmState',
value: 1,
event: 'report'
}