iobroker.shelly
Version:
Integrate your Shelly devices into ioBroker via MQTT or CoAP
1,435 lines (1,390 loc) • 398 kB
JavaScript
'use strict';
const shellyHelper = require('../shelly-helper');
/**
* Naming convention (for new entries)
*
* devices are named like shelly components, i.e. Light, EM, PM1, ...
* id follows componentname without seperator if component does not end with a number (Light - Light0, EM - EM0, ...)
* id follows componentname with seperator ':' if component ends with a number (EM1 - EM1:0, ...)
*/
/**
* Adds a generic analog input sensor definition for Gen 2+ devices
* see
* https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/Input/
*
* @param {object} deviceObj
* @param {number} inputId
*/
function addAnalogInput(deviceObj, inputId) {
deviceObj[`Input${inputId}.ChannelName`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: async (value, self) => {
return value
? await shellyHelper.setChannelName(self, `Input${inputId}`, JSON.parse(value).name)
: undefined;
},
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { name: value } },
});
},
},
common: {
name: {
en: 'Channel name',
de: 'Kanalname',
ru: 'Имя канала',
pt: 'Nome do canal',
nl: 'Kanaalnaam',
fr: 'Nom du canal',
it: 'Nome del canale',
es: 'Nombre del canal',
pl: 'Channel imię',
'zh-cn': '姓名',
},
type: 'string',
role: 'text',
read: true,
write: true,
},
};
deviceObj[`Input${inputId}.Event`] = {
mqtt: {
mqtt_publish: '<mqttprefix>/events/rpc',
mqtt_publish_funct: value => {
const valueObj = JSON.parse(value);
if (valueObj?.method === 'NotifyEvent' && valueObj?.params?.events) {
for (const e in valueObj.params.events) {
const event = valueObj.params.events[e];
if (typeof event === 'object' && event.component === `input:${inputId}`) {
return event.event;
}
}
}
return undefined;
},
},
common: {
name: {
en: 'Input Event',
de: 'Eingangsereignis',
ru: 'Входное событие',
pt: 'Evento de entrada',
nl: 'Invoergebeurtenis',
fr: "Événement d'entrée",
it: 'Evento di input',
es: 'Evento de entrada',
pl: 'Zdarzenie wejściowe',
uk: 'Вхідна подія',
'zh-cn': '输入事件',
},
type: 'string',
role: 'state',
read: true,
write: false,
},
};
deviceObj[`Input${inputId}.InputType`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.parse(value).type : undefined),
// mqtt_cmd: '<mqttprefix>/rpc',
// mqtt_cmd_funct: (value, self) => {
// return JSON.stringify({
// id: self.getNextMsgId(),
// src: 'iobroker',
// method: 'Input.SetConfig',
// params: { id: inputId, config: { type: value } },
// });
// },
},
common: {
name: {
en: 'Input Type',
de: 'Eingangstyp',
ru: 'Тип ввода',
pt: 'Tipo de entrada',
nl: 'Invoertype',
fr: "Type d'entrée",
it: 'Tipo di input',
es: 'Tipo de entrada',
pl: 'Typ wejścia',
uk: 'Тип введення',
'zh-cn': '输入类型',
},
type: 'string',
role: 'state',
read: true,
write: false,
states: {
analog: 'analog',
},
},
};
deviceObj[`Input${inputId}.Enable`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.parse(value).enable : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { enable: value } },
});
},
},
common: {
name: {
en: 'Input enable',
de: 'Eingang aktivieren',
ru: 'Ввод включить',
pt: 'Habilitar entrada',
nl: 'Invoer inschakelen',
fr: "Activation de l'entrée",
it: 'Abilitazione input',
es: 'Habilitación de entrada',
pl: 'Włącz wejście',
uk: 'Увімкнення входу',
'zh-cn': '输入使能',
},
type: 'boolean',
role: 'state',
read: true,
write: true,
},
};
deviceObj[`Input${inputId}.InputInverted`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.parse(value).invert : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { invert: value } },
});
},
},
common: {
name: {
en: 'Input Inverted',
de: 'Eingang invertiert',
ru: 'Вход инвертированный',
pt: 'Entrada Invertida',
nl: 'Invoer omgekeerd',
fr: 'Entrée inversée',
it: 'Ingresso invertito',
es: 'Entrada invertida',
pl: 'Wejście odwrócone',
uk: 'Введення інвертовано',
'zh-cn': '输入反转',
},
type: 'boolean',
role: 'state',
read: true,
write: true,
},
};
deviceObj[`Input${inputId}.ReportThreshold`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.parse(value).report_thr : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { report_thr: value } },
});
},
},
common: {
name: {
en: 'Report threshold',
de: 'Meldeschwelle',
ru: 'Порог отчета',
pt: 'Limiar de referência',
nl: 'Vertaling:',
fr: 'Limite du rapport',
it: 'Soglia di relazione',
es: 'Nivel de informe',
pl: 'Raport o progu',
'zh-cn': '报告阈值',
},
type: 'number',
role: 'level',
read: true,
write: true,
unit: '%',
min: 1,
max: 50,
},
};
deviceObj[`Input${inputId}.RangeMap`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.stringify(JSON.parse(value).range_map) : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { range_map: JSON.parse(value) } },
});
},
},
common: {
name: {
en: 'Range mapping',
de: 'Bereichszuordnung',
ru: 'Картографирование диапазона',
pt: 'Mapeamento de alcance',
nl: 'Bereikmapping',
fr: 'Cartographie de la gamme',
it: "Mappatura dell'intervallo",
es: 'Mapeo de rangos',
pl: 'Mapowanie zasięgu',
uk: 'Картування діапазону',
'zh-cn': '范围映射',
},
type: 'string',
role: 'json',
read: true,
write: true,
},
};
deviceObj[`Input${inputId}.Range`] = {
mqtt: {
http_publish: `/rpc/Input.GetConfig?id=${inputId}`,
http_publish_funct: value => (value ? JSON.parse(value).range : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'Input.SetConfig',
params: { id: inputId, config: { range: value } },
});
},
},
common: {
name: {
en: 'Range',
de: 'Bereich',
ru: 'Диапазон',
pt: 'Faixa',
nl: 'Bereik',
fr: 'Gamme',
it: 'Allineare',
es: 'Rango',
pl: 'Zakres',
uk: 'Діапазон',
'zh-cn': '范围',
},
type: 'number',
role: 'level',
read: true,
write: true,
},
};
deviceObj[`Input${inputId}.Percent`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/input:${inputId}`,
mqtt_publish_funct: value => JSON.parse(value)?.percent,
},
common: {
name: {
en: 'Percentage value',
de: 'Prozentwert',
ru: 'Процентное значение',
pt: 'Valor percentual',
nl: 'Percentagewaarde',
fr: 'valeur en pourcentage',
it: 'Valore percentuale',
es: 'Valor porcentual',
pl: 'Wartość procentowa',
uk: 'Відсоткове значення',
'zh-cn': '百分比值',
},
type: 'number',
role: 'value',
read: true,
write: false,
unit: '%',
},
};
deviceObj[`Input${inputId}.Xpercent`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/input:${inputId}`,
mqtt_publish_funct: value => JSON.parse(value)?.xpercent,
},
common: {
name: {
en: 'Transformed percentage value',
de: 'Transformierter Prozentwert',
ru: 'Преобразованное процентное значение',
pt: 'Valor percentual transformado',
nl: 'Getransformeerde percentagewaarde',
fr: 'Valeur en pourcentage transformée',
it: 'Valore percentuale trasformato',
es: 'Valor porcentual transformado',
pl: 'Przekształcona wartość procentowa',
uk: 'Трансформоване відсоткове значення',
'zh-cn': '转换后的百分比值',
},
type: 'number',
role: 'value',
read: true,
write: false,
unit: '%',
},
};
}
/**
* Adds a generic CCT light definition for Gen 2+ devices
* see
* https://shelly-api-docs.shelly.cloud/gen2/ComponentsAndServices/CCT
*
* @param {object} deviceObj
* @param {number} cctId
* @param {boolean} hasPowerMetering
*/
function addCCT(deviceObj, cctId, hasPowerMetering) {
deviceObj[`CCT${cctId}.ChannelName`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: async (value, self) => {
return value
? await shellyHelper.setChannelName(self, `CCT${cctId}`, JSON.parse(value).name)
: undefined;
},
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { name: value } },
});
},
},
common: {
name: {
en: 'Channel name',
de: 'Kanalname',
ru: 'Имя канала',
pt: 'Nome do canal',
nl: 'Kanaalnaam',
fr: 'Nom du canal',
it: 'Nome del canale',
es: 'Nombre del canal',
pl: 'Channel imię',
'zh-cn': '姓名',
},
type: 'string',
role: 'text',
read: true,
write: true,
def: `cct_${cctId}`,
},
};
deviceObj[`CCT${cctId}.Switch`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).output,
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.Set',
params: { id: cctId, on: value },
});
},
},
common: {
name: {
en: 'Switch',
de: 'Schalter',
ru: 'Переключить',
pt: 'Interruptor',
nl: 'Schakelaar',
fr: 'Interrupteur',
it: 'Interruttore',
es: 'Interruptor',
pl: 'Przełącznik',
'zh-cn': '开关',
},
type: 'boolean',
role: 'switch',
read: true,
write: true,
def: false,
},
};
deviceObj[`CCT${cctId}.Brightness`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).brightness,
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.Set',
params: { id: cctId, brightness: value },
});
},
},
common: {
name: {
en: 'Brightness',
de: 'Helligkeit',
ru: 'Яркость',
pt: 'Brilho',
nl: 'Helderheid',
fr: 'Luminosité',
it: 'Luminosità',
es: 'Brillo',
pl: 'Jasność',
'zh-cn': '亮度',
},
type: 'number',
role: 'level.brightness',
read: true,
write: true,
min: 0,
max: 100,
unit: '%',
},
};
deviceObj[`CCT${cctId}.ColorTemperature`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).ct,
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.Set',
params: { id: cctId, ct: value },
});
},
},
common: {
name: {
en: 'Color Temperature',
de: 'Farbtemperatur',
ru: 'Цветовая температура',
pt: 'Temperatura de cor',
nl: 'Kleurtemperatuur',
fr: 'Température de couleur',
it: 'Temperatura del colore',
es: 'Temperatura de color',
pl: 'Temperatura barwowa',
uk: 'Колірна температура',
'zh-cn': '色温',
},
type: 'number',
role: 'level.color.temperature',
read: true,
write: true,
unit: 'K',
},
};
deviceObj[`CCT${cctId}.source`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).source,
},
common: {
name: {
en: 'Source of last command',
de: 'Quelle des letzten Befehls',
ru: 'Источник последней команды',
pt: 'Fonte do último comando',
nl: 'Bron van laatste opdracht',
fr: 'Source de la dernière commande',
it: "Fonte dell'ultimo comando",
es: 'Fuente del último comando',
pl: 'Źródło ostatniego dowództwa',
uk: 'Джерело останньої команди',
'zh-cn': '最后一次指挥的来源',
},
type: 'string',
role: 'text',
read: true,
write: false,
},
};
deviceObj[`CCT${cctId}.Event`] = {
mqtt: {
mqtt_publish: '<mqttprefix>/events/rpc',
mqtt_publish_funct: value => {
const valueObj = JSON.parse(value);
if (valueObj?.method === 'NotifyEvent' && valueObj?.params?.events) {
for (const e in valueObj.params.events) {
const event = valueObj.params.events[e];
if (typeof event === 'object' && event.component === `cct:${cctId}`) {
return event.event;
}
}
}
return undefined;
},
},
common: {
name: {
en: 'CCT Event',
de: 'CCT-Ereignis',
ru: 'CCT-событие',
pt: 'Evento CCT',
nl: 'CCT-gebeurtenis',
fr: 'Événement CCT',
it: 'Evento CCT',
es: 'Evento CCT',
pl: 'Wydarzenie CCT',
uk: 'Подія CCT',
'zh-cn': 'CCT 事件',
},
type: 'string',
role: 'state',
read: true,
write: false,
},
};
deviceObj[`CCT${cctId}.TimerStartedAt`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).timer_started_at,
},
common: {
name: {
en: 'Start time of the timer',
de: 'Startzeit des Timers',
ru: 'Время начала таймера',
pt: 'Hora de início do cronômetro',
nl: 'Starttijd van de timer',
fr: 'Heure de début du minuteur',
it: 'Ora di inizio del timer',
es: 'Hora de inicio del temporizador',
pl: 'Czas rozpoczęcia timera',
uk: 'Час запуску таймера',
'zh-cn': '计时器的开始时间',
},
type: 'number',
role: 'date',
read: true,
write: false,
},
};
deviceObj[`CCT${cctId}.TimerDuration`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).timer_duration,
},
common: {
name: {
en: 'Duration of the timer',
de: 'Dauer des Timers',
ru: 'Длительность таймера',
pt: 'Duração do temporizador',
nl: 'Duur van de timer',
fr: 'Durée du minuteur',
it: 'Durata del timer',
es: 'Duración del temporizador',
pl: 'Czas trwania timera',
uk: 'Тривалість таймера',
'zh-cn': '计时器持续时间',
},
type: 'number',
role: 'value.timer',
read: true,
write: false,
def: 0,
unit: 's',
},
};
deviceObj[`CCT${cctId}.Transition_Output`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).transition?.target?.output,
},
common: {
name: {
en: 'Target output state',
de: 'Ziel-Ausgangszustand',
ru: 'Целевое состояние выхода',
pt: 'Estado de saída alvo',
nl: 'Doeluitgangsstatus',
fr: 'État de sortie cible',
it: 'Stato di uscita di destinazione',
es: 'Estado de salida objetivo',
pl: 'Docelowy stan wyjścia',
uk: 'Цільовий стан виходу',
'zh-cn': '目标输出状态',
},
type: 'boolean',
role: 'sensor.switch',
read: true,
write: false,
},
};
deviceObj[`CCT${cctId}.Transition_Brightness`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).transition?.target?.brightness,
},
common: {
name: {
en: 'Target brightness',
de: 'Zielhelligkeit',
ru: 'Целевая яркость',
pt: 'Brilho alvo',
nl: 'Doelhelderheid',
fr: 'Luminosité cible',
it: 'Luminosità target',
es: 'Brillo objetivo',
pl: 'Docelowa jasność',
uk: 'Цільова яскравість',
'zh-cn': '目标亮度',
},
type: 'number',
role: 'level.brightness',
read: true,
write: false,
min: 0,
max: 100,
unit: '%',
},
};
deviceObj[`CCT${cctId}.Transition_ColorTemperature`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).transition?.target?.ct,
},
common: {
name: {
en: 'Target color temperature',
de: 'Ziel-Farbtemperatur',
ru: 'Целевая цветовая температура',
pt: 'Temperatura de cor alvo',
nl: 'Doelkleurtemperatuur',
fr: 'Température de couleur cible',
it: 'Temperatura del colore target',
es: 'Temperatura de color objetivo',
pl: 'Docelowa temperatura barwowa',
uk: 'Цільова колірна температура',
'zh-cn': '目标色温',
},
type: 'number',
role: 'level.color.temperature',
read: true,
write: false,
unit: 'K',
},
};
deviceObj[`CCT${cctId}.Transition_StartedAt`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).transition?.started_at,
},
common: {
name: {
en: 'Start time of transition',
de: 'Startzeit des Übergangs',
ru: 'Время начала перехода',
pt: 'Horário de início da transição',
nl: 'Begintijd van de overgang',
fr: 'Début de la transition',
it: 'Ora di inizio della transizione',
es: 'Hora de inicio de la transición',
pl: 'Czas rozpoczęcia przejścia',
uk: 'Час початку переходу',
'zh-cn': '过渡开始时间',
},
type: 'number',
role: 'date',
read: true,
write: false,
},
};
deviceObj[`CCT${cctId}.Transition_Duration`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).transition?.duration,
},
common: {
name: {
en: 'Duration of transition',
de: 'Dauer des Übergangs',
ru: 'Продолжительность перехода',
pt: 'Duração da transição',
nl: 'Duur van de overgang',
fr: 'Durée de la transition',
it: 'Durata della transizione',
es: 'Duración de la transición',
pl: 'Czas trwania przejścia',
uk: 'Тривалість переходу',
'zh-cn': '过渡期持续时间',
},
type: 'number',
role: 'value.timer',
read: true,
write: false,
def: 0,
unit: 's',
},
};
deviceObj[`CCT${cctId}.temperatureC`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).temperature?.tC,
},
common: {
name: {
en: 'Temperature',
de: 'Temperatur',
ru: 'Температура',
pt: 'Temperatura',
nl: 'Temperatuur',
fr: 'Température',
it: 'Temperatura',
es: 'Temperatura',
pl: 'Temperatura',
uk: 'Температура',
'zh-cn': '温度',
},
type: 'number',
role: 'value.temperature',
read: true,
write: false,
unit: '°C',
},
};
deviceObj[`CCT${cctId}.temperatureF`] = {
mqtt: {
mqtt_publish: `<mqttprefix>/status/cct:${cctId}`,
mqtt_publish_funct: value => JSON.parse(value).temperature?.tF,
},
common: {
name: {
en: 'Temperature',
de: 'Temperatur',
ru: 'Температура',
pt: 'Temperatura',
nl: 'Temperatuur',
fr: 'Température',
it: 'Temperatura',
es: 'Temperatura',
pl: 'Temperatura',
uk: 'Температура',
'zh-cn': '温度',
},
type: 'number',
role: 'value.temperature',
read: true,
write: false,
unit: '°F',
},
};
deviceObj[`CCT${cctId}.InitialState`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).initial_state : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { initial_state: value } },
});
},
},
common: {
name: {
en: 'Initial State',
de: 'Initialer Zustand',
ru: 'Начальное состояние',
pt: 'Estado Inicial',
nl: 'Initiële staat',
fr: 'État initial',
it: 'Stato iniziale',
es: 'Estado inicial',
pl: 'Stan początkowy',
uk: 'Початковий стан',
'zh-cn': '初始状态',
},
type: 'string',
role: 'state',
read: true,
write: true,
states: {
on: 'on',
off: 'off',
restore_last: 'restore_last',
},
},
};
deviceObj[`CCT${cctId}.AutoTimerOn`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).auto_on : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { auto_on: value } },
});
},
},
common: {
name: {
en: 'Auto Timer On',
de: 'Automatischer Timer ein',
ru: 'Автоматический таймер включен',
pt: 'Temporizador automático ligado',
nl: 'Automatische timer aan',
fr: 'Activation automatique de la minuterie',
it: 'Timer automatico acceso',
es: 'Temporizador automático activado',
pl: 'Włączanie automatycznego timera',
uk: 'Автоматичний таймер увімкнено',
'zh-cn': '自动定时器开启',
},
type: 'boolean',
role: 'switch.enable',
def: false,
read: true,
write: true,
},
};
deviceObj[`CCT${cctId}.AutoTimerOnDelay`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).auto_on_delay : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { auto_on_delay: value } },
});
},
},
common: {
name: {
en: 'Auto Timer On Delay',
de: 'Automatischer Timer Einschaltverzögerung',
ru: 'Автоматический таймер задержки включения',
pt: 'Temporizador automático com atraso',
nl: 'Automatische timer bij vertraging',
fr: 'Temporisation de mise en marche automatique',
it: 'Ritardo di accensione del timer automatico',
es: 'Temporizador automático con retardo de activación',
pl: 'Opóźnienie automatycznego włączania timera',
uk: 'Автоматична затримка ввімкнення таймера',
'zh-cn': '自动定时器开启延迟',
},
type: 'number',
role: 'level.timer',
def: 0,
unit: 's',
read: true,
write: true,
},
};
deviceObj[`CCT${cctId}.AutoTimerOff`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).auto_off : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { auto_off: value } },
});
},
},
common: {
name: {
en: 'Auto Timer Off',
de: 'Automatischer Timer Aus',
ru: 'Автоматическое выключение таймера',
pt: 'Temporizador automático desligado',
nl: 'Automatische timer uit',
fr: 'Arrêt automatique de la minuterie',
it: 'Spegnimento automatico del timer',
es: 'Apagado automático del temporizador',
pl: 'Automatyczne wyłączanie timera',
uk: 'Автоматичне вимкнення таймера',
'zh-cn': '自动定时器关闭',
},
type: 'boolean',
role: 'switch.enable',
def: false,
read: true,
write: true,
},
};
deviceObj[`CCT${cctId}.AutoTimerOffDelay`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).auto_off_delay : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { auto_off_delay: value } },
});
},
},
common: {
name: {
en: 'Auto Timer Off Delay',
de: 'Automatischer Timer Ausschaltverzögerung',
ru: 'Автоматический таймер задержки выключения',
pt: 'Temporizador automático com atraso de desligamento',
nl: 'Automatische timer uitschakelvertraging',
fr: "Temporisation d'arrêt automatique",
it: 'Ritardo di spegnimento del timer automatico',
es: 'Temporizador automático con retardo de apagado',
pl: 'Opóźnienie automatycznego wyłączania timera',
uk: 'Автоматична затримка вимкнення таймера',
'zh-cn': '自动定时器关闭延迟',
},
type: 'number',
role: 'level.timer',
def: 0,
unit: 's',
read: true,
write: true,
},
};
deviceObj[`CCT${cctId}.TransitionDuration`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).transition_duration : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { transition_duration: value } },
});
},
},
common: {
name: {
en: 'Transition Duration',
de: 'Übergangsdauer',
ru: 'Продолжительность перехода',
pt: 'Duração da transição',
nl: 'Overgangsduur',
fr: 'Durée de la transition',
it: 'Durata della transizione',
es: 'Duración de la transición',
pl: 'Czas trwania przejścia',
uk: 'Тривалість переходу',
'zh-cn': '过渡持续时间',
},
type: 'number',
role: 'level.timer',
def: 0,
unit: 's',
read: true,
write: true,
},
};
deviceObj[`CCT${cctId}.MinBrightnessOnToggle`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).min_brightness_on_toggle : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { min_brightness_on_toggle: value } },
});
},
},
common: {
name: {
en: 'Min Brightness on Toggle',
de: 'Mindesthelligkeit beim Umschalten',
ru: 'Минимальная яркость при переключении',
pt: 'Brilho mínimo ao alternar',
nl: 'Minimale helderheid bij schakelen',
fr: 'Luminosité minimale lors du basculement',
it: 'Luminosità minima alla commutazione',
es: 'Brillo mínimo al alternar',
pl: 'Minimalna jasność przy przełączaniu',
uk: 'Мінімальна яскравість при перемиканні',
'zh-cn': '切换时最小亮度',
},
type: 'number',
role: 'level.brightness',
read: true,
write: true,
min: 0,
max: 100,
unit: '%',
},
};
// ----------
// ATTENTION:
// ----------
//
// Night mode requires firmware 2.x.x - otherwise device might be damaged
// ----------------------------------------------------------------------
//
// deviceObj[`CCT${cctId}.NightModeEnable`] = {
// mqtt: {
// http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
// http_publish_funct: value => (value ? JSON.parse(value).night_mode?.enable : undefined),
// mqtt_cmd: '<mqttprefix>/rpc',
// mqtt_cmd_funct: (value, self) => {
// return JSON.stringify({
// id: self.getNextMsgId(),
// src: 'iobroker',
// method: 'CCT.SetConfig',
// params: { id: cctId, config: { night_mode: { enable: value } } },
// });
// },
// },
// common: {
// name: {
// en: 'Night Mode Enable',
// de: 'Nachtmodus aktivieren',
// ru: 'Включить ночной режим',
// pt: 'Ativar modo noturno',
// nl: 'Nachtmodus inschakelen',
// fr: 'Activer le mode nuit',
// it: 'Abilita modalità notte',
// es: 'Activar modo nocturno',
// pl: 'Włącz tryb nocny',
// uk: 'Увімкнути нічний режим',
// 'zh-cn': '启用夜间模式',
// },
// type: 'boolean',
// role: 'switch.enable',
// def: false,
// read: true,
// write: true,
// },
// };
// deviceObj[`CCT${cctId}.NightModeBrightness`] = {
// mqtt: {
// http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
// http_publish_funct: value => (value ? JSON.parse(value).night_mode?.brightness : undefined),
// mqtt_cmd: '<mqttprefix>/rpc',
// mqtt_cmd_funct: (value, self) => {
// return JSON.stringify({
// id: self.getNextMsgId(),
// src: 'iobroker',
// method: 'CCT.SetConfig',
// params: { id: cctId, config: { night_mode: { brightness: value } } },
// });
// },
// },
// common: {
// name: {
// en: 'Night Mode Brightness',
// de: 'Nachtmodus Helligkeit',
// ru: 'Яркость ночного режима',
// pt: 'Brilho do modo noturno',
// nl: 'Nachtmodus helderheid',
// fr: 'Luminosité du mode nuit',
// it: 'Luminosità modalità notte',
// es: 'Brillo del modo nocturno',
// pl: 'Jasność trybu nocnego',
// uk: 'Яскравість нічного режиму',
// 'zh-cn': '夜间模式亮度',
// },
// type: 'number',
// role: 'level.brightness',
// read: true,
// write: true,
// min: 0,
// max: 100,
// unit: '%',
// },
// };
// deviceObj[`CCT${cctId}.NightModeColorTemperature`] = {
// mqtt: {
// http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
// http_publish_funct: value => (value ? JSON.parse(value).night_mode?.ct : undefined),
// mqtt_cmd: '<mqttprefix>/rpc',
// mqtt_cmd_funct: (value, self) => {
// return JSON.stringify({
// id: self.getNextMsgId(),
// src: 'iobroker',
// method: 'CCT.SetConfig',
// params: { id: cctId, config: { night_mode: { ct: value } } },
// });
// },
// },
// common: {
// name: {
// en: 'Night Mode Color Temperature',
// de: 'Nachtmodus Farbtemperatur',
// ru: 'Цветовая температура ночного режима',
// pt: 'Temperatura de cor do modo noturno',
// nl: 'Nachtmodus kleurtemperatuur',
// fr: 'Température de couleur du mode nuit',
// it: 'Temperatura colore modalità notte',
// es: 'Temperatura de color del modo nocturno',
// pl: 'Temperatura barwowa trybu nocnego',
// uk: 'Колірна температура нічного режиму',
// 'zh-cn': '夜间模式色温',
// },
// type: 'number',
// role: 'level.color.temperature',
// read: true,
// write: true,
// unit: 'K',
// },
// };
deviceObj[`CCT${cctId}.ButtonFadeRate`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).button_fade_rate : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { button_fade_rate: value } },
});
},
},
common: {
name: {
en: 'Button Fade Rate',
de: 'Tastenabblendrate',
ru: 'Скорость затухания кнопки',
pt: 'Taxa de esvanecimento do botão',
nl: 'Knop vervagingssnelheid',
fr: 'Taux de fondu du bouton',
it: 'Velocità di dissolvenza del pulsante',
es: 'Tasa de atenuación del botón',
pl: 'Szybkość zanikania przycisku',
uk: 'Швидкість згасання кнопки',
'zh-cn': '按钮淡出速率',
},
type: 'number',
role: 'level',
read: true,
write: true,
min: 1,
max: 5,
},
};
deviceObj[`CCT${cctId}.ButtonDoublePushBrightness`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value =>
value ? JSON.parse(value).button_presets?.button_doublepush?.brightness : undefined,
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { button_presets: { button_doublepush: { brightness: value } } } },
});
},
},
common: {
name: {
en: 'Button Double Push Brightness',
de: 'Taste Doppeldruck Helligkeit',
ru: 'Яркость двойного нажатия кнопки',
pt: 'Brilho de duplo toque do botão',
nl: 'Knop dubbele druk helderheid',
fr: 'Luminosité du double appui sur le bouton',
it: 'Luminosità doppio tocco pulsante',
es: 'Brillo de doble pulsación del botón',
pl: 'Jasność podwójnego naciśnięcia przycisku',
uk: 'Яскравість подвійного натискання кнопки',
'zh-cn': '按钮双击亮度',
},
type: 'number',
role: 'level.brightness',
read: true,
write: true,
min: 0,
max: 100,
unit: '%',
},
};
deviceObj[`CCT${cctId}.ButtonDoublePushColorTemperature`] = {
mqtt: {
http_publish: `/rpc/CCT.GetConfig?id=${cctId}`,
http_publish_funct: value => (value ? JSON.parse(value).button_presets?.button_doublepush?.ct : undefined),
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.SetConfig',
params: { id: cctId, config: { button_presets: { button_doublepush: { ct: value } } } },
});
},
},
common: {
name: {
en: 'Button Double Push Color Temperature',
de: 'Taste Doppeldruck Farbtemperatur',
ru: 'Цветовая температура двойного нажатия кнопки',
pt: 'Temperatura de cor de duplo toque do botão',
nl: 'Knop dubbele druk kleurtemperatuur',
fr: 'Température de couleur du double appui sur le bouton',
it: 'Temperatura colore doppio tocco pulsante',
es: 'Temperatura de color de doble pulsación del botón',
pl: 'Temperatura barwowa podwójnego naciśnięcia przycisku',
uk: 'Колірна температура подвійного натискання кнопки',
'zh-cn': '按钮双击色温',
},
type: 'number',
role: 'level.color.temperature',
read: true,
write: true,
unit: 'K',
},
};
deviceObj[`CCT${cctId}.Toggle`] = {
mqtt: {
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.Toggle',
params: { id: cctId },
});
},
},
common: {
name: {
en: 'Toggle',
de: 'Umschalten',
ru: 'Переключить',
pt: 'Alternar',
nl: 'Schakelen',
fr: 'Basculer',
it: 'Alternare',
es: 'Alternar',
pl: 'Przełącz',
uk: 'Перемкнути',
'zh-cn': '切换',
},
type: 'boolean',
role: 'button',
read: false,
write: true,
},
};
deviceObj[`CCT${cctId}.DimUp`] = {
mqtt: {
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.DimUp',
params: { id: cctId },
});
},
},
common: {
name: {
en: 'Dim Up',
de: 'Dimmen hoch',
ru: 'Увеличить яркость',
pt: 'Aumentar intensidade',
nl: 'Dimmen omhoog',
fr: 'Augmenter la luminosité',
it: 'Aumenta intensità',
es: 'Aumentar intensidad',
pl: 'Zwiększ jasność',
uk: 'Збільшити яскравість',
'zh-cn': '调亮',
},
type: 'boolean',
role: 'button',
read: false,
write: true,
},
};
deviceObj[`CCT${cctId}.DimDown`] = {
mqtt: {
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.DimDown',
params: { id: cctId },
});
},
},
common: {
name: {
en: 'Dim Down',
de: 'Dimmen runter',
ru: 'Уменьшить яркость',
pt: 'Diminuir intensidade',
nl: 'Dimmen omlaag',
fr: 'Diminuer la luminosité',
it: 'Diminuisci intensità',
es: 'Reducir intensidad',
pl: 'Zmniejsz jasność',
uk: 'Зменшити яскравість',
'zh-cn': '调暗',
},
type: 'boolean',
role: 'button',
read: false,
write: true,
},
};
deviceObj[`CCT${cctId}.DimStop`] = {
mqtt: {
mqtt_cmd: '<mqttprefix>/rpc',
mqtt_cmd_funct: (value, self) => {
return JSON.stringify({
id: self.getNextMsgId(),
src: 'iobroker',
method: 'CCT.DimStop',
params: { id: cctId },
});
},
},
common: {
name: {
en: 'Dim Stop',