HomeAssistant入门之设备管理控制 有介绍京鱼座四件套设备对 Zigbee2MQTT 的接入,主要是外挂了 jingxuan.js 文件。
这个套件虽然烂,但我改装了无线开关:废物利用之京鱼座ZigBee无线开关,用起来还可以,算是榨出了些价值。

可是,最近 Zigbee2MQTT 更新后无线开关就失效了,按钮没有响应,我重新连接 zigbee 也不好使,去掉了外挂 jingxuan.js 也不行。
一直没搞懂,几年了,为什么 Zigbee2MQTT 对这几件套支持的不好,还没人改?是我用的不对吗?看 https://github.com/Koenkk/zigbee-herdsman-converters/tree/master/src/devices 这里,最近还有更新,可是无线开关就是连接后不好使。

研究了一下 Zigbee2MQTT 对新设备的支持,发现有些不一样了:
https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html

前面注释的是之前文件的一些常量,更换成 Zigbee2MQTT 更新的,其他不变,再重启下就好了。

//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 e = exposes.presets;
//const ea = exposes.access;

const {} = require('zigbee-herdsman-converters/lib/modernExtend');
// Add the lines below
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 ota = require('zigbee-herdsman-converters/lib/ota');
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 fzLocal = {
WSZ01_on_off_action: {
cluster: '65029',
type: ['attributeReport'],
convert: (model, msg, publish, options, meta) => {
const clickMapping = {0: 'release', 1: 'single', 2: 'double', 3: 'hold'};
return {action: `${clickMapping[msg.data[1]]}`};
},
},

};

module.exports = [
// 人体传感器
// 人传配对方式:长按重置键,网关发现后,每隔一秒按一次重置键
{
zigbeeModel: ['wall pir'],
model: 'PRZ01',
vendor: 'J.XUAN',
description: 'Human body movement sensor',
fromZigbee: [fz.ias_occupancy_alarm_1_with_timeout, fz.battery],
toZigbee: [],
exposes: [e.occupancy(), e.battery_low(), e.battery()],
},
// 无线开关JD-SWITCH02
{
zigbeeModel: ['JD-SWITCH\u000002'],
model: 'WSZ01',
vendor: 'J.XUAN',
description: 'Wireless switch',
supports: "action, battery, linkquality",
fromZigbee: [fzLocal.WSZ01_on_off_action,fz.battery],
toZigbee: [],
exposes: [e.action(['release', 'single', 'double', 'hold']), e.battery()],
},
// 插座
{
zigbeeModel: ['00090bdc'],
model: 'SPZ01',
vendor: 'J.XUAN',
description: 'plug',
fromZigbee: [fz.on_off, fz.electrical_measurement, fz.metering],
exposes: [e.switch(), e.power(), e.power_outage_memory().withAccess(ea.STATE_SET), e.energy()],
toZigbee: [tz.on_off, tz.SPZ01_power_outage_memory],
configure: async (device, coordinatorEndpoint, logger) => {
const endpoint = device.getEndpoint(1);
await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff', 'haElectricalMeasurement']);
},
},
]