-
-
Save Koenkk/12256a02e6f582e4e369014d2ff1d03b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 reporting = require('zigbee-herdsman-converters/lib/reporting'); | |
const extend = require('zigbee-herdsman-converters/lib/extend'); | |
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 globalStore = require('zigbee-herdsman-converters/lib/store'); | |
const e = exposes.presets; | |
const ea = exposes.access; | |
const tzLocal = { | |
...tuya.tz.datapoints, | |
// TODO: when merging update keys correctly | |
key: [ | |
'temperature_unit', 'temperature_calibration', 'humidity_calibration', 'alarm_switch', | |
'state', 'brightness', 'min_brightness', 'max_brightness', 'power_on_behavior', 'position', | |
'countdown', 'light_type', 'silence', 'self_test', 'child_lock', 'open_window', 'open_window_temperature', 'frost_protection', | |
'system_mode', 'heating_stop', 'current_heating_setpoint', 'local_temperature_calibration', 'preset', 'boost_timeset_countdown', | |
'holiday_start_stop', 'holiday_temperature', 'comfort_temperature', 'eco_temperature', 'working_day', | |
'week_schedule_programming', 'online', 'holiday_mode_date', 'schedule', 'schedule_monday', 'schedule_tuesday', | |
'schedule_wednesday', 'schedule_thursday', 'schedule_friday', 'schedule_saturday', 'schedule_sunday', 'clear_fault', | |
'scale_protection', 'error', 'radar_scene', 'radar_sensitivity', 'tumble_alarm_time', 'tumble_switch', 'fall_sensitivity', | |
'min_temperature', 'max_temperature', 'window_detection', 'boost_heating', 'alarm_ringtone', 'alarm_time', 'fan_speed', | |
'reverse_direction', 'border', 'click_control', 'work_state', 'motor_speed', 'mode', 'factory_reset', 'upper_limit', 'bottom_limit', | |
], | |
} | |
const valueConverter = { | |
setTrue: { | |
to: async (v, meta) => true, | |
from: (v, meta, options) => { | |
return undefined; | |
}, | |
}, | |
}; | |
const definition = { | |
fingerprint: [{modelID: 'TS0601', manufacturerName: '_TZE200_zah67ekd'}], | |
model: 'TS0601_cover_custom', | |
vendor: 'TuYa', | |
description: 'Curtain motor/roller blind motor/window pusher/tubular motor', | |
fromZigbee: [tuya.fz.datapoints], | |
toZigbee: [tzLocal], | |
exposes: [ | |
e.cover_position().setAccess('position', ea.STATE_SET), | |
exposes.enum('motor_direction', ea.STATE_SET, ['normal', 'reversed']).withDescription('Set the motor direction'), | |
exposes.numeric('motor_speed', ea.STATE_SET).withValueMin(0).withValueMax(255).withDescription('Motor speed').withUnit('rpm'), | |
exposes.enum('opening_mode', ea.STATE_SET, ['tilt', 'lift']).withDescription('Opening mode'), | |
exposes.enum('set_upper_limit', ea.SET, ['SET']).withDescription('Set the upper limit, to reset limits use factory_reset'), | |
exposes.enum('set_bottom_limit', ea.SET, ['SET']).withDescription('Set the bottom limit, to reset limits use factory_reset'), | |
exposes.binary('factory_reset', ea.STATE_SET, true, false).withDescription('Factory reset the device'), | |
], | |
meta: { | |
tuyaDatapoints: [ | |
[1, 'state', tuya.valueConverterBasic.lookup({'OPEN': tuya.enum(0), 'STOP': tuya.enum(1), 'CLOSE': tuya.enum(2)})], | |
[2, 'position', tuya.valueConverter.coverPosition], | |
[3, 'position', tuya.valueConverter.raw], | |
[5, 'motor_direction', tuya.valueConverterBasic.lookup({'normal': tuya.enum(0), 'reversed': tuya.enum(1)})], | |
[7, null, null], // work_state, not usefull, ignore | |
[101, 'opening_mode', tuya.valueConverterBasic.lookup({'tilt': tuya.enum(0), 'lift': tuya.enum(1)})], | |
[102, 'factory_reset', tuya.valueConverter.raw], | |
[103, 'set_upper_limit', valueConverter.setTrue], | |
[104, 'set_bottom_limit', valueConverter.setTrue], | |
[105, 'motor_speed', tuya.valueConverter.raw], | |
], | |
}, | |
}; | |
module.exports = definition; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment