Skip to content

Instantly share code, notes, and snippets.

@Koenkk

Koenkk/ext.js Secret

Last active January 31, 2024 19:08
Show Gist options
  • Save Koenkk/20a6e2592ba7444d3d51a9d393defcea to your computer and use it in GitHub Desktop.
Save Koenkk/20a6e2592ba7444d3d51a9d393defcea 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 legacy = require('zigbee-herdsman-converters/lib/legacy');
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: ['lumi.magnet.agl02'],
model: 'MCCGQ12LM',
vendor: 'Xiaomi',
description: 'Aqara T1 door & window contact sensor',
fromZigbee: [fz.xiaomi_contact, fz.aqara_opple, fz.ias_contact_alarm_1, fz.battery],
toZigbee: [],
meta: {battery: {voltageToPercentage: '3V_2850_3000'}},
exposes: [e.contact(), e.battery(), e.battery_voltage()],
ota: ota.zigbeeOTA,
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genPowerCfg']);
await reporting.batteryPercentageRemaining(endpoint);
},
};
module.exports = definition;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment