Hi all
Trying to modify existing drivers / write a new one to get this working with @johan_bendz great Tuya Pro app.
When app is on debug, I can see activity and frames being sent to the Homey Pro, but I cannot get the Homey app to “listen” for these events (i.e. status in Homey is not updating when physical switch is pressed). The other way is working fine (i.e. status on switch is changing when Homey app button is pressed).
How do I get Homey to listen for and respond to the data when pressed?
homey recognises wall switch (debug data):
**zigbee-clusters:cluster** ep: 1, cl: basic (0) read attributes result {
attributes: <Buffer 04 00 00 42 10 5f 54 5a 45 32 30 30 5f 67 62 61 67 6f 69 6c 6f 00 00 00 20 03 01 00 00 20 46 05 00 00 42 06 54 53 30 36 30 31 07 00 00 30 01 fe ff 00 ... 2 more bytes>
} +1ms
2024-01-31T07:28:53.818Z [log] [ManagerDrivers] [Driver:wall_switch_1_gang_tuya] [Device:8c2xxx] 🚀 Wall switch booted up!
data on homey when button is physically pressed (on) (debug data):
zigbee-clusters:cluster ep: 1, cl: tuya (61184) received frame response tuya.response {
status: 0,
transid: 47,
dp: 1,
datatype: 1,
length: 1,
data: <Buffer 01>
data when pressed (off) (debug data):
zigbee-clusters:cluster ep: 1, cl: tuya (61184) received frame response tuya.response {
status: 0,
transid: 51,
dp: 1,
datatype: 1,
length: 1,
data: <Buffer 00>
current test code for device.js:
'use strict';
const { debug, Cluster } = require('zigbee-clusters');
const TuyaSpecificCluster = require('../../lib/TuyaSpecificCluster');
const TuyaSpecificClusterDevice = require("../../lib/TuyaSpecificClusterDevice");
const TuyaOnOffCluster = require('../../lib/TuyaOnOffCluster');
//const {getDataValue} = require('./helpers');
Cluster.addCluster(TuyaSpecificCluster);
Cluster.addCluster(TuyaOnOffCluster)
const WALL_SWITCH_DATA_POINTS = {
onOff: 1
}
class wall_switch_1_gang_tuya extends TuyaSpecificClusterDevice {
async onNodeInit({ zclNode }) {
await super.onNodeInit({ zclNode });
this.printNode();
// debug(true);
await zclNode.endpoints[1].clusters.basic.readAttributes('manufacturerName', 'zclVersion', 'appVersion', 'modelId', 'powerSource', 'attributeReportingStatus')
.catch(err => {
this.error('Error when reading device attributes ', err);
});
this.registerCapabilityListener('onoff', async (onOff) => {
await this.writeBool(WALL_SWITCH_DATA_POINTS.onOff, onOff)
this.log('device on/off set', onOff)
});
zclNode.endpoints[1].clusters.tuya.on("reporting", value => this.processResponse(value));
this.log("🚀 Wall switch booted up!")
}
//new code 29/01
//region Tuya Datapoint Functions
async processResponse(data) {
const dp = data.dp;
const parsedValue = getDataValue(data);
switch (dp) {
case WALL_SWITCH_DATA_POINTS.onOff:
this.log('Wall switch on/off received', parsedValue);
try {
await this.setCapabilityValue('onoff', parsedValue);
} catch (e) {
this.log("Failed to set on/off", e);
}
break;
default:
this.log('Data Point', dp, parsedValue)
}
}
// binding to 61184 / tuya
//end new code
onDeleted() {
this.log('1 Gang Wall GPP Switch removed');
}
}
module.exports = wall_switch_1_gang_tuya;
Tagging @robertklep in case he has any guidance / suggestions as well