mirror of
https://github.com/lehanspb/tuya-mqtt.git
synced 2025-12-18 08:13:23 +00:00
Release 3.0.0
3.0.0 Release Major changes from 2.1.0: * Completely new configuration engine * Completely new topic structure * New template engine for creating friendly topic structure from raw DPS values * Pre-defined templates for some common devices * Directly control devices via Tuya JSON topic or via DPS key topics
This commit is contained in:
@@ -31,6 +31,20 @@ class RGBTWLight extends TuyaDevice {
|
||||
this.deviceData.mdl = 'RGBTW Light'
|
||||
this.isRgbtwLight = true
|
||||
|
||||
// Set white value transform math
|
||||
let whiteValueStateMath
|
||||
let whiteValueCommandMath
|
||||
if (this.config.whiteValueScale === 255) {
|
||||
// Devices with brightness scale of 255 seem to not allow values
|
||||
// less then 25 (10%) without producing timeout errors.
|
||||
whiteValueStateMath = '/2.3-10.86'
|
||||
whiteValueCommandMath = '*2.3+25'
|
||||
} else {
|
||||
// For other scale (usually 1000), 10-1000 seems OK.
|
||||
whiteValueStateMath = '/('+this.config.whiteValueScale+'/100)'
|
||||
whiteValueCommandMath = '*('+this.config.whiteValueScale+'/100)'
|
||||
}
|
||||
|
||||
// Map generic DPS topics to device specific topic names
|
||||
this.deviceTopics = {
|
||||
state: {
|
||||
@@ -40,11 +54,10 @@ class RGBTWLight extends TuyaDevice {
|
||||
white_brightness_state: {
|
||||
key: this.config.dpsWhiteValue,
|
||||
type: 'int',
|
||||
min: 1,
|
||||
max: 100,
|
||||
scale: this.config.whiteValueScale,
|
||||
stateMath: '/('+this.config.whiteValueScale+'/100)',
|
||||
commandMath: '*('+this.config.whiteValueScale+'/100)'
|
||||
topicMin: 0,
|
||||
topicMax: 100,
|
||||
stateMath: whiteValueStateMath,
|
||||
commandMath: whiteValueCommandMath
|
||||
},
|
||||
hs_state: {
|
||||
key: this.config.dpsColor,
|
||||
@@ -77,8 +90,8 @@ class RGBTWLight extends TuyaDevice {
|
||||
this.deviceTopics.color_temp_state = {
|
||||
key: this.config.dpsColorTemp,
|
||||
type: 'int',
|
||||
min: this.config.minColorTemp,
|
||||
max: this.config.maxColorTemp,
|
||||
topicMin: this.config.minColorTemp,
|
||||
topicMax: this.config.maxColorTemp,
|
||||
stateMath: '/'+scaleFactor+'*-'+rangeFactor+'+'+this.config.maxColorTemp,
|
||||
commandMath: '/'+rangeFactor+'*-'+scaleFactor+'+'+tuyaMaxColorTemp
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user