Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help with percentage control in my Tuya day/night curtain converter!! #24800

Open
lccox opened this issue Nov 17, 2024 · 0 comments
Open
Labels
problem Something isn't working

Comments

@lccox
Copy link

lccox commented Nov 17, 2024

What happened?

I wrote an external converter for the Tuya day/night curtains. The curtain device has the following DP points:
{
"1": "Day Curtain Control",
"2": "Day Curtain Percentage Control",
"3": "Day Curtain Percentage Status",
"101": "Night Curtain Percentage Control",
"102": "Night Curtain Percentage Status",
"109": "Night Curtain Control",
"120": "Night Curtain Motor Direction",
"121": "Day Curtain Motor Direction"
}

Using these DP points, I edited an external converter. It allows me to control the day and night curtains' open/close using DP 1 and 109, while DP 2 and 3 enable percentage control and feedback for the day curtain. However, I cannot achieve percentage control for the night curtain using DP 101, although I seem to be able to read the percentage using DP 102.

Here is the converter code I wrote:

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 tuya = require('zigbee-herdsman-converters/lib/tuya');
const legacy = require('zigbee-herdsman-converters/lib/legacy');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: '_TZE200_luexzx4j',
    description: 'Zhongling-DayNightCover-GM24TF/S-TYZ with dual cover support',
    fromZigbee: [tuya.fz.datapoints, legacy.fromZigbee.tuya_cover, fz.ignore_basic_report],
    toZigbee: [tuya.tz.datapoints, legacy.toZigbee.tuya_cover_control, legacy.toZigbee.tuya_cover_options],
    exposes: [
        e.cover_position().withEndpoint('cover_a').setAccess('position', ea.STATE_SET),
        e.cover_position().withEndpoint('cover_b').setAccess('position', ea.STATE_SET),
    ],
    meta: {
        multiEndpoint: true,
        tuyaDatapoints: [
            // Cover A
            [1, 'state_cover_a', tuya.valueConverterBasic.lookup({'CONTINUE': tuya.enum(3), 'CLOSE': tuya.enum(1), 'STOP': tuya.enum(2), 'OPEN': tuya.enum(0)})],
            [2, 'position_cover_a', tuya.valueConverter.coverPositionInverted],
            [3, 'position_cover_a_raw', tuya.valueConverter.raw],
            // Cover B
            [109, 'state_cover_b', tuya.valueConverterBasic.lookup({'CONTINUE': tuya.enum(3), 'CLOSE': tuya.enum(1), 'STOP': tuya.enum(2), 'OPEN': tuya.enum(0)})],
            [101, 'position_cover_b', tuya.valueConverter.coverPositionInverted], // Fix for percentage control logic
            [102, 'position_cover_b_raw', tuya.valueConverter.raw],
        ],
    },
    endpoint: (device) => {
        return {
            cover_a: 1,
            cover_b: 1, // DP is used for distinguishing features, no need for separate endpoints
        };
    },
    configure: async (device, coordinatorEndpoint, logger) => {
        await tuya.configureMagicPacket(device, logger);
    },
};

module.exports = definition;

I would appreciate any insights or solutions to enable percentage control for the night curtain using DP 101.

What did you expect to happen?

I need assistance in completing the percentage control for the night curtain to improve the external converter, allowing the device to function correctly. Thank you!!!!!!

Zigbee2MQTT version

1.22.1

Adapter firmware version

20211210

Adapter

ember

Setup

Addon on HAOS

Debug log

[2024-11-17 15:34:52] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64', payload '{"linkquality":58,"position":0,"position_b":74,"position_cover_a":37,"position_cover_a_raw":0,"position_cover_b":44,"position_cover_b_raw":47,"position_d":61,"position_n":100,"running":false,"state":"OPEN","state_cover_a":"CLOSE","state_cover_b":"STOP"}'
[2024-11-17 15:34:52] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_a', payload '{"position":0,"state":"CLOSE"}'
[2024-11-17 15:34:52] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_b', payload '{"position":44,"state":"STOP"}'
[2024-11-17 15:34:53] debug: zh:zstack:unpi:parser: <-- [254,33,68,129,0,0,0,239,168,224,1,1,0,58,0,213,169,186,0,0,13,9,39,2,0,220,101,2,0,4,0,0,0,56,168,224,29,76]
[2024-11-17 15:34:53] debug: zh:zstack:unpi:parser: --- parseNext [254,33,68,129,0,0,0,239,168,224,1,1,0,58,0,213,169,186,0,0,13,9,39,2,0,220,101,2,0,4,0,0,0,56,168,224,29,76]
[2024-11-17 15:34:53] debug: zh:zstack:unpi:parser: --> parsed 33 - 2 - 4 - 129 - [0,0,0,239,168,224,1,1,0,58,0,213,169,186,0,0,13,9,39,2,0,220,101,2,0,4,0,0,0,56,168,224,29] - 76
[2024-11-17 15:34:53] debug: zh:zstack:znp: <-- AREQ: AF - incomingMsg - {"groupid":0,"clusterid":61184,"srcaddr":57512,"srcendpoint":1,"dstendpoint":1,"wasbroadcast":0,"linkquality":58,"securityuse":0,"timestamp":12233173,"transseqnumber":0,"len":13,"data":{"type":"Buffer","data":[9,39,2,0,220,101,2,0,4,0,0,0,56]}}
[2024-11-17 15:34:53] debug: zh:controller: Received payload: clusterID=61184, address=57512, groupID=0, endpoint=1, destinationEndpoint=1, wasBroadcast=false, linkQuality=58, frame={"header":{"frameControl":{"frameType":1,"manufacturerSpecific":false,"direction":1,"disableDefaultResponse":false,"reservedBits":0},"transactionSequenceNumber":39,"commandIdentifier":2},"payload":{"seq":56320,"dpValues":[{"dp":101,"datatype":2,"data":{"type":"Buffer","data":[0,0,0,56]}}]},"command":{"ID":2,"parameters":[{"name":"seq","type":33},{"name":"dpValues","type":1011}],"name":"dataReport"}}
[2024-11-17 15:34:53] debug: zh:controller:endpoint: ZCL command 0xa4c1385ce13eda64/1 manuSpecificTuya.defaultRsp({"cmdId":2,"statusCode":0}, {"timeout":10000,"disableResponse":false,"disableRecovery":false,"disableDefaultResponse":true,"direction":0,"reservedBits":0,"transactionSequenceNumber":39,"writeUndiv":false})
[2024-11-17 15:34:53] debug: zh:zstack: sendZclFrameToEndpointInternal 0xa4c1385ce13eda64:57512/1 (0,0,1)
[2024-11-17 15:34:53] debug: zh:zstack:znp: --> SREQ: AF - dataRequest - {"dstaddr":57512,"destendpoint":1,"srcendpoint":1,"clusterid":61184,"transid":154,"options":0,"radius":30,"len":5,"data":{"type":"Buffer","data":[16,39,11,2,0]}}
[2024-11-17 15:34:53] debug: zh:zstack:unpi:writer: --> frame [254,15,36,1,168,224,1,1,0,239,154,0,30,5,16,39,11,2,0,50]
[2024-11-17 15:34:53] debug: zh:zstack:unpi:parser: --- parseNext []
[2024-11-17 15:34:53] debug: z2m: Received Zigbee message from '0xa4c1385ce13eda64', type 'commandDataReport', cluster 'manuSpecificTuya', data '{"dpValues":[{"data":{"data":[0,0,0,56],"type":"Buffer"},"datatype":2,"dp":101}],"seq":56320}' from endpoint 1 with groupID 0
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64', payload '{"linkquality":58,"position":0,"position_b":74,"position_cover_a":37,"position_cover_a_raw":0,"position_cover_b":44,"position_cover_b_raw":47,"position_d":61,"position_n":100,"running":false,"state":"OPEN","state_cover_a":"CLOSE","state_cover_b":"STOP"}'
[2024-11-17 15:34:53] debug: zhc:legacy:fz:tuya_cover: Unrecognized DP #101: {"dp":101,"datatype":2,"data":{"type":"Buffer","data":[0,0,0,56]}}
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_a', payload '{"position":0,"state":"CLOSE"}'
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64', payload '{"linkquality":58,"position":0,"position_b":74,"position_cover_a":37,"position_cover_a_raw":0,"position_cover_b":44,"position_cover_b_raw":47,"position_d":61,"position_n":100,"running":false,"state":"OPEN","state_cover_a":"CLOSE","state_cover_b":"STOP"}'
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_b', payload '{"position":44,"state":"STOP"}'
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_a', payload '{"position":0,"state":"CLOSE"}'
[2024-11-17 15:34:53] info: z2m:mqtt: MQTT publish: topic 'zigbee2mqtt/0xa4c1385ce13eda64/cover_b', payload '{"position":44,"state":"STOP"}'

@lccox lccox added the problem Something isn't working label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant