Last active
January 4, 2023 18:02
-
-
Save Koenkk/71d39494daca5b073515e6ae0e768d6b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fz = require('zigbee-herdsman-converters/converters/fromZigbee'); | |
const tz = require('zigbee-herdsman-converters/converters/toZigbee'); | |
const exposes = require('zigbee-herdsman-converters/lib/exposes'); | |
const reporting = require('zigbee-herdsman-converters/lib/reporting'); | |
const extend = require('zigbee-herdsman-converters/lib/extend'); | |
const ota = require('zigbee-herdsman-converters/lib/ota'); | |
const tuya = require('zigbee-herdsman-converters/lib/tuya'); | |
const utils = require('zigbee-herdsman-converters/lib/utils'); | |
const e = exposes.presets; | |
const ea = exposes.access; | |
const globalStore = require('zigbee-herdsman-converters/lib/store'); | |
const definition = { | |
fingerprint: [{modelID: 'TS0002', manufacturerName: '_TZ3000_irrmjcgi'}], | |
model: 'TS0002_power_TEMP', | |
vendor: 'TuYa', | |
description: '2 gang switch with power monitoring', | |
extend: tuya.extend.switch({switchType: true, endpoints: ['l1', 'l2'], electricalMeasurements: true}), | |
endpoint: (device) => { | |
return {'l1': 1, 'l2': 2}; | |
}, | |
// onEvent: tuya.onEventMeasurementPoll, | |
meta: {multiEndpoint: true, multiEndpointSkip: ['energy', 'current', 'voltage', 'power']}, | |
configure: async (device, coordinatorEndpoint, logger) => { | |
const endpoint = device.getEndpoint(1); | |
await endpoint.read('genBasic', ['manufacturerName', 'zclVersion', 'appVersion', 'modelId', 'powerSource', 0xfffe]); | |
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff', 'haElectricalMeasurement', 'seMetering']); | |
await reporting.rmsVoltage(endpoint, {change: 5}); | |
await reporting.rmsCurrent(endpoint, {change: 50}); | |
await reporting.activePower(endpoint, {change: 10}); | |
await reporting.currentSummDelivered(endpoint); | |
endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {acCurrentDivisor: 1000, acCurrentMultiplier: 1}); | |
endpoint.saveClusterAttributeKeyValue('seMetering', {divisor: 100, multiplier: 1}); | |
device.save(); | |
await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']); | |
}, | |
}; | |
module.exports = definition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment