Koenkk / zigbee2mqtt

Zigbee 🐝 to MQTT bridge 🌉, get rid of your proprietary Zigbee bridges 🔨
https://www.zigbee2mqtt.io
GNU General Public License v3.0
11.25k stars 1.6k forks source link

[New device support]: Tuya Curtain Motor (_TZE204_xu4a5rhj) #22614

Closed FliesWithWind closed 2 weeks ago

FliesWithWind commented 2 weeks ago

Link

https://www.aliexpress.us/item/3256805121866593.html?spm=a2g0o.order_list.order_list_main.17.23ff1c24xgAcbe&gatewayAdapt=glo2usa4itemAdapt

Database entry

{ "id": 5, "type": "Router", "ieeeAddr": "0xa4c138510ab3d6d0", "nwkAddr": 24621, "manufId": 4417, "manufName": "_TZE204_xu4a5rhj", "powerSource": "Mains (single phase)", "modelId": "TS0601", "epList": [ 1, 242 ], "endpoints": { "1": { "profId": 260, "epId": 1, "devId": 81, "inClusterList": [ 4, 5, 61184, 0 ], "outClusterList": [ 25, 10 ], "clusters": { "genBasic": { "attributes": { "stackVersion": 0, "dateCode": "" } } }, "binds": [], "configuredReportings": [], "meta": {} }, "242": { "profId": 41440, "epId": 242, "devId": 97, "inClusterList": [], "outClusterList": [ 33 ], "clusters": {}, "binds": [], "configuredReportings": [], "meta": {} } }, "appVersion": 74, "stackVersion": 0, "hwVersion": 1, "dateCode": "", "zclVersion": 3, "interviewCompleted": true, "meta": {}, "lastSeen": 1715600001520 }

Comments

Tuya curtain motor that seems to be similar to https://github.com/Koenkk/zigbee2mqtt/issues/17506 and https://github.com/Koenkk/zigbee2mqtt/issues/17518

I've tried to get it to work using a converter but failed so far since I'm still getting familiar with zigbee2mqtt.

External definition

const definition = {
    zigbeeModel: ['TS0601'],
    model: 'TS0601',
    vendor: '_TZE204_xu4a5rhj',
    description: 'Automatically generated definition',
    extend: [],
    meta: {},
};

module.exports = definition;
FliesWithWind commented 2 weeks ago

I guess it works under TS0601_cover_1

const legacy = require('zigbee-herdsman-converters/lib/legacy');
const fz = {...require('zigbee-herdsman-converters/converters/fromZigbee'), legacy: require('zigbee-herdsman-converters/lib/legacy').fromZigbee};
const tz = {...require('zigbee-herdsman-converters/converters/toZigbee'), legacy: require('zigbee-herdsman-converters/lib/legacy').toZigbee};
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const utils = require('zigbee-herdsman-converters/lib/utils');
const e = exposes.presets;
const ea = exposes.access;

const definition = {
    fingerprint: [
        {modelID: 'TS0601', manufacturerName: '_TZE204_xu4a5rhj'},
    ],
    model: 'TS0601_cover_1',
    vendor: 'TuYa',
    description: 'Curtain motor/roller blind motor/window pusher/tubular motor',
    fromZigbee: [legacy.fromZigbee.tuya_cover, fz.ignore_basic_report],
    toZigbee: [legacy.toZigbee.tuya_cover_control, legacy.toZigbee.tuya_cover_options],
    exposes: [
        e.cover_position().setAccess('position', ea.STATE_SET),
        e.composite('options', 'options', ea.STATE_SET)
            .withFeature(e.numeric('motor_speed', ea.STATE_SET)
                .withValueMin(0).withValueMax(255).withDescription('Motor speed'))
            .withFeature(e.binary('reverse_direction', ea.STATE_SET, true, false)
                .withDescription('Reverse the motor direction'))
    ],
};

module.exports = definition;
Koenkk commented 2 weeks ago

Added!

Changes will be available in the dev branch in a few hours from now.