Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const herdsman = require('zigbee-herdsman');
- const exposes = require('zigbee-herdsman-converters/lib/exposes');
- const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
- const tz = require('zigbee-herdsman-converters/converters/toZigbee');
- const constants = require('zigbee-herdsman-converters/lib/constants');
- const reporting = require('zigbee-herdsman-converters/lib/reporting');
- const globalStore = require('zigbee-herdsman-converters/lib/store');
- const ota = require('zigbee-herdsman-converters/lib/ota');
- const utils = require('zigbee-herdsman-converters/lib/utils');
- const extend = require('zigbee-herdsman-converters/lib/extend');
- const ea = exposes.access;
- const e = exposes.presets;
- // 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 ota = require('zigbee-herdsman-converters/lib/ota');
- // const e = exposes.presets;
- // const ea = exposes.access;
- const sunricherManufacturer = {manufacturerCode: herdsman.Zcl.ManufacturerCode.SHENZHEN_SUNRICH};
- const definition = {
- zigbeeModel: ['4512737', '4512738'],
- model: '4512737/4512738',
- vendor: 'Namron',
- description: 'Touch termostat usr',
- fromZigbee: [fz.thermostat, fz.namron_thermostat, fz.metering, fz.electrical_measurement,
- fz.namron_hvac_user_interface],
- toZigbee: [tz.thermostat_occupied_heating_setpoint, tz.thermostat_unoccupied_heating_setpoint, tz.thermostat_occupancy,
- tz.thermostat_local_temperature_calibration, tz.thermostat_local_temperature, tz.thermostat_outdoor_temperature,
- tz.thermostat_system_mode, tz.thermostat_control_sequence_of_operation, tz.thermostat_running_state,
- tz.namron_thermostat_child_lock, tz.namron_thermostat],
- exposes: [
- e.local_temperature(),
- exposes.numeric('outdoor_temperature', ea.STATE_GET).withUnit('°C')
- .withDescription('Current temperature measured from the floor sensor'),
- exposes.climate()
- .withSetpoint('occupied_heating_setpoint', 0, 40, 0.5)
- .withLocalTemperature()
- .withLocalTemperatureCalibration(-3, 3, 0.1)
- .withSystemMode(['off', 'auto', 'dry', 'heat'])
- .withRunningState(['idle', 'heat']),
- exposes.binary('away_mode', ea.ALL, 'ON', 'OFF')
- .withDescription('Enable/disable away mode'),
- exposes.binary('child_lock', ea.ALL, 'LOCK', 'UNLOCK')
- .withDescription('Enables/disables physical input on the device'),
- e.power(), e.current(), e.voltage(), e.energy(),
- exposes.enum('lcd_brightness', ea.ALL, ['low', 'mid', 'high'])
- .withDescription('OLED brightness when operating the buttons. Default: Medium.'),
- exposes.enum('button_vibration_level', ea.ALL, ['off', 'low', 'high'])
- .withDescription('Key beep volume and vibration level. Default: Low.'),
- exposes.enum('floor_sensor_type', ea.ALL, ['10k', '15k', '50k', '100k', '12k'])
- .withDescription('Type of the external floor sensor. Default: NTC 10K/25.'),
- exposes.enum('sensor', ea.ALL, ['air', 'floor', 'both'])
- .withDescription('The sensor used for heat control. Default: Room Sensor.'),
- exposes.enum('powerup_status', ea.ALL, ['default', 'last_status'])
- .withDescription('The mode after a power reset. Default: Previous Mode.'),
- exposes.numeric('floor_sensor_calibration', ea.ALL)
- .withUnit('°C')
- .withValueMin(-3).withValueMax(3).withValueStep(0.1)
- .withDescription('The tempearatue calibration for the exernal floor sensor, between -3 and 3 in 0.1°C. Default: 0.'),
- exposes.numeric('dry_time', ea.ALL)
- .withUnit('min')
- .withValueMin(5).withValueMax(100)
- .withDescription('The duration of Dry Mode, between 5 and 100 minutes. Default: 5.'),
- exposes.enum('mode_after_dry', ea.ALL, ['off', 'manual', 'auto', 'away'])
- .withDescription('The mode after Dry Mode. Default: Auto.'),
- exposes.enum('temperature_display', ea.ALL, ['room', 'floor'])
- .withDescription('The temperature on the display. Default: Room Temperature.'),
- exposes.numeric('window_open_check', ea.ALL)
- .withUnit('°C')
- .withValueMin(0).withValueMax(4).withValueStep(0.5)
- .withDescription('The threshold to detect window open, between 1.5 and 4 in 0.5 °C. Default: 0 (disabled).'),
- exposes.numeric('hysterersis', ea.ALL)
- .withUnit('°C')
- .withValueMin(0.5).withValueMax(2).withValueStep(0.1)
- .withDescription('Hysteresis setting, between 0.5 and 2 in 0.1 °C. Default: 0.5.'),
- exposes.enum('display_auto_off_enabled', ea.ALL, ['enabled', 'disabled']),
- exposes.numeric('alarm_airtemp_overvalue', ea.ALL)
- .withUnit('°C')
- .withValueMin(20).withValueMax(60)
- .withDescription('Room temperature alarm threshold, between 20 and 60 in °C. 0 means disabled. Default: 45.'),
- ],
- onEvent: async (type, data, device, options) => {
- const endpoint = device.getEndpoint(1);
- if (type === 'stop') {
- clearInterval(globalStore.getValue(device, 'time'));
- globalStore.clearValue(device, 'time');
- } else if (!globalStore.hasValue(device, 'time')) {
- const hours24 = 1000 * 60 * 60 * 24;
- const interval = setInterval(async () => {
- try {
- // Device does not asks for the time with binding, therefore we write the time every 24 hours
- const time = Math.round(((new Date()).getTime() - constants.OneJanuary2000) / 1000 + ((new Date())
- .getTimezoneOffset() * -1) * 60);
- const values = {time: time};
- endpoint.write('genTime', values);
- } catch (error) {/* Do nothing*/}
- }, hours24);
- globalStore.putValue(device, 'time', interval);
- }
- },
- configure: async (device, coordinatorEndpoint, logger) => {
- const endpoint = device.getEndpoint(1);
- const binds = [
- 'genBasic', 'genIdentify', 'hvacThermostat', 'seMetering', 'haElectricalMeasurement', 'genAlarms',
- 'msOccupancySensing', 'genTime', 'hvacUserInterfaceCfg',
- ];
- await reporting.bind(endpoint, coordinatorEndpoint, binds);
- // standard ZCL attributes
- await reporting.thermostatTemperature(endpoint);
- await reporting.thermostatOccupiedHeatingSetpoint(endpoint);
- await reporting.thermostatUnoccupiedHeatingSetpoint(endpoint);
- await reporting.thermostatKeypadLockMode(endpoint);
- // await endpoint.configureReporting('hvacThermostat', [{
- // attribute: 'occupancy',
- // minimumReportInterval: 0,
- // maximumReportInterval: constants.repInterval.HOUR,
- // reportableChange: null,
- // }]);
- await endpoint.read('haElectricalMeasurement', ['acVoltageMultiplier', 'acVoltageDivisor', 'acCurrentMultiplier']);
- await endpoint.read('haElectricalMeasurement', ['acCurrentDivisor']);
- await reporting.activePower(endpoint);
- await reporting.rmsCurrent(endpoint, {min: 10, change: 10});
- await reporting.rmsVoltage(endpoint, {min: 10});
- await reporting.readMeteringMultiplierDivisor(endpoint);
- await reporting.currentSummDelivered(endpoint);
- // Custom attributes
- const options = {manufacturerCode: 0x1224};
- // OperateDisplayLcdBrightnesss
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1000, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // ButtonVibrationLevel
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1001, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // FloorSensorType
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1002, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // ControlType
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1003, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // PowerUpStatus
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1004, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // FloorSensorCalibration
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1005, type: 0x28},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: 0}],
- options);
- // DryTime
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1006, type: 0x20},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: 0}],
- options);
- // ModeAfterDry
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1007, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // TemperatureDisplay
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1008, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // WindowOpenCheck
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x1009, type: 0x20},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: 0}],
- options);
- // Hysterersis
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x100A, type: 0x20},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: 0}],
- options);
- // DisplayAutoOffEnable
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x100B, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // AlarmAirTempOverValue
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x2001, type: 0x20},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: 0}],
- options);
- // Away Mode Set
- await endpoint.configureReporting('hvacThermostat', [{
- attribute: {ID: 0x2002, type: 0x30},
- minimumReportInterval: 0,
- maximumReportInterval: constants.repInterval.HOUR,
- reportableChange: null}],
- options);
- // Trigger initial read
- await endpoint.read('hvacThermostat', ['systemMode', 'runningState', 'occupiedHeatingSetpoint']);
- await endpoint.read('hvacThermostat', [0x1000, 0x1001, 0x1002, 0x1003], options);
- await endpoint.read('hvacThermostat', [0x1004, 0x1005, 0x1006, 0x1007], options);
- await endpoint.read('hvacThermostat', [0x1008, 0x1009, 0x100A, 0x100B], options);
- await endpoint.read('hvacThermostat', [0x2001, 0x2002], options);
- },
- ota: ota.zigbeeOTA
- };
- module.exports = definition;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement