Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. в файле zigbee-shepherd-converters/devices.js добавляем в список devices описание нашего устройства:
  2. {
  3. zigbeeModel: ['JAGER_KEYPAD20'],
  4. model: 'JAGER_KEYPAD20',
  5. vendor: 'Custom devices (DiY)',
  6. description: '',
  7. supports: '',
  8. fromZigbee: [fz.keypad20states],
  9. ep: (device) => {
  10. return {'btn_1': 1, 'btn_2': 2, 'btn_3': 3, 'btn_4': 4};
  11. },
  12. },
  13.  
  14.  
  15. в файле zigbee-shepherd-converters/converters/fromZigbee.js добавляем конвертеры:
  16. keypad20states: {
  17. cid: 'genOnOff',
  18. type: 'attReport',
  19. convert: (model, msg, publish, options) => {
  20. const ep = msg.endpoints[0];
  21. const button = getKey(model.ep(ep.device), ep.epId);
  22. const state = msg.data.data['onOff'] === 1 ? true : false;
  23. if (button) {
  24. return {[button]: state};
  25. }
  26. },
  27. },
  28.  
  29.  
  30. в iobroker.zigbee/lib/devstates.js надо добавить состояния и описание устройства:
  31.  
  32. const states = {
  33. ...
  34. keypad_btn1: {
  35. id: 'btn_1',
  36. prop: 'btn_1',
  37. name: 'Button 1 click event',
  38. icon: undefined,
  39. role: 'state',
  40. write: false,
  41. read: true,
  42. type: 'boolean',
  43. },
  44. keypad_btn2: {
  45. id: 'btn_2',
  46. prop: 'btn_2',
  47. name: 'Button 2 click event',
  48. icon: undefined,
  49. role: 'state',
  50. write: false,
  51. read: true,
  52. type: 'boolean',
  53. },
  54. };
  55.  
  56.  
  57.  
  58. const devices = [
  59. ...
  60. {
  61. vendor: 'Custom devices (DiY)',
  62. models: ['JAGER_KEYPAD20'],
  63. icon: 'img/diy.png',
  64. states: [states.keypad_btn1, states.keypad_btn2],
  65. },
  66. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement