Advertisement
Guest User

lywsd03mmc-z.js

a guest
Feb 14th, 2024
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 5.02 KB | Source Code | 0 0
  1. // requires zigbee2mqtt v1.34+
  2. // external converter for ZigbeeTLc by pvvx
  3. // https://github.com/pvvx/ZigbeeTLc
  4. // based on external converter for devbis-Firmware
  5. // https://raw.githubusercontent.com/devbis/z03mmc/master/converters/lywsd03mmc.js
  6.  
  7. const {
  8.     batteryPercentage,
  9.     temperature,
  10.     humidity,
  11.     enumLookup,
  12.     binary,
  13.     numeric,
  14.     quirkAddEndpointCluster,
  15. } = require('zigbee-herdsman-converters/lib/modernExtend');
  16. const reporting = require('zigbee-herdsman-converters/lib/reporting');
  17. const ota = require('zigbee-herdsman-converters/lib/ota');
  18.  
  19. const dataType = {
  20.     boolean: 0x10,
  21.     uint8: 0x20,
  22.     uint16: 0x21,
  23.     int8: 0x28,
  24.     int16: 0x29,
  25.     enum8: 0x30,
  26. };
  27.  
  28. const definition = {
  29.     zigbeeModel: ['LYWSD03MMC-z'],
  30.     model: 'LYWSD03MMC',
  31.     vendor: 'Xiaomi',
  32.     description: 'Temperature & humidity sensor with custom firmware',
  33.     extend: [
  34.         quirkAddEndpointCluster({
  35.             endpointID: 1,
  36.             outputClusters: [],
  37.             inputClusters: [
  38.                 'genPowerCfg',
  39.                 'msTemperatureMeasurement',
  40.                 'msRelativeHumidity',
  41.                 'hvacUserInterfaceCfg',
  42.             ],
  43.         }),
  44.         batteryPercentage(),
  45.         temperature({reporting: {min: 10, max: 300, change: 10}}),
  46.         humidity({reporting: {min: 10, max: 300, change: 50}}),
  47.         enumLookup({
  48.             name: 'temperature_display_mode',
  49.             lookup: {'celsius': 0, 'fahrenheit': 1},
  50.             cluster: 'hvacUserInterfaceCfg',
  51.             attribute: {ID: 0x0000, type: dataType.enum8},
  52.             description: 'The units of the temperature displayed on the device screen.',
  53.         }),
  54.         binary({
  55.             name: 'show_smiley',
  56.             valueOn: ['SHOW', 0],
  57.             valueOff: ['HIDE', 1],
  58.             cluster: 'hvacUserInterfaceCfg',
  59.             attribute: {ID: 0x0002, type: dataType.enum8},
  60.             description: 'Whether to show a smiley on the device screen.',
  61.         }),
  62.         numeric({
  63.             name: 'temperature_calibration',
  64.             unit: 'ºC',
  65.             cluster: 'hvacUserInterfaceCfg',
  66.             attribute: {ID: 0x0100, type: dataType.int8},
  67.             valueMin: -12.7,
  68.             valueMax: 12.7,
  69.             valueStep: 0.1,
  70.             scale: 10,
  71.             description: 'The temperature calibration, in 0.1° steps.',
  72.         }),
  73.         numeric({
  74.             name: 'humidity_calibration',
  75.             unit: '%',
  76.             cluster: 'hvacUserInterfaceCfg',
  77.             attribute: {ID: 0x0101, type: dataType.int8},
  78.             valueMin: -12.7,
  79.             valueMax: 12.7,
  80.             valueStep: 0.1,
  81.             scale: 10,
  82.             description: 'The humidity offset is set in 0.1 % steps.',
  83.         }),
  84.         numeric({
  85.             name: 'comfort_temperature_min',
  86.             unit: 'ºC',
  87.             cluster: 'hvacUserInterfaceCfg',
  88.             attribute: {ID: 0x0102, type: dataType.int8},
  89.             valueMin: -127.0,
  90.             valueMax: 127.0,
  91.             description: 'Comfort parameters/Temperature minimum, in 0.1°C steps.',
  92.         }),
  93.         numeric({
  94.             name: 'comfort_temperature_max',
  95.             unit: 'ºC',
  96.             cluster: 'hvacUserInterfaceCfg',
  97.             attribute: {ID: 0x0103, type: dataType.int8},
  98.             valueMin: -127.0,
  99.             valueMax: 127.0,
  100.             description: 'Comfort parameters/Temperature maximum, in 0.1°C steps.',
  101.         }),
  102.         numeric({
  103.             name: 'comfort_humidity_min',
  104.             unit: '%',
  105.             cluster: 'hvacUserInterfaceCfg',
  106.             attribute: {ID: 0x0104, type: dataType.uint8},
  107.             valueMin: 0.0,
  108.             valueMax: 100.0,
  109.             description: 'Comfort parameters/Humidity minimum, in 1% steps.',
  110.         }),
  111.         numeric({
  112.             name: 'comfort_humidity_max',
  113.             unit: '%',
  114.             cluster: 'hvacUserInterfaceCfg',
  115.             attribute: {ID: 0x0105, type: dataType.uint8},
  116.             valueMin: 0.0,
  117.             valueMax: 100.0,
  118.             description: 'Comfort parameters/Humidity maximum, in 1% steps.',
  119.         }),
  120.     ],
  121.     ota: ota.zigbeeOTA,
  122.     configure: async (device, coordinatorEndpoint, logger) => {
  123.         const endpoint = device.getEndpoint(1);
  124.         const bindClusters = ['msTemperatureMeasurement', 'msRelativeHumidity', 'genPowerCfg'];
  125.         await reporting.bind(endpoint, coordinatorEndpoint, bindClusters);
  126.         await reporting.temperature(endpoint, {min: 10, max: 300, change: 10});
  127.         await reporting.humidity(endpoint, {min: 10, max: 300, change: 50});
  128.         await reporting.batteryPercentageRemaining(endpoint);
  129.         try {
  130.             await endpoint.read('hvacThermostat', [0x0010, 0x0011, 0x0102, 0x0103, 0x0104, 0x0105]);
  131.             await endpoint.read('msTemperatureMeasurement', [0x0010]);
  132.             await endpoint.read('msRelativeHumidity', [0x0010]);
  133.         } catch (e) {
  134.             /* backward compatibility */
  135.         }
  136.     },
  137. };
  138.  
  139. module.exports = definition;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement