Skip to content

Instantly share code, notes, and snippets.

@Koenkk
Last active December 17, 2022 09:35
Show Gist options
  • Save Koenkk/b0d110314059fc4defc74620650580c5 to your computer and use it in GitHub Desktop.
Save Koenkk/b0d110314059fc4defc74620650580c5 to your computer and use it in GitHub Desktop.
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 globalStore = require('zigbee-herdsman-converters/lib/store');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
zigbeeModel: ['4257050-RZHAC'],
model: '4257050-RZHAC',
vendor: 'Centralite',
description: '3-Series smart outlet',
fromZigbee: [fz.on_off, fz.electrical_measurement],
toZigbee: [tz.on_off],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff', 'haElectricalMeasurement']);
await reporting.onOff(endpoint);
try {
await reporting.readEletricalMeasurementMultiplierDivisors(endpoint);
console.log('\n\nUSED FROM DEVICE\n\n');
} catch (exception) {
// For some this fails so set manually
// https://github.com/Koenkk/zigbee2mqtt/issues/3575
endpoint.saveClusterAttributeKeyValue('haElectricalMeasurement', {
acCurrentDivisor: 10, acCurrentMultiplier: 1, powerMultiplier: 1, powerDivisor: 100});
console.log('\n\nUSED MANUAL\n\n');
}
await reporting.rmsVoltage(endpoint, {change: 2}); // Voltage reports in V
await reporting.rmsCurrent(endpoint, {change: 10}); // Current reports in mA
await reporting.activePower(endpoint, {change: 2}); // Power reports in 0.1W
},
exposes: [e.switch(), e.power(), e.current(), e.voltage()],
};
module.exports = definition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment