Skip to content

The curtain cannot be opened,I have found prob commit,need fix it #30206

@wchy1128

Description

@wchy1128

What happened?

After updating my older version to 2.7.1, I found that my Konke curtain motor cannot open properly.
The symptom is: when I click to open or set the position to 100%, the curtain opens a little first, then pauses and closes again. If I set the curtain position above 90% multiple times within a short period, the curtain can occasionally open.

What did you expect to happen?

No response

How to reproduce it (minimal and precise)

After investigation, I found that the curtain works normally with the code before commit 5286570. However, once updated to version 528657or later, it malfunctions. Looking at the changes in 528657, I suspect it's related to the optimization of the oneventhandling, but I cannot pinpoint the exact details. Please help fix this issue.

Zigbee2MQTT version

after 2.6.0

Adapter firmware version

7.4.4 [GA]

Adapter

EmberZNet

Setup

haos raspberry 5B

curtain code:
`
cover_position_tilt : {
cluster: "closuresWindowCovering",
type: ["attributeReport", "readResponse"],
//options: [exposes_1.options.invert_cover()],
convert: (model, msg, publish, options, meta) => {
// debugger;
const result = {};

        // const metaInvert = model.meta?.coverInverted;
        // const invert = metaInvert ? !options.invert_cover : options.invert_cover;

        if (msg.data.currentPositionLiftPercentage !== undefined && msg.data.currentPositionLiftPercentage <= 100) {
            const value = msg.data.currentPositionLiftPercentage;
            // result[(0, utils_1.postfixWithEndpointName)("position", msg, model, meta)] = invert ? value : 100 - value;

            result[(0, utils.postfixWithEndpointName)("position", msg, model, meta)] = value;
            if (value >= 4){
                result[(0, utils.postfixWithEndpointName)("state", msg, model, meta)] = "OPEN";
            }else
            {
                result[(0, utils.postfixWithEndpointName)("state", msg, model, meta)] = "CLOSE";
            }
        }
        
        // result[(0, utils.postfixWithEndpointName)("position", msg, model, meta)] = value;
        // // result[(0, utils.postfixWithEndpointName)("state", msg, model, meta)] = value === 0 ? "CLOSE" : "OPEN";
        // // result[(0, utils.postfixWithEndpointName)("state", msg, model, meta)] = value === 100 ? "CLOSE" : "OPEN";
        // result[(0, utils.postfixWithEndpointName)("state", msg, model, meta)] = value < 4 ? "CLOSE" : "OPEN";

        // if (msg.data.windowCoveringMode !== undefined) {
        //     result[(0, utils.postfixWithEndpointName)("cover_mode", msg, model, meta)] = {
        //         reversed: (msg.data.windowCoveringMode & (1 << 0)) > 0,
        //         calibration: (msg.data.windowCoveringMode & (1 << 1)) > 0,
        //         maintenance: (msg.data.windowCoveringMode & (1 << 2)) > 0,
        //         led: (msg.data.windowCoveringMode & (1 << 3)) > 0,
        //     };
        // }
        return result;
    },
},
on_off : {
    cluster: "genOnOff",
    type: ["attributeReport", "readResponse"],
    options: [exposes_1.options.state_action()],
    convert: (model, msg, publish, options, meta) => {
        // debugger;
        const state_dict = { 0: 'CLOSE', 1: 'OPEN', 2:'STOP' };
        if (msg.data.onOff !== undefined) {
            const payload = {};
            const property = (0, utils.postfixWithEndpointName)("state", msg, model, meta);
            const state = state_dict[msg.data.onOff];
            payload[property] = state;
            if (options?.state_action) {
                payload.action = (0, utils.postfixWithEndpointName)(state.toLowerCase(), msg, model, meta);
            }
            return payload;
        }
    },
}

{
zigbeeModel: ["3AFE201102020000"],
model: "BCM100D",
vendor: "Konke",
description: "Konke Curtain",
fromZigbee: [fz_local.motor_direction, fz_local.on_off, fz_local.cover_position_tilt],
toZigbee: [tz_local.konke_cmd, tz.cover_state, tz.cover_position_tilt],
exposes:[
e.cover().withPosition(),
e.enum("Konke_cmd", ea.STATE_SET, ["calibration", "reversed"]).withDescription("calibration/reversed curtain"),
e.enum("motor_direction", ea.STATE_SET, ["forward", "reverse"]).withDescription("Set the motor direction")
],
extend: [
m.deviceAddCustomCluster("customClusterKonke", customCluster),
//m.setupConfigureForReporting("closuresWindowCovering", "currentPositionLiftPercentage", { min: "1_SECOND", max: "MAX", change: 1 }, exposes_1.access.STATE_GET),

        // closuresWindowCovering
        //m.quirkAddEndpointCluster({endpointID: 1, inputClusters: ["genOnOff"]})
    ],
    configure: async (device, coordinatorEndpoint) => {
        const endpoint = device.getEndpoint(1);

        //await reporting.bind(endpoint, coordinatorEndpoint, ["closuresWindowCovering", "genOnOff"]);
		await reporting.bind(endpoint, coordinatorEndpoint, ["closuresWindowCovering"]);
        await reporting.currentPositionLiftPercentage(endpoint, {min: 0, max: 3600, change: 1});
        //await reporting.onOff(endpoint, {min: 30, max: 3600, change: 1})
    },
    onEvent: async (type, data, device, settings, state) => {
        //debugger;
        //logger_1.logger.info((data.type + "< type, cluster >" + data.cluster), "onevent puts: ");
        device.skipDefaultResponse = true;
        if (type === "message") {
            if (data.type === "attributeReport" && (data.cluster === "genOnOff" || data.cluster === "closuresWindowCovering"))
            {
                await data.endpoint.defaultResponse(0x0a, 0, 258, data.meta.zclTransactionSequenceNumber, {direction: 0, disableDefaultResponse: true});
                //logger_1.logger.info(data.data.onOff, NS);
            }
        }
    },
},`

Device database.db entry

No response

Debug log

log.zip

Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    problemSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions