diff --git a/Winner/ZigBee/Winner_ZigBee_dev.js b/Winner/ZigBee/Winner_ZigBee_dev.js index 3da06c0..4cd9b3b 100644 --- a/Winner/ZigBee/Winner_ZigBee_dev.js +++ b/Winner/ZigBee/Winner_ZigBee_dev.js @@ -6,14 +6,15 @@ const modernExtend = require('zigbee-herdsman-converters/lib/modernExtend'); const e = exposes.presets; const ea = exposes.access; const tuya = require('zigbee-herdsman-converters/lib/tuya'); +const exp = require('constants'); +const { Numeric } = require('zigbee-herdsman-converters/lib/exposes'); +const { Binary } = require('zigbee-herdsman-converters/lib/exposes'); -//DP value masks -const counterMask = 0b00000111_11111111_11111111_11111111; const tzDatapoints = { ...tuya.tz.datapoints, - key: ['switch', /*'percent_control',*/ 'fault', 'weather_delay', 'countdown', 'smart_weather', 'minihum_set', 'alarm', 'battery', 'cleaning', 'journal', - 'sensor_1', 'sensor_name_1', + key: ['switch', 'percent_control', 'fault', 'weather_delay', 'countdown', 'smart_weather', 'minihum_set', 'alarm', 'battery', 'cleaning', 'journal', 'channel_2', + 'sensor_1', 'sensor_1.signal', 'sensor_name_1', 'sensor_2', 'sensor_name_2', 'sensor_3', 'sensor_name_3', 'sensor_4', 'sensor_name_4', @@ -62,65 +63,167 @@ const definition = { onEvent: tuya.onEventSetTime, exposes: [ exposes.presets.enum('fault', ea.STATE, ['low_battery', 'fault', 'lack_water', 'sensor_fault', 'motor_fault', 'low_temp']).withCategory('diagnostic'), - exposes.presets.binary('switch', ea.STATE_SET, true, false ).withLabel('Valve status:'), + exposes.presets.binary('switch', ea.STATE_SET, true, false ).withLabel('Valve status').withDescription('Can not turn the alarm on. Use External vendor sensor for that.'), exposes.presets.binary('cleaning', ea.STATE_SET, true, false).withLabel('Cleaning Mode:'), exposes.presets.binary('alarm', ea.STATE_SET, true, false), - exposes.presets.enum('battery', ea.STATE, ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100', '101']), - + exposes.presets.enum('battery', ea.STATE, ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100', 'Plugged In']), - /* WIP - //exposes.presets.binary('channel_2', ea.SET, true, false), //send-only DP, doesn't get sent by the device and causes errors - exposes.presets.text('journal', ea.STATE), - exposes.presets.text('sensor_name_1', ea.ALL), - exposes.presets.numeric('sensor_1', ea.STATE), - exposes.presets.text('sensor_name_2', ea.ALL).withLabel('Sensor 2 Name:').withProperty('test'), - exposes.presets.numeric('sensor_2', ea.STATE_GET), - */ + exposes.presets.binary('channel_2', 0b010, true, false).withLabel("External vendor sensor").withDescription("A DP for an extra wired sensor. Triggers alarm on true."), + + //#region Sensors fields + exposes.presets.text('sensor_name_1', ea.STATE_SET), + exposes.presets.composite('sensor_1', 'sensor_1', ea.ALL).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_2', ea.ALL), + exposes.presets.composite('sensor_2', 'sensor_2', ea.ALL).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_3', ea.ALL), + exposes.presets.composite('sensor_3', 'sensor_3', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_4', ea.ALL), + exposes.presets.composite('sensor_4', 'sensor_4', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_5', ea.ALL), + exposes.presets.composite('sensor_5', 'sensor_5', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_6', ea.ALL), + exposes.presets.composite('sensor_6', 'sensor_6', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_7', ea.ALL), + exposes.presets.composite('sensor_7', 'sensor_7', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_8', ea.ALL), + exposes.presets.composite('sensor_8', 'sensor_8', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_9', ea.ALL), + exposes.presets.composite('sensor_9', 'sensor_9', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_10', ea.ALL), + exposes.presets.composite('sensor_10', 'sensor_10', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_11', ea.ALL), + exposes.presets.composite('sensor_11', 'sensor_11', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_12', ea.ALL), + exposes.presets.composite('sensor_12', 'sensor_12', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_13', ea.ALL), + exposes.presets.composite('sensor_13', 'sensor_13', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_14', ea.ALL), + exposes.presets.composite('sensor_14', 'sensor_14', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_15', ea.ALL), + exposes.presets.composite('sensor_15', 'sensor_15', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_16', ea.ALL), + exposes.presets.composite('sensor_16', 'sensor_16', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_17', ea.ALL), + exposes.presets.composite('sensor_17', 'sensor_17', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_18', ea.ALL), + exposes.presets.composite('sensor_18', 'sensor_18', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_19', ea.ALL), + exposes.presets.composite('sensor_19', 'sensor_19', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_20', ea.ALL), + exposes.presets.composite('sensor_20', 'sensor_20', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_21', ea.ALL), + exposes.presets.composite('sensor_21', 'sensor_21', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_22', ea.ALL), + exposes.presets.composite('sensor_22', 'sensor_22', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_23', ea.ALL), + exposes.presets.composite('sensor_23', 'sensor_23', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_24', ea.ALL), + exposes.presets.composite('sensor_24', 'sensor_24', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_25', ea.ALL), + exposes.presets.composite('sensor_25', 'sensor_25', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_26', ea.ALL), + exposes.presets.composite('sensor_26', 'sensor_26', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_27', ea.ALL), + exposes.presets.composite('sensor_27', 'sensor_27', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_28', ea.ALL), + exposes.presets.composite('sensor_28', 'sensor_28', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_29', ea.ALL), + exposes.presets.composite('sensor_29', 'sensor_29', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_30', ea.ALL), + exposes.presets.composite('sensor_30', 'sensor_30', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_31', ea.ALL), + exposes.presets.composite('sensor_31', 'sensor_31', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + + exposes.presets.text('sensor_name_32', ea.ALL), + exposes.presets.composite('sensor_32', 'sensor_32', ea.ALL).withFeature(new Numeric('signal', ea.STATE_GET)).withFeature(new Numeric('battery', ea.STATE_GET)).withFeature(new Binary('isOnline', ea.GET, true, false)).withFeature(new Binary('leakDetected', ea.GET, true, false)).withFeature(new Binary('securityMode', ea.SET, true, false)).withFeature(new Binary('statusBatterySignal', ea.GET, true, false)).withFeature(new Binary('ignoreLeaks', ea.STATE_SET, true, false)), + //#endregion ], meta: { tuyaDatapoints: [ [1, 'switch', tuya.valueConverter.raw], //[2, 'percent_control', tuya.valueConverter.raw], //don't even know what this is [4, 'fault', tuya.valueConverter.raw], + [10, 'weather_delay', tuya.valueConverter.raw], + [11, 'countdown', tuya.valueConverter.raw], + [13, 'smart_weather', tuya.valueConverter.raw], + [21, 'minihum_set', tuya.valueConverter.raw], [101, 'alarm', tuya.valueConverter.raw], - [102, 'battery', tuya.valueConverterBasic.lookup({'10': tuya.enum(0), '20': tuya.enum(1), '30': tuya.enum(2), '40': tuya.enum(3), '50': tuya.enum(4), '60': tuya.enum(5), '70': tuya.enum(6), '80': tuya.enum(7), '90': tuya.enum(8), '100': tuya.enum(9), '101': tuya.enum(10)})], + [102, + 'battery', + tuya.valueConverterBasic.lookup({ + 10: tuya.enum(0), + 20: tuya.enum(1), + 30: tuya.enum(2), + 40: tuya.enum(3), + 50: tuya.enum(4), + 60: tuya.enum(5), + 70: tuya.enum(6), + 80: tuya.enum(7), + 90: tuya.enum(8), + 100: tuya.enum(9), + 'Plugged in': tuya.enum(10)})], + + + /* + * Device_CMD: Used by Smart Life app for Winner + * to issue commands. + * TODO: list all hexcodes for commands + * + */ + //[103, 'device_cmd', tuya.valueConverter.raw], + [104, 'cleaning', tuya.valueConverter.raw], - //#region WIP - - //[103, 'device_cmd', tuya.valueConverter.raw], // a Number DP used to issue commands to the device - //[105, 'journal', tuya.valueConverterBasic.lookup({'single': 0, 'double': 1, 'hold': 2})] // Temporarily publishes string 'sensor name;x' where "x" is any of following characters: A - leak detected; B - Winner's battery charge is low; L - low sensor charge; T - sensor signal lost; - //[106, 'channel_2', tuya.valueConverter.raw], //send-only boolean DP used for external sensors; doesn't get sent by the device and throws an error in z2mqtt - - //#region Water Counters - /* - Tick Settings: 1 tick per 1 liter | 1 tick per 10 liters; - * - * - Number DPs contain both counter ticks to display the water volume and a bit flag for Smart Life App; - * Use counterMask to get the water volume (multiply by ticks): - let counterWaterValue1 = (counter1 & counterMask) * counterMultiplier1 //or something like that + /* Journal DP: the device will post a string in this DP in format "x; sensor name" where x is a special character: + * A - regular leak event + * L - sensor battery charge low + * T - sensor signal lost + * B - device(!) battery charge low + * + * These values are displayed VERY BRIEFLY + * to utilize Tuya's DP log in the Smart Life app for Winner. + * Unless you have a log of your own to track the values, + * this field is practically useless. */ - - //[10, 'weather_delay', tuya.valueConverterBasic.lookup({'1': tuya.enum(0), '10': tuya.enum(1)})], // counter 1 setting - //[11, 'countdown', tuya.valueConverter.raw], // counter 1 Number DP - //[13, 'smart_weather', tuya.valueConverterBasic.lookup({'1': tuya.enum(0), '10': tuya.enum(1)})], // counter 2 setting - //[21, 'minihum_set', tuya.valueConverter.raw], // counter 2 Number DP - //#endregion - - //#region Sensors - /* Each sensor DP has the following structure: - * - * 0xAA_BB_CC_DD where: - * [AA] - command bit flags - * [BB] - status bit flags - * [CC] - signal strength - * [DD] - battery charge - */ - - /* - [107, 'sensor_1', tuya.valueConverter.raw], - [108, 'sensor_name_1', tuya.valueConverter.raw], + //[105, 'journal', tuya.valueConverterBasic.lookup({'single': 0, 'double': 1, 'hold': 2})] - [109, 'sensor_2', tuya.valueConverter.raw], + [106, 'channel_2', tuya.valueConverter.raw], + + //#region Sensors DPs + [107, 'sensor_1', tuya.valueConverter.gidrolockWinnerSensor], + [108, 'sensor_name_1', tuya.valueConverterBasic.lookup({'single': 0, 'double': 1, 'hold': 2})], + + [109, 'sensor_2', tuya.valueConverter.gidrolockWinnerSensor], [110, 'sensor_name_2', tuya.valueConverterBasic.lookup({'single': 0, 'double': 1, 'hold': 2})], [111, 'sensor_3', tuya.valueConverter.raw], @@ -212,15 +315,32 @@ const definition = { [169, 'sensor_32', tuya.valueConverter.raw], [170, 'sensor_name_32', tuya.valueConverterBasic.lookup({'single': 0, 'double': 1, 'hold': 2})], - */ - //#endregion WIP - //#endregion + //#endregion ], }, extend: [ - tuya.modernExtend.tuyaMagicPacket(), + tuya.modernExtend.tuyaMagicPacket(), ], }; module.exports = definition; +//DP value masks +const counterMask = 0b00000111_11111111_11111111_11111111; +const sensorMasks = { + sensorSignal: 0x00_00_00_FF, + sensorBattery: 0x00_00_FF_00, + + //booleans + online: 0b00000000_00000010_00000000_00000000, // Is Online + leak: 0b00000000_00000100_00000000_00000000, // Leak detected + ignore: 0b00000000_00001000_00000000_00000000, // Ignore leaks + securityMode: 0b00000000_00010000_00000000_00000000, // Toggle high security mode: treat low senor battery or signal loss as an alarm condition + statusBatterySignal: 0b00000000_00100000_00000000_00000000, // Indicates low charge or signal loss if high security mode is enabled +} + +const converterExtension = { + ...tuya.valueConverter, + + +}