เมื่ออุปกรณ์ Zigbee ไม่สามารถใช้งานกับ Zigbee2MQTT

เมื่ออุปกรณ์ Zigbee ไม่สามารถใช้งานกับ Zigbee2MQTT

ช่วงหลังๆ พยายามเปลี่ยนอุปกรณ์ smart home ภายในบ้าน มาใช้งานแบบ zigbee เพื่อจะลดปัญหาการใช้อุปกรณ์ประเภท wifi จะได้ลดการพึ่งพา cloud ก็ยังไม่เคยเจออุปกรณ์ zigbee ที่ไม่สามารถใช้งานกับ zigbee2mqtt จนในที่สุด ก็มาเจออุปกรณ์ตัวนึง ใช้งานกับ zigbee2mqtt ไม่ได้

เมื่อทำการ pairing อุปกรณ์ zigbee เข้าสู่  zigbee2mqtt จะมีข้อความแจ้งประมาณ

Device '0x70b3d52b60008885' with Zigbee model 'TS011F' and manufacturer name '_TZ3000_r6buo8ba' is NOT supported, please follow https://www.zigbee2mqtt.io/advanced/support-new-devices/01_support_new_devices.html

เป็นการบอกให้รู้ว่าอุปกรณ์ที่เรากำลังใช้ยังไม่ support zigbee2mqtt ให้ทำการเพิ่มอุปกรณ์ด้วยวิธีสร้าง external converter (อ่านเพิ่มเติม)

แนวทางการแก้ไข

zigbee2mqtt เวอร์ชั่นปัจจุบัน 1.26.0-1 จะเก็บพวกไฟล์ config ไว้ที่ path /config/zigbee2mqtt ให้ทำการสร้างไฟล์ .js ตัวอย่างเช่น TS011F.js

เนื่องจากอุปกรณ์ zigbee ตัวนี้เป็นประเภท switch เราสามารถ copy ตัวอย่างของ converter ประเภท switch มาใช้งานได้เลย กรณีเราอยากได้ converter ประเภทอื่น หรือ vender เจ้าอื่นๆ (อ่านเพิ่มเติม)

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 definition = {
    zigbeeModel: ['TS011F'],
    model: 'TS011F',
    fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_r6buo8ba'}],
    vendor: 'TuYa',
    description: 'My super switch!',
    fromZigbee: [fz.on_off],
    toZigbee: [tz.on_off],
    exposes: [e.switch()],
    // The configure method below is needed to make the device reports on/off state changes
    // when the device is controlled manually through the button on it.
    configure: async (device, coordinatorEndpoint, logger) => {
        const endpoint = device.getEndpoint(1);
        await reporting.bind(endpoint, coordinatorEndpoint, ['genOnOff']);
        await reporting.onOff(endpoint);
    },
};

module.exports = definition;
  • zigbeeModel: ['TS011F'] ใส่เป็นชื่อ Zigbee model ตามที่เราได้มาจาก log ของ zigbee2mqtt
  • model: 'TS011F' ใช้เหมือนกับ zigbeeModel
  • fingerprint: [{modelID: 'TS011F', manufacturerName: '_TZ3000_r6buo8ba'}] modelID ใช้เหมือนกับ zigbeeModel ส่วน manufacturerName คือ Zigbee Manufacturer
  • vendor: 'TuYa' ใส่ชื่อ vendor

ทำการแก้ไขไฟล์ /config/zigbee2mqtt/configuration.yaml ของเดิมคือ

external_converters: []

ให้แก้ไข เพื่อจะเพิ่ม converter ของเราเข้าไป

external_converters:
  - TS011F.js

จากนั้นให้ทำการ restart zigbee2mqtt

หลังจากเราทำการ restart ตอนนี้ zigbee2mqtt จะรู้จักอุปกรณ์ของเราแล้ว