zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[TS130F (TS130F_GIRIER) / _TZ3210_dwytrmda] Issue setting "Calibration Time" on Girier Curtain Module (Possible scaling/validation error)

Open Plohrja opened this issue 5 months ago • 4 comments

What happened?

I am unable to set the 'Calibration Time' attribute for the Girier curtain module. When I attempt to input a value, the system behaves incorrectly in two ways:

If I enter a value like '30', the system reports an error stating that the range is 0–255, but claims that I entered '300' (it appears to multiply my input by 10).

If I enter '25', the system returns an 'invalid format' error.

These issues persist regardless of the configuration method used: I have attempted setting the value via the UI, directly via MQTT, and via the Developer Console using the closuresWindowCovering cluster and moesCalibrationTime (ENUM8) attribute. Despite re-pairing the device, power-cycling it, and performing the manual calibration procedure (as per the documentation), the calibration time cannot be configured.

Image Image Image

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

No response

Zigbee2MQTT version

2.12.1 (unknown)

Adapter firmware version

{"maintrel":1,"majorrel":2,"minorrel":7,"product":1,"revision":20221226,"transportrev":2}

Adapter

ZStack3x0

Setup

os: #1 SMP PREEMPT_DYNAMIC Mon Jan 19 12:07:25 UTC 2026 - 6.12.63-haos - x64 node: v22.23.0 ha: true

Device database.db entry

No response

Debug log

No response

Notes

Device

definition: TS130F_GIRIER - Girier (v0.0.0) software_build_id: undefined date_code: `` endpoints:

{"1":{"bindings":[],"clusters":{"input":["genGroups","genScenes","closuresWindowCovering","genBasic"],"output":["genOta","genTime"]},"configured_reportings":[],"scenes":[]},"242":{"bindings":[],"clusters":{"input":[],"output":["greenPower"]},"configured_reportings":[],"scenes":[]}}

Plohrja avatar Jul 05 '26 10:07 Plohrja

Had a look — I think this is already sorted upstream, it just hasn't reached your build yet.

The value scaling isn't actually the bug. This module stores calibration time in tenths of a second, so 30s is meant to be written as 300 — the converter's value * 10 is correct (the code reads it back with a matching /10, and someone reported elsewhere that 320 = 32s; the sibling Moes MS-108ZR uses the same x10 with a 0–500s range).

The real problem was the attribute type. In src/lib/tuya.ts, the shared cluster helper addTuyaClosuresWindowCoveringCluster() declared moesCalibrationTime (0xf003) as ENUM8, which is 8-bit and tops out at 255. So anything from 25.5s up overflowed: 30 -> 300 gave you the "range is 0–255, you entered 300" error, and smaller odd values like 25 fell foul of the type check and came back as "invalid format". Your Girier _TZ3210_dwytrmda rides on the generic TS130F definition and that shared cluster, so it inherited the wrong type — there's nothing device-specific to add.

It got fixed in zigbee-herdsman-converters PR #12619 (merged 5 Jul), one line:

// src/lib/tuya.ts, addTuyaClosuresWindowCoveringCluster()
- moesCalibrationTime: {name: "moesCalibrationTime", ID: 0xf003, type: Zcl.DataType.ENUM8,  write: true, max: 0xffff},
+ moesCalibrationTime: {name: "moesCalibrationTime", ID: 0xf003, type: Zcl.DataType.UINT16, write: true, max: 0xffff},

Because it's a shared definition, every TS130F variant (yours included) is covered with no per-device converter. It shipped in converters v26.78.0. You're on z2m 2.12.1, which bundles converters 26.76.0 — two releases before the fix — so you don't have it yet. As far as I can see 2.12.1 is still the latest z2m, so there isn't a newer release to jump to right now; the next z2m that bumps its converters past 26.78.0 should just work.

If you want it working today without waiting, you can drop an external converter in that re-declares that cluster attribute as UINT16 and restart. It's the same body as the built-in cluster, with only moesCalibrationTime changed from ENUM8 to UINT16:

import {Zcl} from "zigbee-herdsman";
import * as m from "zigbee-herdsman-converters/lib/modernExtend";
import * as tuya from "zigbee-herdsman-converters/lib/tuya";
import * as fz from "zigbee-herdsman-converters/converters/fromZigbee";
import * as tz from "zigbee-herdsman-converters/converters/toZigbee";
import * as e from "zigbee-herdsman-converters/lib/exposes";

export default {
    fingerprint: [{modelID: "TS130F", manufacturerName: "_TZ3210_dwytrmda"}],
    model: "TS130F_GIRIER",
    vendor: "Girier",
    description: "Smart curtain switch (moesCalibrationTime UINT16 override)",
    fromZigbee: [fz.cover_position_tilt, tuya.fz.cover_options],
    toZigbee: [tz.cover_state, tz.cover_position_tilt, tuya.tz.cover_calibration, tuya.tz.cover_reversal],
    meta: {coverInverted: true},
    extend: [
        tuya.modernExtend.tuyaBase(),
        m.deviceAddCustomCluster("closuresWindowCovering", {
            name: "closuresWindowCovering",
            ID: Zcl.Clusters.closuresWindowCovering.ID,
            attributes: {
                tuyaMovingState:   {name: "tuyaMovingState",   ID: 0xf000, type: Zcl.DataType.ENUM8,  write: true, max: 0xff},
                tuyaCalibration:   {name: "tuyaCalibration",   ID: 0xf001, type: Zcl.DataType.ENUM8,  write: true, max: 0xff},
                tuyaMotorReversal: {name: "tuyaMotorReversal", ID: 0xf002, type: Zcl.DataType.ENUM8,  write: true, max: 0xff},
                moesCalibrationTime:{name: "moesCalibrationTime",ID: 0xf003, type: Zcl.DataType.UINT16, write: true, max: 0xffff},
                tuyaSwitchType:    {name: "tuyaSwitchType",    ID: 0x8000, type: Zcl.DataType.ENUM8,  write: true, max: 0xff},
            },
            commands: {},
            commandsResponse: {},
        }),
    ],
    exposes: [
        e.cover_position(),
        e.binary("calibration", e.access.ALL, "ON", "OFF"),
        e.numeric("calibration_time", e.access.ALL).withUnit("s"),
        e.enum("moving", e.access.STATE, ["UP", "STOP", "DOWN"]),
        e.binary("motor_reversal", e.access.ALL, "ON", "OFF"),
    ],
};

Once you're on a build with the fix, entering 30 should write 300 and stick.

One honest caveat: I don't have this module on my bench, so I'm reasoning from the code and the tenths-of-a-second behaviour others reported, not a hardware test on your exact unit. The external converter above I also haven't run against real hardware — it's a stopgap, not the upstream fix. If after updating you enter 30 and it calibrates to something other than ~30s, say so and we'll look again, but I'd be surprised.

SamHartleyFixes avatar Jul 09 '26 23:07 SamHartleyFixes

same issue within my installation.

on-off-on avatar Jul 17 '26 22:07 on-off-on

Confirming this on the same device (TS130F_GIRIER, _TZ3210_dwytrmda, two units) — and I think I can pin down the cause: this is a regression, and the attribute is being encoded as 8-bit instead of 16-bit.

It works on 2.8.0 and fails on 2.12.1. I hit this after upgrading and rolled back to verify:

Z2M {"calibration_time": 18}
2.12.1 fails
2.8.0 succeeds, device confirms calibration_time: 18

Why both error variants appear. The converter multiplies seconds by 10 (lib/tuya.js):

const calibration_time = value * 10;
await entity.write("closuresWindowCovering", { moesCalibrationTime: calibration_time });

Combined with an 8-bit encoding that gives exactly the two failures described here:

  • value > 25.5 s → value * 10 > 255 → RangeError [ERR_OUT_OF_RANGE]: The value of "value" is out of range. It must be >= 0 and <= 255. Received 300
  • value <= 25.5 s → fits in 8 bit, gets sent, but the device rejects it: failed (Status 'INVALID_DATA_TYPE')

So no input value can succeed.

Likely root cause — duplicate attribute ID. In 2.8.0 zigbee-herdsman/dist/zspec/zcl/definition/cluster.js has two attributes sharing ID 0xf003 in closuresWindowCovering:

moesCalibrationTime:          { ID: 0xf003, type: DataType.UINT16, write: true, max: 0xffff },
targetPositionTiltPercentage: { ID: 0xf003, type: DataType.ENUM8 },

On 2.8.0 the write is encoded as UINT16 and the device accepts it. On 2.12.1 the 8-bit (ENUM8) definition appears to win the lookup, which matches the OP's observation that the Developer Console shows the attribute as ENUM8, and explains the INVALID_DATA_TYPE from a device that expects 16-bit.

Workaround for anyone stuck: the calibration time is stored in the device, so a temporary downgrade is enough — roll back to 2.8.0, set the value once, then upgrade again. The setting persists.

Verified by measuring actual motor runtime via an in-line power meter: with calibration_time wrongly left at 31 s on a shutter whose real travel is ~18 s, a 50 % command ran the motor 15.5 s (nearly fully closed). After setting 18 s it runs ~11 s, i.e. roughly half travel as expected.

cu6e avatar Jul 29 '26 19:07 cu6e

The issue is fixed in the next Z2M release

andrei-lazarov avatar Jul 29 '26 20:07 andrei-lazarov

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

github-actions[bot] avatar Sep 28 '26 00:09 github-actions[bot]