zigbee-herdsman-converters
Version:
Collection of device converters to be used with zigbee-herdsman
155 lines (153 loc) • 7.73 kB
JavaScript
const exposes = require('../lib/exposes');
const fz = {...require('../converters/fromZigbee'), legacy: require('../lib/legacy').fromZigbee};
const tz = require('../converters/toZigbee');
const tuya = require('../lib/tuya');
const reporting = require('../lib/reporting');
const extend = require('../lib/extend');
const e = exposes.presets;
const ea = exposes.access;
module.exports = [
{
fingerprint: [{modelID: 'TS0121', manufacturerName: '_TYZB01_iuepbmpv'}, {modelID: 'TS011F', manufacturerName: '_TZ3000_zmy1waw6'},
{modelID: 'TS011F', manufacturerName: '_TZ3000_bkfe0bab'}],
model: 'MS-104Z',
description: 'Smart light switch module (1 gang)',
vendor: 'Moes',
extend: extend.switch(),
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
try {
// Fails for some devices.
// https://github.com/Koenkk/zigbee2mqtt/issues/4598
await reporting.onOff(endpoint);
} catch (e) {
e;
}
},
},
{
fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_pmz6mjyu'}],
model: 'MS-104BZ',
description: 'Smart light switch module (2 gang)',
vendor: 'Moes',
toZigbee: extend.switch().toZigbee.concat([tz.moes_power_on_behavior]),
fromZigbee: extend.switch().fromZigbee.concat([fz.moes_power_on_behavior]),
extend: extend.switch(),
meta: {multiEndpoint: true},
exposes: [e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2'),
exposes.enum('power_on_behavior', ea.ALL, ['on', 'off', 'previous'])
.withDescription('Controls the behaviour when the device is powered on')],
endpoint: (device) => {
return {l1: 1, l2: 2};
},
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint1 = device.getEndpoint(1);
await reporting.bind(endpoint1, coordinatorEndpoint, ['genOnOff']);
await reporting.onOff(endpoint1);
const endpoint2 = device.getEndpoint(2);
await reporting.bind(endpoint2, coordinatorEndpoint, ['genOnOff']);
await reporting.onOff(endpoint2);
},
},
{
zigbeeModel: ['TS0112'],
model: 'ZK-EU-2U',
vendor: 'Moes',
description: 'Zigbee 3.0 dual USB wireless socket plug',
extend: extend.switch(),
exposes: [e.switch().withEndpoint('l1'), e.switch().withEndpoint('l2')],
meta: {multiEndpoint: true},
endpoint: (device) => {
const hasEndpoint2 = !!device.getEndpoint(2);
return {l1: 1, l2: hasEndpoint2 ? 2 : 7};
},
configure: async (device, coordinatorEndpoint, logger) => {
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']);
},
},
{
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_aoclfnxz'},
{modelID: 'TS0601', manufacturerName: '_TZE200_ztvwu4nk'}],
model: 'BHT-002-GCLZB',
vendor: 'Moes',
description: 'Moes BHT series Thermostat',
fromZigbee: [fz.moes_thermostat],
toZigbee: [tz.moes_thermostat_child_lock, tz.moes_thermostat_current_heating_setpoint, tz.moes_thermostat_mode,
tz.moes_thermostat_standby, tz.moes_thermostat_sensor, tz.moes_thermostat_calibration,
tz.moes_thermostat_deadzone_temperature, tz.moes_thermostat_max_temperature_limit],
exposes: [e.child_lock(), e.deadzone_temperature(), e.max_temperature_limit(),
exposes.climate().withSetpoint('current_heating_setpoint', 5, 30, 1, ea.STATE_SET)
.withLocalTemperature(ea.STATE).withLocalTemperatureCalibration(ea.STATE_SET)
.withSystemMode(['off', 'heat'], ea.STATE_SET).withRunningState(['idle', 'heat', 'cool'], ea.STATE)
.withPreset(['hold', 'program']).withSensor(['IN', 'AL', 'OU'], ea.STATE_SET)],
onEvent: tuya.onEventSetLocalTime,
},
{
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_amp6tsvy'}],
model: 'ZTS-EU_1gang',
vendor: 'Moes',
description: 'Wall touch light switch (1 gang)',
exposes: [e.switch().setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.tuya_switch],
toZigbee: [tz.tuya_switch_state],
configure: async (device, coordinatorEndpoint, logger) => {
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
},
},
{
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_g1ib5ldv'}],
model: 'ZTS-EU_2gang',
vendor: 'Moes',
description: 'Wall touch light switch (2 gang)',
exposes: [e.switch().withEndpoint('l1').setAccess('state', ea.STATE_SET),
e.switch().withEndpoint('l2').setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch],
toZigbee: [tz.tuya_switch_state],
meta: {multiEndpoint: true},
endpoint: (device) => {
// Endpoint selection is made in tuya_switch_state
return {'l1': 1, 'l2': 1};
},
configure: async (device, coordinatorEndpoint, logger) => {
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
if (device.getEndpoint(2)) await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']);
// Reports itself as battery which is not correct: https://github.com/Koenkk/zigbee2mqtt/issues/6190
device.powerSource = 'Mains (single phase)';
device.save();
},
},
{
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_tz32mtza'}],
model: 'ZTS-EU_3gang',
vendor: 'Moes',
description: 'Wall touch light switch (3 gang)',
exposes: [e.switch().withEndpoint('l1').setAccess('state', ea.STATE_SET),
e.switch().withEndpoint('l2').setAccess('state', ea.STATE_SET), e.switch().withEndpoint('l3').setAccess('state', ea.STATE_SET)],
fromZigbee: [fz.ignore_basic_report, fz.tuya_switch],
toZigbee: [tz.tuya_switch_state],
meta: {multiEndpoint: true},
endpoint: (device) => {
// Endpoint selection is made in tuya_switch_state
return {'l1': 1, 'l2': 1, 'l3': 1};
},
configure: async (device, coordinatorEndpoint, logger) => {
await reporting.bind(device.getEndpoint(1), coordinatorEndpoint, ['genOnOff']);
if (device.getEndpoint(2)) await reporting.bind(device.getEndpoint(2), coordinatorEndpoint, ['genOnOff']);
if (device.getEndpoint(3)) await reporting.bind(device.getEndpoint(3), coordinatorEndpoint, ['genOnOff']);
// Reports itself as battery which is not correct: https://github.com/Koenkk/zigbee2mqtt/issues/6190
device.powerSource = 'Mains (single phase)';
device.save();
},
},
{
fingerprint: [{modelID: 'TS0222', manufacturerName: '_TYZB01_kvwjujy9'}],
model: 'ZSS-ZK-THL',
vendor: 'Moes',
description: 'Smart temperature and humidity meter with display',
fromZigbee: [fz.battery, fz.illuminance, fz.humidity, fz.temperature],
toZigbee: [],
exposes: [e.battery(), e.illuminance(), e.illuminance_lux().withUnit('lx'), e.humidity(), e.temperature()],
},
];