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: 'Tuya',
description: '涂鸦控制器+中菱管状电机GM24TF/Z 7',
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().setAccess('position', ea.STATE_SET),
e.enum('reverse_direction', ea.STATE_SET, ['forward', 'back']).withDescription('Reverse the motor direction'),
e.binary('motor_fault', ea.STATE, true, false).withDescription('Motor Fault'),
e.binary('set_limit', ea.STATE_SET, true, false).withDescription('Set Limit'),
//e.binary('auto_power', ea.STATE_SET, true, false).withDescription('Auto Power'),
//exposes.numeric('motor_speed', ea.STATE_SET).withValueMin(0).withValueMax(255).withDescription('Motor speed'),
],
meta: {
tuyaDatapoints: [
[1, 'state', tuya.valueConverterBasic.lookup({'CONTINUE': tuya.enum(3), 'CLOSE': tuya.enum(2), 'STOP': tuya.enum(1), 'OPEN': tuya.enum(0)})],
//[6, 'auto_power', tuya.valueConverter.trueFalse1],
[9, 'position', tuya.valueConverter.coverPosition],
[8, 'position', tuya.valueConverter.coverPosition],
[10, 'motor_fault', tuya.valueConverter.trueFalse1],
[11, 'reverse_direction', tuya.valueConverterBasic.lookup({forward: tuya.enum(0), back: tuya.enum(1)})],
[101, 'set_limit', tuya.valueConverter.trueFalse1],
//[105, 'motor_speed', tuya.valueConverter.raw],
],
},
};
module.exports = definition;