Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- в файле zigbee-shepherd-converters/devices.js добавляем в список devices описание нашего устройства:
- {
- zigbeeModel: ['JAGER_KEYPAD20'],
- model: 'JAGER_KEYPAD20',
- vendor: 'Custom devices (DiY)',
- description: '',
- supports: '',
- fromZigbee: [fz.keypad20states],
- ep: (device) => {
- return {'btn_1': 1, 'btn_2': 2, 'btn_3': 3, 'btn_4': 4};
- },
- },
- в файле zigbee-shepherd-converters/converters/fromZigbee.js добавляем конвертеры:
- keypad20states: {
- cid: 'genOnOff',
- type: 'attReport',
- convert: (model, msg, publish, options) => {
- const ep = msg.endpoints[0];
- const button = getKey(model.ep(ep.device), ep.epId);
- const state = msg.data.data['onOff'] === 1 ? true : false;
- if (button) {
- return {[button]: state};
- }
- },
- },
- в iobroker.zigbee/lib/devstates.js надо добавить состояния и описание устройства:
- const states = {
- ...
- keypad_btn1: {
- id: 'btn_1',
- prop: 'btn_1',
- name: 'Button 1 click event',
- icon: undefined,
- role: 'state',
- write: false,
- read: true,
- type: 'boolean',
- },
- keypad_btn2: {
- id: 'btn_2',
- prop: 'btn_2',
- name: 'Button 2 click event',
- icon: undefined,
- role: 'state',
- write: false,
- read: true,
- type: 'boolean',
- },
- };
- const devices = [
- ...
- {
- vendor: 'Custom devices (DiY)',
- models: ['JAGER_KEYPAD20'],
- icon: 'img/diy.png',
- states: [states.keypad_btn1, states.keypad_btn2],
- },
- ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement