Skip to content

Instantly share code, notes, and snippets.

@ccfiel
Last active July 31, 2025 16:18
Show Gist options
  • Select an option

  • Save ccfiel/532d0000c2ec584a5e4ff3728c2ebe3c to your computer and use it in GitHub Desktop.

Select an option

Save ccfiel/532d0000c2ec584a5e4ff3728c2ebe3c to your computer and use it in GitHub Desktop.

Revisions

  1. ccfiel revised this gist Jul 31, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion tuya_water_meter_converter.mjs
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,7 @@ export default {
    [13, "state", tuya.valueConverter.onOffNotStrict],
    [14, "auto_clean", tuya.valueConverter.raw],
    [21, "flow_rate", tuya.valueConverter.divideBy1000],
    [22, "temperature", tuya.valueConverter.divideBy10],
    [22, "temperature", tuya.valueConverter.divideBy100],
    [26, "voltage", tuya.valueConverter.divideBy100],
    ],
    },
  2. ccfiel renamed this gist Jul 29, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. ccfiel created this gist Jul 29, 2025.
    60 changes: 60 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    import * as exposes from "zigbee-herdsman-converters/lib/exposes";
    import * as tuya from "zigbee-herdsman-converters/lib/tuya";

    const e = exposes.presets;
    const ea = exposes.access;

    /** @type {import('zigbee-herdsman-converters').Definition} */
    export default {
    fingerprint: [
    {
    modelID: "TS0601",
    manufacturerName: "_TZE284_vuwtqx0t",
    },
    ],
    model: "TS0601_water_valve",
    vendor: "Tuya",
    description: "Ultrasonic water meter valve",
    fromZigbee: [tuya.fz.datapoints],
    toZigbee: [tuya.tz.datapoints],
    onEvent: tuya.onEventSetTime,
    configure: tuya.configureMagicPacket,
    exposes: [
    // Main valve switch
    e.switch().setAccess("state", ea.STATE_SET),

    // Water consumption sensor
    e.numeric("water_consumed", ea.STATE).withUnit("m³").withDescription("Total water consumption").withValueMin(0).withValueStep(0.001),

    // Flow rate sensor
    e.numeric("flow_rate", ea.STATE).withUnit("m³/h").withDescription("Instantaneous water flow rate").withValueMin(0).withValueStep(0.001),

    // Temperature sensor
    e.temperature(),

    // Voltage monitoring
    e.voltage(),
    // Auto clean mode toggle
    e.binary("auto_clean", ea.STATE_SET, true, false).withDescription("Auto clean mode"),
    ],
    meta: {
    tuyaDatapoints: [
    [1, "water_consumed", tuya.valueConverter.divideBy1000],
    [13, "state", tuya.valueConverter.onOffNotStrict],
    [14, "auto_clean", tuya.valueConverter.raw],
    [21, "flow_rate", tuya.valueConverter.divideBy1000],
    [22, "temperature", tuya.valueConverter.divideBy10],
    [26, "voltage", tuya.valueConverter.divideBy100],
    ],
    },
    // Optional: Add device-specific options
    options: [
    exposes.options.precision("water_consumed"),
    exposes.options.calibration("water_consumed"),
    exposes.options.precision("flow_rate"),
    exposes.options.calibration("flow_rate"),
    exposes.options.precision("temperature"),
    exposes.options.calibration("temperature"),
    ],
    };