@@ -3,6 +3,7 @@ import * as tuya from '../lib/tuya';
3
3
import { DefinitionWithExtend } from '../lib/types' ;
4
4
5
5
const e = exposes . presets ;
6
+ const ea = exposes . access ;
6
7
7
8
const definitions : DefinitionWithExtend [ ] = [
8
9
{
@@ -29,7 +30,159 @@ const definitions: DefinitionWithExtend[] = [
29
30
] ,
30
31
} ,
31
32
} ,
32
-
33
+ {
34
+ fingerprint : tuya . fingerprint ( 'TS0601' , [ '_TZE200_ybsqljjg' ] ) ,
35
+ model : 'ME168' ,
36
+ vendor : 'AVATTO' ,
37
+ description : 'Thermostatic radiator valve' ,
38
+ fromZigbee : [ tuya . fz . datapoints ] ,
39
+ toZigbee : [ tuya . tz . datapoints ] ,
40
+ onEvent : tuya . onEventSetTime ,
41
+ configure : tuya . configureMagicPacket ,
42
+ ota : true ,
43
+ exposes : [
44
+ e . battery ( ) ,
45
+ //! to fix as the exposed format is bitmap
46
+ e . numeric ( 'error' , ea . STATE ) . withDescription ( 'If NTC is damaged, "Er" will be on the TRV display.' ) ,
47
+ e . child_lock ( ) . withCategory ( 'config' ) ,
48
+ e
49
+ . enum ( 'running_mode' , ea . STATE , [ 'auto' , 'manual' , 'off' , 'eco' , 'comfort' , 'boost' ] )
50
+ . withDescription ( 'Actual TRV running mode' )
51
+ . withCategory ( 'diagnostic' ) ,
52
+ e
53
+ . climate ( )
54
+ . withSystemMode ( [ 'off' , 'heat' , 'auto' ] , ea . STATE_SET , 'Basic modes' )
55
+ . withPreset ( [ 'eco' , 'comfort' , 'boost' ] , 'Additional heat modes' )
56
+ . withRunningState ( [ 'idle' , 'heat' ] , ea . STATE )
57
+ . withSetpoint ( 'current_heating_setpoint' , 4 , 35 , 1 , ea . STATE_SET )
58
+ . withLocalTemperature ( ea . STATE )
59
+ . withLocalTemperatureCalibration ( - 30 , 30 , 1 , ea . STATE_SET ) ,
60
+ e
61
+ . binary ( 'window_detection' , ea . STATE_SET , 'ON' , 'OFF' )
62
+ . withDescription ( 'Enables/disables window detection on the device' )
63
+ . withCategory ( 'config' ) ,
64
+ e . window_open ( ) ,
65
+ e
66
+ . binary ( 'frost_protection' , ea . STATE_SET , 'ON' , 'OFF' )
67
+ . withDescription (
68
+ 'When the room temperature is lower than 5 °C, the valve opens; when the temperature rises to 8 °C, the valve closes.' ,
69
+ )
70
+ . withCategory ( 'config' ) ,
71
+ e
72
+ . binary ( 'scale_protection' , ea . STATE_SET , 'ON' , 'OFF' )
73
+ . withDescription (
74
+ 'If the heat sink is not fully opened within ' +
75
+ 'two weeks or is not used for a long time, the valve will be blocked due to silting up and the heat sink will not be ' +
76
+ 'able to be used. To ensure normal use of the heat sink, the controller will automatically open the valve fully every ' +
77
+ 'two weeks. It will run for 30 seconds per time with the screen displaying "Ad", then return to its normal working state ' +
78
+ 'again.' ,
79
+ )
80
+ . withCategory ( 'config' ) ,
81
+ e
82
+ . numeric ( 'boost_time' , ea . STATE_SET )
83
+ . withUnit ( 'min' )
84
+ . withDescription ( 'Boost running time' )
85
+ . withValueMin ( 0 )
86
+ . withValueMax ( 255 )
87
+ . withCategory ( 'config' ) ,
88
+ e . numeric ( 'boost_timeset_countdown' , ea . STATE ) . withUnit ( 'min' ) . withDescription ( 'Boost time remaining' ) ,
89
+ e . eco_temperature ( ) . withValueMin ( 5 ) . withValueMax ( 35 ) . withValueStep ( 1 ) . withCategory ( 'config' ) ,
90
+ e . comfort_temperature ( ) . withValueMin ( 5 ) . withValueMax ( 35 ) . withValueStep ( 1 ) . withCategory ( 'config' ) ,
91
+ ...tuya . exposes
92
+ . scheduleAllDays ( ea . STATE_SET , '06:00/21.0 08:00/16.0 12:00/21.0 14:00/16.0 18:00/21.0 22:00/16.0' )
93
+ . map ( ( text ) => text . withCategory ( 'config' ) ) ,
94
+ ] ,
95
+ meta : {
96
+ tuyaDatapoints : [
97
+ // mode (RW Enum [0=auto, 1=manual, 2=off, 3=eco, 4=comfort, 5=boost])
98
+ [
99
+ 2 ,
100
+ null ,
101
+ tuya . valueConverter . thermostatSystemModeAndPresetMap ( {
102
+ fromMap : {
103
+ 0 : { device_mode : 'auto' , system_mode : 'auto' , preset : 'none' } ,
104
+ 1 : { device_mode : 'manual' , system_mode : 'heat' , preset : 'none' } ,
105
+ 2 : { device_mode : 'off' , system_mode : 'off' , preset : 'none' } ,
106
+ 3 : { device_mode : 'eco' , system_mode : 'heat' , preset : 'eco' } ,
107
+ 4 : { device_mode : 'comfort' , system_mode : 'heat' , preset : 'comfort' } ,
108
+ 5 : { device_mode : 'boost' , system_mode : 'heat' , preset : 'boost' } ,
109
+ } ,
110
+ } ) ,
111
+ ] ,
112
+ [
113
+ 2 ,
114
+ 'system_mode' ,
115
+ tuya . valueConverter . thermostatSystemModeAndPresetMap ( {
116
+ toMap : {
117
+ auto : new tuya . Enum ( 0 ) , // auto
118
+ heat : new tuya . Enum ( 1 ) , // manual
119
+ off : new tuya . Enum ( 2 ) , // off
120
+ } ,
121
+ } ) ,
122
+ ] ,
123
+ [
124
+ 2 ,
125
+ 'preset' ,
126
+ tuya . valueConverter . thermostatSystemModeAndPresetMap ( {
127
+ toMap : {
128
+ none : new tuya . Enum ( 1 ) , // manual
129
+ eco : new tuya . Enum ( 3 ) , // eco
130
+ comfort : new tuya . Enum ( 4 ) , // comfort
131
+ boost : new tuya . Enum ( 5 ) , // boost
132
+ } ,
133
+ } ) ,
134
+ ] ,
135
+ // work_state (RO Enum [0=opened, 1=closed])
136
+ [ 3 , 'running_state' , tuya . valueConverterBasic . lookup ( { heat : tuya . enum ( 0 ) , idle : tuya . enum ( 1 ) } ) ] ,
137
+ // temp_set (RW Integer, 40-350 C, scale 1 step 10)
138
+ [ 4 , 'current_heating_setpoint' , tuya . valueConverter . divideBy10 ] ,
139
+ // temp_current (RO Integer, -0-500 C, scale 1 step 10)
140
+ [ 5 , 'local_temperature' , tuya . valueConverter . divideBy10 ] ,
141
+ // battery_percentage (RO, Integer, 0-100 %, scale 0 step 1)
142
+ [ 6 , 'battery' , tuya . valueConverter . raw ] ,
143
+ // child_lock (RW Boolean)
144
+ [ 7 , 'child_lock' , tuya . valueConverter . lockUnlock ] ,
145
+ //! load_status (RW, Enum, range [0=closed, 1=opened]) - Non-functional
146
+ // [13, 'load_status', tuya.valueConverterBasic.lookup({CLOSE: tuya.enum(0), OPEN: tuya.enum(1)})],
147
+ // window_check (RW Boolean)
148
+ [ 14 , 'window_detection' , tuya . valueConverter . onOff ] ,
149
+ // window_state (RO Enum, range [0=opened, 1=closed])
150
+ [ 15 , 'window_open' , tuya . valueConverter . trueFalseEnum0 ] ,
151
+ // week_program_13_(1-7) (RW Raw, maxlen 128, special binary-in-base64 format)
152
+ [ 28 , 'schedule_monday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 1 , 6 ) ] ,
153
+ [ 29 , 'schedule_tuesday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 2 , 6 ) ] ,
154
+ [ 30 , 'schedule_wednesday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 3 , 6 ) ] ,
155
+ [ 31 , 'schedule_thursday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 4 , 6 ) ] ,
156
+ [ 32 , 'schedule_friday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 5 , 6 ) ] ,
157
+ [ 33 , 'schedule_saturday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 6 , 6 ) ] ,
158
+ [ 34 , 'schedule_sunday' , tuya . valueConverter . thermostatScheduleDayMultiDPWithDayNumber ( 7 , 6 ) ] ,
159
+ //? error (RO Bitmap, maxlen 2, label [0x=low_battery, x0=sensor_fault]?)
160
+ [ 35 , null , tuya . valueConverter . errorOrBatteryLow ] ,
161
+ // frost (RW Boolean)
162
+ [ 36 , 'frost_protection' , tuya . valueConverter . onOff ] ,
163
+ //! rapid_switch (RW Boolean) - Non-functional
164
+ // [37, 'rapid_switch', tuya.valueConverter.onOff],
165
+ //! rapid_countdown (RW Integer, 1-12 h, scale 0 step 1) - Non-functional
166
+ // [38, 'rapid_countdown', tuya.valueConverter.raw],
167
+ // scale_switch (RW Boolean)
168
+ [ 39 , 'scale_protection' , tuya . valueConverter . onOff ] ,
169
+ // temp_correction (RW Integer, -10-10 C, scale 0 step 1)
170
+ [ 47 , 'local_temperature_calibration' , tuya . valueConverter . localTempCalibration2 ] ,
171
+ // comfort_temp (RW Integer, 100-250 C, scale 1 step 10)
172
+ [ 101 , 'comfort_temperature' , tuya . valueConverter . divideBy10 ] ,
173
+ //! switch (RW Boolean) - Non-functional
174
+ // [102, 'switch', tuya.valueConverter.onOff],
175
+ // rapid_time_set (RW Integer, 0-180 min, scale 0 step 1)
176
+ [ 103 , 'boost_time' , tuya . valueConverter . raw ] ,
177
+ // heating_countdown (RO Integer, 0-3600 min, scale 0 step 1)
178
+ [ 104 , 'boost_timeset_countdown' , tuya . valueConverter . countdown ] ,
179
+ // eco_temp (RW Integer, 100-200 C, scale 1 step 10)
180
+ [ 105 , 'eco_temperature' , tuya . valueConverter . divideBy10 ] ,
181
+ //! eco (RW Boolean) - Non-functional
182
+ // [106, 'eco', tuya.valueConverter.onOff],
183
+ ] ,
184
+ } ,
185
+ } ,
33
186
{
34
187
fingerprint : tuya . fingerprint ( 'TS0601' , [ '_TZE204_goecjd1t' ] ) ,
35
188
model : 'ZWPM16' ,
0 commit comments