iobroker.shelly
Advanced tools
Comparing version 5.1.2 to 5.1.3
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"news": { | ||
"5.1.3": { | ||
"en": "Changed common.states strings to objects\nJust perform firmware update if an available update was detected\nExtended logging for CoAP", | ||
"de": "common.states-Strings in Objekte geändert\nFühren Sie einfach ein Firmware-Update durch, wenn ein verfügbares Update erkannt wurde\nErweiterte Protokollierung für CoAP", | ||
"ru": "Изменены строки common.states на объекты\nПросто выполните обновление прошивки, если было обнаружено доступное обновление.\nРасширенное ведение журнала для CoAP", | ||
"pt": "Strings common.states alteradas para objetos\nBasta realizar a atualização do firmware se uma atualização disponível foi detectada\nRegistro estendido para CoAP", | ||
"nl": "Common.states-tekenreeksen gewijzigd in objecten\nVoer gewoon een firmware-update uit als er een beschikbare update is gedetecteerd\nUitgebreide logging voor CoAP", | ||
"fr": "Modification des chaînes common.states en objets\nEffectuez simplement la mise à jour du micrologiciel si une mise à jour disponible a été détectée\nJournalisation étendue pour CoAP", | ||
"it": "Modificate le stringhe common.states in oggetti\nBasta eseguire l'aggiornamento del firmware se è stato rilevato un aggiornamento disponibile\nRegistrazione estesa per CoAP", | ||
"es": "Se cambiaron las cadenas common.states a objetos.\nSimplemente realice una actualización de firmware si se detectó una actualización disponible\nRegistro extendido para CoAP", | ||
"pl": "Zmieniono ciągi common.states na obiekty\nPo prostu wykonaj aktualizację oprogramowania układowego, jeśli zostanie wykryta dostępna aktualizacja\nRozszerzone logowanie dla CoAP", | ||
"zh-cn": "将 common.states 字符串更改为对象\n如果检测到可用更新,只需执行固件更新\nCoAP 的扩展日志记录" | ||
}, | ||
"5.1.2": { | ||
@@ -77,14 +89,2 @@ "en": "Fixed Shelly UNI ADC voltage\nFixed dimmer brightness values handling\nLogging improvements for offline devices", | ||
"zh-cn": "尝试在适配器停止后防止状态更改" | ||
}, | ||
"4.1.0": { | ||
"en": "several fixes and adjustments\nfix temperature maximum warning\nDestroy Coap and MQTT server on unload", | ||
"de": "mehrere Fixes und Anpassungen\nTemperaturmaximalwarnung fixieren\nZerstöre Coap- und MQTT-Server beim Entladen", | ||
"ru": "несколько исправлений и корректировок\nисправить предупреждение о максимальной температуре\nУничтожить Coap и сервер MQTT при выгрузке", | ||
"pt": "várias correções e ajustes\nfixar aviso de temperatura máxima\nDestrua o servidor Coap e MQTT ao descarregar", | ||
"nl": "verschillende fixes en aanpassingen\nfix temperatuur maximum waarschuwing\nVernietig Coap en MQTT-server bij het verwijderen", | ||
"fr": "plusieurs corrections et ajustements\navertissement maximum de température fixe\nDétruire le serveur Coap et MQTT lors du déchargement", | ||
"it": "diverse correzioni e regolazioni\nfissare l'avviso di temperatura massima\nDistruggi il server Coap e MQTT allo scaricamento", | ||
"es": "varias correcciones y ajustes\nFijar temperatura máxima advertencia\nDestruye Coap y el servidor MQTT al descargar", | ||
"pl": "kilka poprawek i korekt\nnaprawić ostrzeżenie o maksymalnej temperaturze\nZniszcz serwer Coap i MQTT przy rozładowaniu", | ||
"zh-cn": "几个修复和调整\n修复温度最高警告\n卸载时销毁 Coap 和 MQTT 服务器" | ||
} | ||
@@ -91,0 +91,0 @@ }, |
@@ -7,3 +7,3 @@ /** | ||
* https://gist.github.com/mjackson/5311256 | ||
* | ||
* | ||
* @param Number r The red color value | ||
@@ -16,25 +16,25 @@ * @param Number g The green color value | ||
function rgbToHsl(r, g, b) { | ||
r /= 255, g /= 255, b /= 255; | ||
r /= 255, g /= 255, b /= 255; | ||
let max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
let h, s, l = (max + min) / 2; | ||
const max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
let h, s, l = (max + min) / 2; | ||
if (max == min) { | ||
h = s = 0; // achromatic | ||
} else { | ||
let d = max - min; | ||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | ||
if (max == min) { | ||
h = s = 0; // achromatic | ||
} else { | ||
const d = max - min; | ||
s = l > 0.5 ? d / (2 - max - min) : d / (max + min); | ||
switch (max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
switch (max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
} | ||
h /= 6; | ||
} | ||
h /= 6; | ||
} | ||
// return [h, s, l]; | ||
// return [h * 360, s * 100, l * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)]; | ||
// return [h, s, l]; | ||
// return [h * 360, s * 100, l * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)]; | ||
} | ||
@@ -54,22 +54,22 @@ | ||
function hslToRgb(h, s, l) { | ||
h = h / 360; | ||
s = s / 100; | ||
l = l / 100; | ||
h = h / 360; | ||
s = s / 100; | ||
l = l / 100; | ||
let r, g, b; | ||
let r, g, b; | ||
if (s == 0) { | ||
r = g = b = l; // achromatic | ||
} else { | ||
if (s == 0) { | ||
r = g = b = l; // achromatic | ||
} else { | ||
let q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
let p = 2 * l - q; | ||
const q = l < 0.5 ? l * (1 + s) : l + s - l * s; | ||
const p = 2 * l - q; | ||
r = hue2rgb(p, q, h + 1 / 3); | ||
g = hue2rgb(p, q, h); | ||
b = hue2rgb(p, q, h - 1 / 3); | ||
} | ||
r = hue2rgb(p, q, h + 1 / 3); | ||
g = hue2rgb(p, q, h); | ||
b = hue2rgb(p, q, h - 1 / 3); | ||
} | ||
// return [r * 255, g * 255, b * 255]; | ||
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; | ||
// return [r * 255, g * 255, b * 255]; | ||
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; | ||
} | ||
@@ -89,25 +89,25 @@ | ||
function rgbToHsv(r, g, b) { | ||
r /= 255, g /= 255, b /= 255; | ||
r /= 255, g /= 255, b /= 255; | ||
let max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
let h, s, v = max; | ||
const max = Math.max(r, g, b), min = Math.min(r, g, b); | ||
let h, s, v = max; | ||
let d = max - min; | ||
s = max == 0 ? 0 : d / max; | ||
const d = max - min; | ||
s = max == 0 ? 0 : d / max; | ||
if (max == min) { | ||
h = 0; // achromatic | ||
} else { | ||
switch (max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
if (max == min) { | ||
h = 0; // achromatic | ||
} else { | ||
switch (max) { | ||
case r: h = (g - b) / d + (g < b ? 6 : 0); break; | ||
case g: h = (b - r) / d + 2; break; | ||
case b: h = (r - g) / d + 4; break; | ||
} | ||
h /= 6; | ||
} | ||
h /= 6; | ||
} | ||
// return [h, s, v]; | ||
// return [h * 360, s * 100, v * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(v * 100)]; | ||
// return [h, s, v]; | ||
// return [h * 360, s * 100, v * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(v * 100)]; | ||
} | ||
@@ -127,46 +127,46 @@ | ||
function hsvToRgb(h, s, v) { | ||
h = h / 360; | ||
s = s / 100; | ||
v = v / 100; | ||
h = h / 360; | ||
s = s / 100; | ||
v = v / 100; | ||
let r, g, b; | ||
let i = Math.floor(h * 6); | ||
let f = h * 6 - i; | ||
let p = v * (1 - s); | ||
let q = v * (1 - f * s); | ||
let t = v * (1 - (1 - f) * s); | ||
let r, g, b; | ||
const i = Math.floor(h * 6); | ||
const f = h * 6 - i; | ||
const p = v * (1 - s); | ||
const q = v * (1 - f * s); | ||
const t = v * (1 - (1 - f) * s); | ||
switch (i % 6) { | ||
case 0: r = v, g = t, b = p; break; | ||
case 1: r = q, g = v, b = p; break; | ||
case 2: r = p, g = v, b = t; break; | ||
case 3: r = p, g = q, b = v; break; | ||
case 4: r = t, g = p, b = v; break; | ||
case 5: r = v, g = p, b = q; break; | ||
} | ||
switch (i % 6) { | ||
case 0: r = v, g = t, b = p; break; | ||
case 1: r = q, g = v, b = p; break; | ||
case 2: r = p, g = v, b = t; break; | ||
case 3: r = p, g = q, b = v; break; | ||
case 4: r = t, g = p, b = v; break; | ||
case 5: r = v, g = p, b = q; break; | ||
} | ||
// return [r * 255, g * 255, b * 255]; | ||
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; | ||
// return [r * 255, g * 255, b * 255]; | ||
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; | ||
} | ||
/** | ||
* | ||
* @param {*} p | ||
* @param {*} q | ||
* @param {*} t | ||
* | ||
* @param {*} p | ||
* @param {*} q | ||
* @param {*} t | ||
*/ | ||
function hue2rgb(p, q, t) { | ||
if (t < 0) t += 1; | ||
if (t > 1) t -= 1; | ||
if (t < 1 / 6) return p + (q - p) * 6 * t; | ||
if (t < 1 / 2) return q; | ||
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; | ||
return p; | ||
if (t < 0) t += 1; | ||
if (t > 1) t -= 1; | ||
if (t < 1 / 6) return p + (q - p) * 6 * t; | ||
if (t < 1 / 2) return q; | ||
if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6; | ||
return p; | ||
} | ||
module.exports = { | ||
rgbToHsl, | ||
hslToRgb, | ||
rgbToHsv, | ||
hsvToRgb | ||
rgbToHsl, | ||
hslToRgb, | ||
rgbToHsv, | ||
hsvToRgb | ||
}; |
@@ -49,108 +49,108 @@ /* jshint -W097 */ | ||
let devices = { | ||
'shellyswitch': shellyswitch, | ||
'shellyswitch25': shellyswitch25, | ||
'shelly1': shelly1, | ||
'shelly1pm': shelly1pm, | ||
'shelly1l': shelly1l, | ||
'shellyht': shellyht, | ||
'shellysmoke': shellysmoke, | ||
'shellybulb': shellybulb, | ||
'shellyrgbww': shellyrgbww, | ||
'shellyrgbw2': shellyrgbw2, | ||
'shelly2led': shelly2led, | ||
'shellyplug': shellyplug, | ||
'shelly4pro': shelly4pro, | ||
'shellysense': shellysense, | ||
'shellyplug-s': shellyplugs, | ||
'shellyem': shellyem, | ||
'shellyem3': shellyem3, | ||
'shellyflood': shellyflood, | ||
'shellydimmer': shellydimmer, | ||
'shellydw': shellydw, | ||
'shellydw2': shellydw2, | ||
'ShellyBulbDuo': shellybulbduo, | ||
'ShellyVintage': shellyvintage, | ||
'shellyix3': shellyix3, | ||
'shellybutton1': shellybutton1, | ||
'shellygas': shellygas, | ||
'shellydimmer2': shellydimmer2, | ||
'shellyuni': shellyuni, | ||
'shellycolorbulb': shellycolorbulb, | ||
'shellymotionsensor': shellymotionsensor, | ||
'shellyplus1': shellyplus1, | ||
'shellyplus1pm': shellyplus1pm, | ||
'shellypro4pm': shellypro4pm | ||
const devices = { | ||
'shellyswitch': shellyswitch, | ||
'shellyswitch25': shellyswitch25, | ||
'shelly1': shelly1, | ||
'shelly1pm': shelly1pm, | ||
'shelly1l': shelly1l, | ||
'shellyht': shellyht, | ||
'shellysmoke': shellysmoke, | ||
'shellybulb': shellybulb, | ||
'shellyrgbww': shellyrgbww, | ||
'shellyrgbw2': shellyrgbw2, | ||
'shelly2led': shelly2led, | ||
'shellyplug': shellyplug, | ||
'shelly4pro': shelly4pro, | ||
'shellysense': shellysense, | ||
'shellyplug-s': shellyplugs, | ||
'shellyem': shellyem, | ||
'shellyem3': shellyem3, | ||
'shellyflood': shellyflood, | ||
'shellydimmer': shellydimmer, | ||
'shellydw': shellydw, | ||
'shellydw2': shellydw2, | ||
'ShellyBulbDuo': shellybulbduo, | ||
'ShellyVintage': shellyvintage, | ||
'shellyix3': shellyix3, | ||
'shellybutton1': shellybutton1, | ||
'shellygas': shellygas, | ||
'shellydimmer2': shellydimmer2, | ||
'shellyuni': shellyuni, | ||
'shellycolorbulb': shellycolorbulb, | ||
'shellymotionsensor': shellymotionsensor, | ||
'shellyplus1': shellyplus1, | ||
'shellyplus1pm': shellyplus1pm, | ||
'shellypro4pm': shellypro4pm | ||
}; | ||
let devicenames = { | ||
'shellyswitch': ['SHSW-21'], | ||
'shellyswitch25': ['SHSW-25'], | ||
'shelly1': ['SHSW-1'], | ||
'shelly1pm': ['SHSW-PM'], | ||
'shelly1l': ['SHSW-L'], | ||
'shellyht': ['SHHT-1'], | ||
'shellysmoke': ['SHSM-01'], | ||
'shellybulb': ['SHBLB-1'], | ||
// 'shellyrgbww': ['SHRGBWW-01'], | ||
'shellyrgbw2': ['SHRGBW2'], | ||
'shelly2led': ['SH2LED'], | ||
'shellyplug': ['SHPLG-1'], | ||
'shelly4pro': ['SHSW-44'], | ||
'shellysense': ['SHSEN-1'], | ||
'shellyplug-s': ['SHPLG-S', 'SHPLG2-1'], | ||
'shellyem': ['SHEM'], | ||
'shellyem3': ['SHEM-3'], | ||
'shellyflood': ['SHWT-1'], | ||
'shellydimmer': ['SHDM-1'], | ||
'shellydw': ['SHDW-1'], | ||
'shellydw2': ['SHDW-2'], | ||
'ShellyBulbDuo': ['SHBDUO-1'], | ||
'ShellyVintage': ['SHVIN-1'], | ||
'shellyix3': ['SHIX3-1'], | ||
'shellybutton1': ['SHBTN-1', 'SHBTN-2'], | ||
'shellygas': ['SHGS-1'], | ||
'shellydimmer2': ['SHDM-2'], | ||
'shellyuni': ['SHUNI-1'], | ||
'shellycolorbulb': ['SHCB-1'], | ||
'shellymotionsensor': ['SHMOS-01'], | ||
'shellyplus1': ['shellyplus1'], | ||
'shellyplus1pm': ['shellyplus1pm'], | ||
'shellypro4pm': ['shellypro4pm'] | ||
const devicenames = { | ||
'shellyswitch': ['SHSW-21'], | ||
'shellyswitch25': ['SHSW-25'], | ||
'shelly1': ['SHSW-1'], | ||
'shelly1pm': ['SHSW-PM'], | ||
'shelly1l': ['SHSW-L'], | ||
'shellyht': ['SHHT-1'], | ||
'shellysmoke': ['SHSM-01'], | ||
'shellybulb': ['SHBLB-1'], | ||
// 'shellyrgbww': ['SHRGBWW-01'], | ||
'shellyrgbw2': ['SHRGBW2'], | ||
'shelly2led': ['SH2LED'], | ||
'shellyplug': ['SHPLG-1'], | ||
'shelly4pro': ['SHSW-44'], | ||
'shellysense': ['SHSEN-1'], | ||
'shellyplug-s': ['SHPLG-S', 'SHPLG2-1'], | ||
'shellyem': ['SHEM'], | ||
'shellyem3': ['SHEM-3'], | ||
'shellyflood': ['SHWT-1'], | ||
'shellydimmer': ['SHDM-1'], | ||
'shellydw': ['SHDW-1'], | ||
'shellydw2': ['SHDW-2'], | ||
'ShellyBulbDuo': ['SHBDUO-1'], | ||
'ShellyVintage': ['SHVIN-1'], | ||
'shellyix3': ['SHIX3-1'], | ||
'shellybutton1': ['SHBTN-1', 'SHBTN-2'], | ||
'shellygas': ['SHGS-1'], | ||
'shellydimmer2': ['SHDM-2'], | ||
'shellyuni': ['SHUNI-1'], | ||
'shellycolorbulb': ['SHCB-1'], | ||
'shellymotionsensor': ['SHMOS-01'], | ||
'shellyplus1': ['shellyplus1'], | ||
'shellyplus1pm': ['shellyplus1pm'], | ||
'shellypro4pm': ['shellypro4pm'] | ||
}; | ||
let devicesgen = { | ||
'shellyswitch': 1, | ||
'shellyswitch25': 1, | ||
'shelly1': 1, | ||
'shelly1pm': 1, | ||
'shelly1l': 1, | ||
'shellyht': 1, | ||
'shellysmoke': 1, | ||
'shellybulb': 1, | ||
// 'shellyrgbww': 1, | ||
'shellyrgbw2': 1, | ||
'shelly2led': 1, | ||
'shellyplug': 1, | ||
'shelly4pro': 1, | ||
'shellysense': 1, | ||
'shellyplug-s': 1, | ||
'shellyem': 1, | ||
'shellyem3': 1, | ||
'shellyflood': 1, | ||
'shellydimmer': 1, | ||
'shellydw': 1, | ||
'shellydw2': 1, | ||
'ShellyBulbDuo': 1, | ||
'ShellyVintage': 1, | ||
'shellyix3': 1, | ||
'shellybutton1': 1, | ||
'shellygas': 1, | ||
'shellydimmer2': 1, | ||
'shellyuni': 1, | ||
'shellycolorbulb': 1, | ||
'shellymotionsensor': 1, | ||
'shellyplus1': 2, | ||
'shellyplus1pm': 2, | ||
'shellypro4pm': 2 | ||
const devicesgen = { | ||
'shellyswitch': 1, | ||
'shellyswitch25': 1, | ||
'shelly1': 1, | ||
'shelly1pm': 1, | ||
'shelly1l': 1, | ||
'shellyht': 1, | ||
'shellysmoke': 1, | ||
'shellybulb': 1, | ||
// 'shellyrgbww': 1, | ||
'shellyrgbw2': 1, | ||
'shelly2led': 1, | ||
'shellyplug': 1, | ||
'shelly4pro': 1, | ||
'shellysense': 1, | ||
'shellyplug-s': 1, | ||
'shellyem': 1, | ||
'shellyem3': 1, | ||
'shellyflood': 1, | ||
'shellydimmer': 1, | ||
'shellydw': 1, | ||
'shellydw2': 1, | ||
'ShellyBulbDuo': 1, | ||
'ShellyVintage': 1, | ||
'shellyix3': 1, | ||
'shellybutton1': 1, | ||
'shellygas': 1, | ||
'shellydimmer2': 1, | ||
'shellyuni': 1, | ||
'shellycolorbulb': 1, | ||
'shellymotionsensor': 1, | ||
'shellyplus1': 2, | ||
'shellyplus1pm': 2, | ||
'shellypro4pm': 2 | ||
}; | ||
@@ -161,11 +161,11 @@ | ||
*/ | ||
let polltime = { | ||
'shellysmoke': 3600, | ||
'shellysense': 3600, | ||
'shellyflood': 3600, | ||
'shellydw': 3600, | ||
'shellydw2': 3600, | ||
'shellybutton1': 3600, | ||
'shellygas': 3600, | ||
'shellymotionsensor': 3600 | ||
const polltime = { | ||
'shellysmoke': 3600, | ||
'shellysense': 3600, | ||
'shellyflood': 3600, | ||
'shellydw': 3600, | ||
'shellydw2': 3600, | ||
'shellybutton1': 3600, | ||
'shellygas': 3600, | ||
'shellymotionsensor': 3600 | ||
}; | ||
@@ -175,88 +175,88 @@ | ||
* Copy an object | ||
* @param {*} obj | ||
* @param {*} obj | ||
*/ | ||
function clone(obj) { | ||
if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) | ||
return obj; | ||
let temp; | ||
if (obj instanceof Date) | ||
temp = new obj.constructor(); //or new Date(obj); | ||
else | ||
temp = obj.constructor(); | ||
for (let key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
obj['isActiveClone'] = null; | ||
temp[key] = clone(obj[key]); | ||
delete obj['isActiveClone']; | ||
if (obj === null || typeof (obj) !== 'object' || 'isActiveClone' in obj) | ||
return obj; | ||
let temp; | ||
if (obj instanceof Date) | ||
temp = new obj.constructor(); //or new Date(obj); | ||
else | ||
temp = obj.constructor(); | ||
for (const key in obj) { | ||
if (Object.prototype.hasOwnProperty.call(obj, key)) { | ||
obj['isActiveClone'] = null; | ||
temp[key] = clone(obj[key]); | ||
delete obj['isActiveClone']; | ||
} | ||
} | ||
} | ||
return temp; | ||
return temp; | ||
} | ||
function deleteNoDisplay(device, protocol) { | ||
if (protocol === 'coap' || protocol === 'mqtt') { | ||
for (let key in device) { | ||
let dev = device[key]; | ||
if (protocol === 'coap' && dev.coap && dev.coap.no_display) { | ||
delete device[key]; | ||
continue; | ||
} | ||
if (protocol === 'mqtt' && dev.mqtt && dev.mqtt.no_display) { | ||
delete device[key]; | ||
continue; | ||
} | ||
if (protocol === 'coap' || protocol === 'mqtt') { | ||
for (const key in device) { | ||
const dev = device[key]; | ||
if (protocol === 'coap' && dev.coap && dev.coap.no_display) { | ||
delete device[key]; | ||
continue; | ||
} | ||
if (protocol === 'mqtt' && dev.mqtt && dev.mqtt.no_display) { | ||
delete device[key]; | ||
continue; | ||
} | ||
} | ||
} | ||
} | ||
return device; | ||
return device; | ||
} | ||
function getAll(protocol) { | ||
let cdevices = clone(devices); | ||
if (protocol === 'coap' || protocol === 'mqtt') { | ||
for (let key in cdevices) { | ||
cdevices[key] = deleteNoDisplay(cdevices[key], protocol); | ||
const cdevices = clone(devices); | ||
if (protocol === 'coap' || protocol === 'mqtt') { | ||
for (const key in cdevices) { | ||
cdevices[key] = deleteNoDisplay(cdevices[key], protocol); | ||
} | ||
} | ||
} | ||
return cdevices; | ||
return cdevices; | ||
} | ||
function getDeviceByType(type, protocol) { | ||
if (!devices[type]) return; | ||
if (!devices[type]) return; | ||
let device; | ||
let device; | ||
if (getDeviceGen(type) == 2) { | ||
device = clone(Object.assign(devices[type], defaultsgen2)); | ||
} else { | ||
device = clone(Object.assign(devices[type], defaultsgen1)); | ||
} | ||
if (getDeviceGen(type) == 2) { | ||
device = clone(Object.assign(devices[type], defaultsgen2)); | ||
} else { | ||
device = clone(Object.assign(devices[type], defaultsgen1)); | ||
} | ||
device = deleteNoDisplay(device, protocol); | ||
return device; | ||
device = deleteNoDisplay(device, protocol); | ||
return device; | ||
} | ||
function getDeviceNameForMQTT(name) { | ||
return devicenames[name] ? devicenames[name][0] : undefined; | ||
return devicenames[name] ? devicenames[name][0] : undefined; | ||
} | ||
function getDeviceNameForCoAP(name) { | ||
let value = Object.keys(devicenames).find((key) => devicenames[key].indexOf(name) !== -1); | ||
return value; | ||
const value = Object.keys(devicenames).find((key) => devicenames[key].indexOf(name) !== -1); | ||
return value; | ||
} | ||
function getDeviceGen(type) { | ||
return devicesgen[type] ? devicesgen[type] : 1; | ||
return devicesgen[type] ? devicesgen[type] : 1; | ||
} | ||
function getPolltime(name) { | ||
return polltime[name]; | ||
return polltime[name]; | ||
} | ||
module.exports = { | ||
getAll: getAll, | ||
getDeviceNameForMQTT: getDeviceNameForMQTT, | ||
getDeviceNameForCoAP: getDeviceNameForCoAP, | ||
getDeviceGen: getDeviceGen, | ||
getDeviceByType: getDeviceByType, | ||
getPolltime: getPolltime | ||
getAll: getAll, | ||
getDeviceNameForMQTT: getDeviceNameForMQTT, | ||
getDeviceNameForCoAP: getDeviceNameForCoAP, | ||
getDeviceGen: getDeviceGen, | ||
getDeviceByType: getDeviceByType, | ||
getPolltime: getPolltime | ||
}; |
@@ -14,219 +14,219 @@ /* jshint -W097 */ | ||
*/ | ||
let defaultsgen1 = { | ||
'gen': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceGen(); } | ||
const defaultsgen1 = { | ||
'gen': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceGen(); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceGen(); } | ||
}, | ||
common: { | ||
'name': 'Device generation', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceGen(); } | ||
'online': { | ||
coap: { | ||
}, | ||
mqtt: { | ||
}, | ||
common: { | ||
'name': 'Online', | ||
'type': 'boolean', | ||
'role': 'indicator.reachable', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device generation', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'online': { | ||
coap: { | ||
'firmware': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { | ||
return value ? JSON.parse(value).update.has_update : undefined; | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/announce', | ||
mqtt_publish_funct: async (value, self) => { | ||
return value ? JSON.parse(value).new_fw : false; | ||
} | ||
}, | ||
common: { | ||
'name': 'New firmware available', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
'firmwareupdate': { | ||
coap: { | ||
http_cmd: '/ota?update=true', | ||
}, | ||
mqtt: { | ||
http_cmd: '/ota?update=true', | ||
}, | ||
common: { | ||
'name': 'Update Firmware', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Online', | ||
'type': 'boolean', | ||
'role': 'indicator.reachable', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'firmware': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { | ||
return value ? JSON.parse(value).update.has_update : undefined; | ||
} | ||
'uptime': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).uptime) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).uptime) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Uptime', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/announce', | ||
mqtt_publish_funct: async (value, self) => { | ||
return value ? JSON.parse(value).new_fw : false; | ||
} | ||
'version': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).fw : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/announce', | ||
mqtt_publish_funct: async (value) => { return value ? JSON.parse(value).fw_ver : undefined; } | ||
}, | ||
common: { | ||
'name': 'Firmware version', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'New firmware available', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'firmwareupdate': { | ||
coap: { | ||
http_cmd: '/ota?update=true', | ||
'hostname': { | ||
coap: { | ||
}, | ||
mqtt: { | ||
}, | ||
common: { | ||
'name': 'Device Hostname', | ||
'type': 'string', | ||
'role': 'info.ip', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_cmd: '/ota?update=true', | ||
'id': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
}, | ||
common: { | ||
'name': 'Device Id', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Update Firmware', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'uptime': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).uptime) : undefined; } | ||
'type': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
}, | ||
common: { | ||
'name': 'Device type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).uptime) : undefined; } | ||
'rssi': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value && JSON.parse(value) && JSON.parse(value).wifi_sta ? JSON.parse(value).wifi_sta.rssi : 0; } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value && JSON.parse(value) && JSON.parse(value).wifi_sta ? JSON.parse(value).wifi_sta.rssi : 0; } | ||
}, | ||
common: { | ||
'name': 'Device RSSI status', | ||
'type': 'number', | ||
'role': 'value', | ||
'unit': 'db', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Uptime', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'version': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).fw : undefined; } | ||
'reboot': { | ||
coap: { | ||
http_cmd: '/reboot', | ||
}, | ||
mqtt: { | ||
http_cmd: '/reboot', | ||
}, | ||
common: { | ||
'name': 'Reboot', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/announce', | ||
mqtt_publish_funct: async (value) => { return value ? JSON.parse(value).fw_ver : undefined; } | ||
'protocol': { | ||
coap: { | ||
coap_init_value: 'coap' | ||
}, | ||
mqtt: { | ||
mqtt_init_value: 'mqtt' | ||
}, | ||
common: { | ||
'name': 'Protocol', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Firmware version', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
'name': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setDeviceName(self, JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setDeviceName(self, JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Device Name', | ||
'type': 'string', | ||
'role': 'info.name', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'hostname': { | ||
coap: { | ||
}, | ||
mqtt: { | ||
}, | ||
common: { | ||
'name': 'Device Hostname', | ||
'type': 'string', | ||
'role': 'info.ip', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'id': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
}, | ||
common: { | ||
'name': 'Device Id', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'type': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
}, | ||
common: { | ||
'name': 'Device type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'rssi': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value && JSON.parse(value) && JSON.parse(value).wifi_sta ? JSON.parse(value).wifi_sta.rssi : 0; } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value && JSON.parse(value) && JSON.parse(value).wifi_sta ? JSON.parse(value).wifi_sta.rssi : 0; } | ||
}, | ||
common: { | ||
'name': 'Device RSSI status', | ||
'type': 'number', | ||
'role': 'value', | ||
'unit': 'db', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'reboot': { | ||
coap: { | ||
http_cmd: '/reboot', | ||
}, | ||
mqtt: { | ||
http_cmd: '/reboot', | ||
}, | ||
common: { | ||
'name': 'Reboot', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'protocol': { | ||
coap: { | ||
coap_init_value: 'coap' | ||
}, | ||
mqtt: { | ||
mqtt_init_value: 'mqtt' | ||
}, | ||
common: { | ||
'name': 'Protocol', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'name': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setDeviceName(self, JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setDeviceName(self, JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Device Name', | ||
'type': 'string', | ||
'role': 'info.name', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
@@ -238,209 +238,209 @@ | ||
*/ | ||
let defaultsgen2 = { | ||
'gen': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).gen : undefined; } | ||
const defaultsgen2 = { | ||
'gen': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).gen : undefined; } | ||
}, | ||
common: { | ||
'name': 'Device generation', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device generation', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'online': { | ||
mqtt: { | ||
'online': { | ||
mqtt: { | ||
}, | ||
common: { | ||
'name': 'Online', | ||
'type': 'boolean', | ||
'role': 'indicator.reachable', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Online', | ||
'type': 'boolean', | ||
'role': 'indicator.reachable', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'firmware': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: (value) => { | ||
if (value) { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj.sys, 'available_updates') && | ||
'firmware': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: (value) => { | ||
if (value) { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj.sys, 'available_updates') && | ||
Object.prototype.hasOwnProperty.call(valueObj.sys.available_updates, 'stable') && | ||
Object.prototype.hasOwnProperty.call(valueObj.sys.available_updates.stable, 'version') | ||
) { | ||
return true; | ||
} | ||
) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
}, | ||
common: { | ||
'name': 'New firmware available', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return false; | ||
} | ||
}, | ||
common: { | ||
'name': 'New firmware available', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'firmwareupdate': { | ||
mqtt: { | ||
http_cmd: '/rpc/Shelly.Update', | ||
'firmwareupdate': { | ||
mqtt: { | ||
http_cmd: '/rpc/Shelly.Update', | ||
}, | ||
common: { | ||
'name': 'Update Firmware', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Update Firmware', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'uptime': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).sys.uptime) : undefined; } | ||
'uptime': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: async (value) => { return value ? shellyHelper.uptimeString(JSON.parse(value).sys.uptime) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Uptime', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Uptime', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'version': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).ver : undefined; } | ||
'version': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).ver : undefined; } | ||
}, | ||
common: { | ||
'name': 'Firmware version', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Firmware version', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'hostname': { | ||
mqtt: { | ||
'hostname': { | ||
mqtt: { | ||
}, | ||
common: { | ||
'name': 'Device Hostname', | ||
'type': 'string', | ||
'role': 'info.ip', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device Hostname', | ||
'type': 'string', | ||
'role': 'info.ip', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'id': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
'id': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return self.getDeviceId(); } | ||
}, | ||
common: { | ||
'name': 'Device Id', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device Id', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'type': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
'type': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return self.getDeviceType(); } | ||
}, | ||
common: { | ||
'name': 'Device type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'model': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return value ? JSON.parse(value).model : undefined; } | ||
'model': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return value ? JSON.parse(value).model : undefined; } | ||
}, | ||
common: { | ||
'name': 'Device Model', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device Model', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'authEnabled': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return value ? JSON.parse(value).auth_en : undefined; } | ||
'authEnabled': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: (value, self) => { return value ? JSON.parse(value).auth_en : undefined; } | ||
}, | ||
common: { | ||
'name': 'Authentication enabled', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Authentication enabled', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'rssi': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).wifi.rssi : undefined; } | ||
'rssi': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetStatus', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).wifi.rssi : undefined; } | ||
}, | ||
common: { | ||
'name': 'Device RSSI status', | ||
'type': 'number', | ||
'role': 'value', | ||
'unit': 'db', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Device RSSI status', | ||
'type': 'number', | ||
'role': 'value', | ||
'unit': 'db', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'reboot': { | ||
mqtt: { | ||
http_cmd: '/rpc/Shelly.Reboot', | ||
'reboot': { | ||
mqtt: { | ||
http_cmd: '/rpc/Shelly.Reboot', | ||
}, | ||
common: { | ||
'name': 'Reboot', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Reboot', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'protocol': { | ||
mqtt: { | ||
mqtt_init_value: 'mqtt' | ||
'protocol': { | ||
mqtt: { | ||
mqtt_init_value: 'mqtt' | ||
}, | ||
common: { | ||
'name': 'Protocol', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Protocol', | ||
'type': 'string', | ||
'role': 'info', | ||
'read': true, | ||
'write': false | ||
'name': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).id : undefined; } | ||
}, | ||
common: { | ||
'name': 'Device Name', | ||
'type': 'string', | ||
'role': 'info.name', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'name': { | ||
mqtt: { | ||
http_publish: '/rpc/Shelly.GetDeviceInfo', | ||
http_publish_funct: async (value) => { return value ? JSON.parse(value).id : undefined; } | ||
}, | ||
common: { | ||
'name': 'Device Name', | ||
'type': 'string', | ||
'role': 'info.name', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
defaultsgen1: defaultsgen1, | ||
defaultsgen2: defaultsgen2 | ||
defaultsgen1: defaultsgen1, | ||
defaultsgen2: defaultsgen2 | ||
}; |
@@ -21,463 +21,475 @@ /* jshint -W097 */ | ||
*/ | ||
let shelly1 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shelly1 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'ext.switch1': { | ||
coap: { | ||
coap_publish: '3117' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_switch/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.switch1': { | ||
coap: { | ||
coap_publish: '3117' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_switch/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
@@ -487,3 +499,3 @@ | ||
module.exports = { | ||
shelly1: shelly1 | ||
shelly1: shelly1 | ||
}; |
@@ -10,657 +10,683 @@ /* jshint -W097 */ | ||
let shelly1l = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shelly1l = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay0.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay0.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay0.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay0.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay0.Longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.Longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
'Relay0.Longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.Longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay0.Button1Type': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.Button1Reverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay0.Button2Type': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay0.Button2Reverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.Longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Button1Type': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_type: value }; } | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'Relay0.Button1Reverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn1_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn1_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Button2Type': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.Button2Reverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn2_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn2_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shelly1l: shelly1l | ||
shelly1l: shelly1l | ||
}; |
@@ -21,618 +21,630 @@ /* jshint -W097 */ | ||
*/ | ||
let shelly1pm = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shelly1pm = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'maxPower': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max_power : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { max_power: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max_power : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { max_power: value }; } | ||
}, | ||
common: { | ||
'name': 'max. Power', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'overpower': { | ||
coap: { | ||
coap_publish: '6102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overpower', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Overpower', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
'ext.switch1': { | ||
coap: { | ||
coap_publish: '3117' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_switch/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'maxPower': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max_power : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { max_power: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max_power : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { max_power: value }; } | ||
}, | ||
common: { | ||
'name': 'max. Power', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'overpower': { | ||
coap: { | ||
coap_publish: '6102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overpower', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Overpower', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF1': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF2': { | ||
coap: { | ||
coap_publish: '3202', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF3': { | ||
coap: { | ||
coap_publish: '3302', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.humidity1': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '1') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.humidity3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtHum(JSON.parse(value), '2') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'ext.switch1': { | ||
coap: { | ||
coap_publish: '3117' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_switch/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shelly1pm: shelly1pm | ||
shelly1pm: shelly1pm | ||
}; |
@@ -18,294 +18,305 @@ | ||
*/ | ||
let shelly2led = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shelly2led = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.red': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).red : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.green': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).green : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
'lights.blue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).blue : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.white': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).white : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.red': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).red : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
'lights.gain': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).gain : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.temp': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).temp : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.green': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).green : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).brightness : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': { | ||
0: 'Off', | ||
1: 'Meteor Shower', | ||
2: 'Gradual Change', | ||
3: 'Breath', | ||
4: 'Flash', | ||
5: 'On/Off Gradual', | ||
6: 'Red/Green Change' | ||
} | ||
} | ||
} | ||
}, | ||
'lights.blue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).blue : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).white : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.gain': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).gain : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.temp': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).temp : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { | ||
return value ? JSON.parse(value).brightness : undefined; | ||
}, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': '0:Off;1:Meteor Shower;2:Gradual Change;3:Breath;4:Flash;5:On/Off Gradual;6:Red/Green Change' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shelly2led: shelly2led | ||
shelly2led: shelly2led | ||
}; |
@@ -14,26 +14,26 @@ /* jshint -W097 */ | ||
*/ | ||
let shelly4pro = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '112', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shelly4pro = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '112', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
/* | ||
/* | ||
'Relay0.ChannelName': { | ||
@@ -61,171 +61,181 @@ coap: { | ||
*/ | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '111', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '118', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '122', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '111', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '118', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '122', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
/* | ||
/* | ||
'Relay1.ChannelName': { | ||
@@ -253,171 +263,182 @@ coap: { | ||
*/ | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '121', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay1.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[1].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '128', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay2.Switch': { | ||
coap: { | ||
coap_publish: '132', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/2', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/2/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '121', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay1.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[1].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '128', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay2.Switch': { | ||
coap: { | ||
coap_publish: '132', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/2', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/2/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
/* | ||
/* | ||
'Relay2.ChannelName': { | ||
@@ -445,171 +466,182 @@ coap: { | ||
*/ | ||
'Relay2.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay2.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay2.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay2.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/2', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay2.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay2.Power': { | ||
coap: { | ||
coap_publish: '131', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay2.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[2].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay2.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay2.Input': { | ||
coap: { | ||
coap_publish: '138', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/2', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[2].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay3.Switch': { | ||
coap: { | ||
coap_publish: '142', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/3', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/3/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay2.Power': { | ||
coap: { | ||
coap_publish: '131', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay2.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[2].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/2/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay2.Input': { | ||
coap: { | ||
coap_publish: '138', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/2', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay3.Switch': { | ||
coap: { | ||
coap_publish: '142', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/3', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/3/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
/* | ||
/* | ||
'Relay3.ChannelName': { | ||
@@ -637,148 +669,159 @@ coap: { | ||
*/ | ||
'Relay3.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay3.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay3.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay3.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay3.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/3', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay3.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay3.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay3.Power': { | ||
coap: { | ||
coap_publish: '141', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay3.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[3].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay3.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay3.Input': { | ||
coap: { | ||
coap_publish: '148', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/3', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[3].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay3.Power': { | ||
coap: { | ||
coap_publish: '141', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay3.Energy': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[3].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/3/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay3.Input': { | ||
coap: { | ||
coap_publish: '148', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/3', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
}; | ||
@@ -788,3 +831,3 @@ | ||
module.exports = { | ||
shelly4pro: shelly4pro | ||
shelly4pro: shelly4pro | ||
}; |
@@ -21,340 +21,351 @@ | ||
*/ | ||
let shellybulb = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellybulb = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.color.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': { | ||
0: 'Off', | ||
1: 'Meteor Shower', | ||
2: 'Gradual Change', | ||
3: 'Breath', | ||
4: 'Flash', | ||
5: 'On/Off Gradual', | ||
6: 'Red/Green Change' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.color.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': '0:Off;1:Meteor Shower;2:Gradual Change;3:Breath;4:Flash;5:On/Off Gradual;6:Red/Green Change' | ||
} | ||
}, | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellybulb: shellybulb | ||
shellybulb: shellybulb | ||
}; |
@@ -19,180 +19,180 @@ | ||
*/ | ||
let shellybulbduo = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellybulbduo = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5104', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'unit': '%', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'unit': 'K', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'unit': '%', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5104', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
'lights.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'unit': '%', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
'lights.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
} | ||
}, | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'unit': 'K', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'unit': '%', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'lights.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellybulbduo: shellybulbduo | ||
shellybulbduo: shellybulbduo | ||
}; |
@@ -18,91 +18,96 @@ /* jshint -W097 */ | ||
*/ | ||
let shellybutton1 = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= 1.8 | ||
const shellybutton1 = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'Button.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'SS': '2xShort', | ||
'SSS': '3xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'Button.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Button.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Button.Input': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].input : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].input : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Input', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;SS:2xShort;SSS:3xShort;L:Long' | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}, | ||
'Button.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Button.Input': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].input : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].input : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Input', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value) }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellybutton1: shellybutton1 | ||
shellybutton1: shellybutton1 | ||
}; |
@@ -21,340 +21,351 @@ | ||
*/ | ||
let shellycolorbulb = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellycolorbulb = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.color.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', //CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': { | ||
0: 'Off', | ||
1: 'Meteor Shower', | ||
2: 'Gradual Change', | ||
3: 'Breath', | ||
4: 'Flash', | ||
5: 'On/Off Gradual', | ||
6: 'Red/Green Change' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.color.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': '0:Off;1:Meteor Shower;2:Gradual Change;3:Breath;4:Flash;5:On/Off Gradual;6:Red/Green Change' | ||
} | ||
}, | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellycolorbulb: shellycolorbulb | ||
shellycolorbulb: shellycolorbulb | ||
}; |
@@ -19,445 +19,461 @@ | ||
*/ | ||
let shellydimmer = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellydimmer = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).ison === true : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).ison === true : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 1, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'lights.mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 1, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'one_button': 'one_button', | ||
'dual_button': 'dual_button', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
'lights.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'one_button:one_button;dual_button:dual_button;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'lights.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); }, | ||
'lights.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'lights.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'lights.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); }, | ||
'lights.longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Fade Rate', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'unit': 'ms', | ||
'min': 0, | ||
'max': 5000 | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'lights.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'lights.FadeRate': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Transitions Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'lights.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature_f', | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'lights.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'lights.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'lights.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Fade Rate', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'unit': 'ms', | ||
'min': 0, | ||
'max': 5000 | ||
} | ||
}, | ||
'lights.FadeRate': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Transitions Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature_f', | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellydimmer: shellydimmer | ||
shellydimmer: shellydimmer | ||
}; | ||
@@ -16,443 +16,459 @@ | ||
*/ | ||
let shellydimmer2 = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellydimmer2 = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).ison === true : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).ison === true : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'lights.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'one_button': 'one_button', | ||
'dual_button': 'dual_button', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; } | ||
'lights.Power': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { | ||
return value ? (Math.round(JSON.parse(value).meters[0].power * 100) / 100) : undefined; | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.Energy': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'one_button:one_button;dual_button:dual_button;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'lights.Power': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { | ||
return value ? (Math.round(JSON.parse(value).meters[0].power * 100) / 100) : undefined; | ||
} | ||
'lights.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'lights.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'lights.Energy': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
'lights.longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round((JSON.parse(value).meters[0].total / 60) * 100) / 100) : undefined; } | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Transitions Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'unit': 'ms', | ||
'min': 0, | ||
'max': 5000 | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'lights.Input1': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'lights.FadeRate': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Fade Rate', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature' | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Event1': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature_f' | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'lights.EventCount1': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'lights.longpush1': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Input2': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Event2': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'lights.EventCount2': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'lights.longpush2': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).transition : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Transitions Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'unit': 'ms', | ||
'min': 0, | ||
'max': 5000 | ||
} | ||
}, | ||
'lights.FadeRate': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return value ? JSON.parse(value).fade_rate : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Fade Rate', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature' | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature_f' | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Over Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellydimmer2: shellydimmer2 | ||
shellydimmer2: shellydimmer2 | ||
}; |
@@ -18,124 +18,128 @@ /* jshint -W097 */ | ||
*/ | ||
let shellydw = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellydw = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'sensor.door': { | ||
coap: { | ||
coap_publish: '3108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 0 ? false : true; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/state', | ||
mqtt_publish_funct: (value) => { return value === 'open'; } | ||
}, | ||
common: { | ||
'name': 'Door Sensor', | ||
'type': 'boolean', | ||
'role': 'sensor.door', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.door': { | ||
coap: { | ||
coap_publish: '3108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 0 ? false : true; } | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/state', | ||
mqtt_publish_funct: (value) => { return value === 'open'; } | ||
'sensor.illuminantion': { | ||
coap: { | ||
coap_publish: '3110', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/illumination', | ||
}, | ||
common: { | ||
'name': 'Illumination Level', | ||
'type': 'string', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'dark': 'dark', | ||
'twilight': 'twilight', | ||
'bright': 'bright' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Door Sensor', | ||
'type': 'boolean', | ||
'role': 'sensor.door', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/vibration', | ||
mqtt_publish_funct: (value) => { return value != 0; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
'sensor.tilt': { | ||
coap: { | ||
coap_publish: '3109' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/tilt', | ||
}, | ||
common: { | ||
'name': 'Tilt', | ||
'type': 'number', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false, | ||
'unit': 'degree' | ||
} | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}, | ||
'sensor.illuminantion': { | ||
coap: { | ||
coap_publish: '3110', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/illumination', | ||
}, | ||
common: { | ||
'name': 'Illumination Level', | ||
'type': 'string', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'states': 'dark:dark;twilight:twilight;bright:bright' | ||
} | ||
}, | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/vibration', | ||
mqtt_publish_funct: (value) => { return value != 0; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.tilt': { | ||
coap: { | ||
coap_publish: '3109' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/tilt', | ||
}, | ||
common: { | ||
'name': 'Tilt', | ||
'type': 'number', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false, | ||
'unit': 'degree' | ||
} | ||
}, | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value) }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellydw: shellydw | ||
shellydw: shellydw | ||
}; |
@@ -18,158 +18,162 @@ /* jshint -W097 */ | ||
*/ | ||
let shellydw2 = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellydw2 = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'sensor.door': { | ||
coap: { | ||
coap_publish: '3108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 0 ? false : true; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/state', | ||
mqtt_publish_funct: (value) => { return value === 'open'; } | ||
}, | ||
common: { | ||
'name': 'Door Sensor', | ||
'type': 'boolean', | ||
'role': 'sensor.door', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.door': { | ||
coap: { | ||
coap_publish: '3108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 0 ? false : true; } | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/state', | ||
mqtt_publish_funct: (value) => { return value === 'open'; } | ||
'sensor.illuminantion': { | ||
coap: { | ||
coap_publish: '3110', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/illumination', | ||
}, | ||
common: { | ||
'name': 'Illumination Level', | ||
'type': 'string', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'dark': 'dark', | ||
'twilight': 'twilight', | ||
'bright': 'bright' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Door Sensor', | ||
'type': 'boolean', | ||
'role': 'sensor.door', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/vibration', | ||
mqtt_publish_funct: (value) => { return value != 0; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
'sensor.tilt': { | ||
coap: { | ||
coap_publish: '3109' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/tilt', | ||
}, | ||
common: { | ||
'name': 'Tilt', | ||
'type': 'number', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false, | ||
'unit': 'degree' | ||
} | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
}, | ||
'sensor.illuminantion': { | ||
coap: { | ||
coap_publish: '3110', // CoAP >= FW 1.8 | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/illumination', | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Illumination Level', | ||
'type': 'string', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'states': 'dark:dark;twilight:twilight;bright:bright' | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value); }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}, | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/vibration', | ||
mqtt_publish_funct: (value) => { return value != 0; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.tilt': { | ||
coap: { | ||
coap_publish: '3109' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/tilt', | ||
}, | ||
common: { | ||
'name': 'Tilt', | ||
'type': 'number', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false, | ||
'unit': 'degree' | ||
} | ||
}, | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'sensor.wakeupevent': { | ||
coap: { | ||
coap_publish: '9102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return JSON.stringify(value) }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/wakeupevent', | ||
}, | ||
common: { | ||
'name': 'Wakeup Event', | ||
'type': 'json', | ||
'role': 'json', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellydw2: shellydw2 | ||
shellydw2: shellydw2 | ||
}; |
@@ -17,357 +17,357 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyem = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellyem = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } }, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } }, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Emeter0.Power': { | ||
coap: { | ||
coap_publish: '4105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Emeter0.Total': { | ||
coap: { | ||
coap_publish: '4106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total' | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Emeter0.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned' | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Emeter0.Power': { | ||
coap: { | ||
coap_publish: '4105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter0.ReactivePower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].reactive * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/reactive_power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Reactive Power', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'VAR' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter0.PowerFactor': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 0); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 0); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Emeter0.Total': { | ||
coap: { | ||
coap_publish: '4106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter0.Voltage': { | ||
coap: { | ||
coap_publish: '4108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total' | ||
'Emeter0.Current': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Current Transformation Type', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter0.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Power': { | ||
coap: { | ||
coap_publish: '4205', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned' | ||
'Emeter1.Total': { | ||
coap: { | ||
coap_publish: '4206', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter0.ReactivePower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].reactive * 100) / 100) : undefined; } | ||
'Emeter1.Total_Returned': { | ||
coap: { | ||
coap_publish: '4207', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/reactive_power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.ReactivePower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].reactive * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/reactive_power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Reactive Power', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'VAR' | ||
} | ||
}, | ||
common: { | ||
'name': 'Reactive Power', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'VAR' | ||
} | ||
}, | ||
'Emeter0.PowerFactor': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 0); } | ||
'Emeter1.PowerFactor': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 1); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 1); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 0); } | ||
'Emeter1.Voltage': { | ||
coap: { | ||
coap_publish: '4208', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
'Emeter1.Current': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Current Transformation Type', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
} | ||
}, | ||
'Emeter0.Voltage': { | ||
coap: { | ||
coap_publish: '4108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Emeter0.Current': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[0].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Current Transformation Type', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
'Emeter1.Power': { | ||
coap: { | ||
coap_publish: '4205', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Emeter1.Total': { | ||
coap: { | ||
coap_publish: '4206', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter1.Total_Returned': { | ||
coap: { | ||
coap_publish: '4207', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter1.ReactivePower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].reactive * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/reactive_power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Reactive Power', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'VAR' | ||
} | ||
}, | ||
'Emeter1.PowerFactor': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 1); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerFactor(self, 1); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Emeter1.Voltage': { | ||
coap: { | ||
coap_publish: '4208', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Emeter1.Current': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? (Math.round(JSON.parse(value).emeters[1].ctraf_type * 100) / 100) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Current Transformation Type', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyem: shellyem | ||
shellyem: shellyem | ||
}; |
@@ -12,4 +12,4 @@ /* jshint -W097 */ | ||
* Shelly 3 EM / SHEM-3 / shellyem3 | ||
* CoAP: | ||
* {"blk":[{"I":0,"D":"Relay0"},{"I":1,"D":"Meter0"},{"I":2,"D":"Meter1"},{"I":3,"D":"Meter2"}],"sen":[{"I":112,"T":"S","D":"State","R":"0/1","L":0},{"I":111,"T":"P","D":"Power","R":"0/26400","L":1},{"I":114,"T":"S","D":"PF","R":"0/1","L":1},{"I":115,"T":"S","D":"Current","R":"0/120","L":1},{"I":116,"T":"S","D":"Voltage","R":"0/265","L":1},{"I":121,"T":"P","D":"Power","R":"0/26400","L":2},{"I":124,"T":"S","D":"PF","R":"0/1","L":2},{"I":125,"T":"S","D":"Current","R":"0/120","L":2},{"I":126,"T":"S","D":"Voltage","R":"0/265","L":2},{"I":131,"T":"P","D":"Power","R":"0/26400","L":3},{"I":134,"T":"S","D":"PF","R":"0/1","L":3},{"I":135,"T":"S","D":"Current","R":"0/120","L":3},{"I":136,"T":"S","D":"Voltage","R":"0/265","L":3}]} | ||
* CoAP: | ||
* {"blk":[{"I":0,"D":"Relay0"},{"I":1,"D":"Meter0"},{"I":2,"D":"Meter1"},{"I":3,"D":"Meter2"}],"sen":[{"I":112,"T":"S","D":"State","R":"0/1","L":0},{"I":111,"T":"P","D":"Power","R":"0/26400","L":1},{"I":114,"T":"S","D":"PF","R":"0/1","L":1},{"I":115,"T":"S","D":"Current","R":"0/120","L":1},{"I":116,"T":"S","D":"Voltage","R":"0/265","L":1},{"I":121,"T":"P","D":"Power","R":"0/26400","L":2},{"I":124,"T":"S","D":"PF","R":"0/1","L":2},{"I":125,"T":"S","D":"Current","R":"0/120","L":2},{"I":126,"T":"S","D":"Voltage","R":"0/265","L":2},{"I":131,"T":"P","D":"Power","R":"0/26400","L":3},{"I":134,"T":"S","D":"PF","R":"0/1","L":3},{"I":135,"T":"S","D":"Current","R":"0/120","L":3},{"I":136,"T":"S","D":"Voltage","R":"0/265","L":3}]} | ||
* | ||
@@ -19,550 +19,550 @@ * CoAP Version >= 1.8 | ||
*/ | ||
let shellyem3 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellyem3 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Emeter0.Power': { | ||
coap: { | ||
coap_publish: '4105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Emeter0.Total': { | ||
coap: { | ||
coap_publish: '4106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Emeter0.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Emeter0.PowerFactor': { | ||
coap: { | ||
coap_publish: '4110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Emeter0.Power': { | ||
coap: { | ||
coap_publish: '4105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter0.Voltage': { | ||
coap: { | ||
coap_publish: '4108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter0.Current': { | ||
coap: { | ||
coap_publish: '4109', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Emeter0.Total': { | ||
coap: { | ||
coap_publish: '4106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Power': { | ||
coap: { | ||
coap_publish: '4205', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Total': { | ||
coap: { | ||
coap_publish: '4206', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter0.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Total_Returned': { | ||
coap: { | ||
coap_publish: '4207', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.PowerFactor': { | ||
coap: { | ||
coap_publish: '4210', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter0.PowerFactor': { | ||
coap: { | ||
coap_publish: '4110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Voltage': { | ||
coap: { | ||
coap_publish: '4208', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter1.Current': { | ||
coap: { | ||
coap_publish: '4209', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Emeter0.Voltage': { | ||
coap: { | ||
coap_publish: '4108', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.Power': { | ||
coap: { | ||
coap_publish: '4305', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (value * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.Total': { | ||
coap: { | ||
coap_publish: '4306', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value) * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Emeter0.Current': { | ||
coap: { | ||
coap_publish: '4109', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.Total_Returned': { | ||
coap: { | ||
coap_publish: '4307', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.PowerFactor': { | ||
coap: { | ||
coap_publish: '4310', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
'Emeter1.Power': { | ||
coap: { | ||
coap_publish: '4205', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.Voltage': { | ||
coap: { | ||
coap_publish: '4308', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Emeter2.Current': { | ||
coap: { | ||
coap_publish: '4309', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Emeter1.Total': { | ||
coap: { | ||
coap_publish: '4206', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Total.ConsumedPower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getTotalSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getTotalSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total consumed energy', | ||
'type': 'number', | ||
'role': 'value.totalconsumed', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Total.Current': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getCurrentSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/current', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getCurrentSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter1.Total_Returned': { | ||
coap: { | ||
coap_publish: '4207', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Total.InstantPower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getPowerSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total Instantaneous power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Total.VoltageMean': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'mean'); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'mean'); } | ||
}, | ||
common: { | ||
'name': 'Voltage Mean', | ||
'type': 'number', | ||
'role': 'value.voltagemean', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter1.PowerFactor': { | ||
coap: { | ||
coap_publish: '4210', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Total.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { return shellyHelper.getTotalReturnedSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getTotalReturnedSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
/* Das macht keinen Sinn */ | ||
'Total.Voltage': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'total'); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'total'); } | ||
}, | ||
common: { | ||
'name': 'Voltage Total', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
} | ||
}, | ||
'Emeter1.Voltage': { | ||
coap: { | ||
coap_publish: '4208', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Emeter1.Current': { | ||
coap: { | ||
coap_publish: '4209', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/1/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
'Emeter2.Power': { | ||
coap: { | ||
coap_publish: '4305', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (value * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Emeter2.Total': { | ||
coap: { | ||
coap_publish: '4306', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value) * 100) / 100; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/total', | ||
mqtt_publish_funct: (value) => { return (Math.round(value) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Total', | ||
'type': 'number', | ||
'role': 'value.total', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter2.Total_Returned': { | ||
coap: { | ||
coap_publish: '4307', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/total_returned', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Emeter2.PowerFactor': { | ||
coap: { | ||
coap_publish: '4310', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/pf', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power Factor', | ||
'type': 'number', | ||
'role': 'value', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Emeter2.Voltage': { | ||
coap: { | ||
coap_publish: '4308', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/voltage', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Voltage', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Emeter2.Current': { | ||
coap: { | ||
coap_publish: '4309', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/2/current', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
'Total.ConsumedPower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getTotalSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getTotalSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total consumed energy', | ||
'type': 'number', | ||
'role': 'value.totalconsumed', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Total.Current': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getCurrentSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/current', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getCurrentSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total Current', | ||
'type': 'number', | ||
'role': 'value.current', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'A' | ||
} | ||
}, | ||
'Total.InstantPower': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getPowerSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/power', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getPowerSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total Instantaneous power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Total.VoltageMean': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'mean'); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/voltage', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'mean'); } | ||
}, | ||
common: { | ||
'name': 'Voltage Mean', | ||
'type': 'number', | ||
'role': 'value.voltagemean', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
}, | ||
'Total.Total_Returned': { | ||
coap: { | ||
coap_publish: '4107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { return shellyHelper.getTotalReturnedSumm(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/emeter/0/total_returned', | ||
mqtt_publish_funct: async (value, self) => { return shellyHelper.getTotalReturnedSumm(self); } | ||
}, | ||
common: { | ||
'name': 'Total_Returned', | ||
'type': 'number', | ||
'role': 'value.total_returned', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
/* Das macht keinen Sinn */ | ||
'Total.Voltage': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'total'); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: async (value, self) => { return shellyHelper.getVoltageCalc(self, 'total'); } | ||
}, | ||
common: { | ||
'name': 'Voltage Total', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'V' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyem3: shellyem3 | ||
shellyem3: shellyem3 | ||
}; |
@@ -17,75 +17,75 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyflood = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellyflood = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'sensor.flood': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/flood', | ||
}, | ||
common: { | ||
'name': 'Flood', | ||
'type': 'boolean', | ||
'role': 'sensor.alarm.flood', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.flood': { | ||
coap: { | ||
coap_publish: '6106', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/flood', | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Flood', | ||
'type': 'boolean', | ||
'role': 'sensor.alarm.flood', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
}; | ||
module.exports = { | ||
shellyflood: shellyflood | ||
shellyflood: shellyflood | ||
}; |
@@ -18,68 +18,68 @@ /* jshint -W097 */ | ||
*/ | ||
let shellygas = { | ||
'Gas.SensorState': { | ||
coap: { | ||
coap_publish: '3113' // CoAP >= FW 1.8 | ||
const shellygas = { | ||
'Gas.SensorState': { | ||
coap: { | ||
coap_publish: '3113' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/operation', | ||
}, | ||
common: { | ||
'name': 'Sensor State', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/operation', | ||
'Gas.SelfTestState': { | ||
coap: { | ||
coap_publish: '3114' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/self_test', | ||
}, | ||
common: { | ||
'name': 'Self-test state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Sensor State', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Gas.SelfTestState': { | ||
coap: { | ||
coap_publish: '3114' // CoAP >= FW 1.8 | ||
'Gas.AlarmState': { | ||
coap: { | ||
coap_publish: '6108' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/gas', | ||
}, | ||
common: { | ||
'name': 'Alarm state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/self_test', | ||
}, | ||
common: { | ||
'name': 'Self-test state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
'Gas.Concentration': { | ||
coap: { | ||
coap_publish: '3107' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/concentration', | ||
}, | ||
common: { | ||
'name': 'Concentration', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'uunit': 'ppm' | ||
} | ||
} | ||
}, | ||
'Gas.AlarmState': { | ||
coap: { | ||
coap_publish: '6108' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/gas', | ||
}, | ||
common: { | ||
'name': 'Alarm state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Gas.Concentration': { | ||
coap: { | ||
coap_publish: '3107' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/concentration', | ||
}, | ||
common: { | ||
'name': 'Concentration', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'uunit': 'ppm' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellygas: shellygas | ||
shellygas: shellygas | ||
}; |
@@ -18,77 +18,77 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyht = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellyht = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'hum.value': { | ||
coap: { | ||
coap_publish: '3103' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/humidity' | ||
}, | ||
common: { | ||
'name': 'Relative humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'hum.value': { | ||
coap: { | ||
coap_publish: '3103' // CoAP >= FW 1.8 | ||
'tmp.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/humidity' | ||
'tmp.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Relative humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'tmp.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'tmp.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
}; | ||
module.exports = { | ||
shellyht: shellyht | ||
shellyht: shellyht | ||
}; |
@@ -17,443 +17,487 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyix3 = { | ||
/* | ||
const shellyix3 = { | ||
/* | ||
* /settings generell | ||
* | ||
*/ | ||
'longpushDurationMsMin': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_duration_ms.min : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
'longpushDurationMsMin': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_duration_ms.min : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/longpush_duration_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).min : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush min. duration', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 3000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/longpush_duration_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).min : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
'longpushDurationMsMax': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_duration_ms.max : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { max: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/longpush_duration_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { max: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush max. duration', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 3000, | ||
'read': true, | ||
'write': true | ||
}, | ||
}, | ||
common: { | ||
'name': 'Longpush min. duration', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 3000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'longpushDurationMsMax': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_duration_ms.max : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { max: value }; } | ||
'multipushTimeBetweenPushesMsMax': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).multipush_time_between_pushes_ms.max : undefined; }, | ||
http_cmd: '/settings/multipush_time_between_pushes_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/multipush_time_between_pushes_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max : undefined; }, | ||
http_cmd: '/settings/multipush_time_between_pushes_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
}, | ||
common: { | ||
'name': 'Max time between sequential pushes', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 500, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/longpush_duration_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max : undefined; }, | ||
http_cmd: '/settings/longpush_duration_ms', | ||
http_cmd_funct: (value) => { return { max: value }; } | ||
'Relay0.Name': { | ||
coap: { | ||
http_publish: '/settings/input/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush max. duration', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 3000, | ||
'read': true, | ||
'write': true | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/0', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/0', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
}, | ||
'multipushTimeBetweenPushesMsMax': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).multipush_time_between_pushes_ms.max : undefined; }, | ||
http_cmd: '/settings/multipush_time_between_pushes_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'SS': '2xShort', | ||
'SSS': '3xShort', | ||
'SL': 'Short Long', | ||
'LS': 'Long Short', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/multipush_time_between_pushes_ms', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).max : undefined; }, | ||
http_cmd: '/settings/multipush_time_between_pushes_ms', | ||
http_cmd_funct: (value) => { return { min: value }; } | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Max time between sequential pushes', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 500, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Name': { | ||
coap: { | ||
http_publish: '/settings/input/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_type : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_type : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/0', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
'Relay1.Name': { | ||
coap: { | ||
http_publish: '/settings/input/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/0', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/1', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/1', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Off', | ||
1: 'On' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Off;1:On' | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'SS': '2xShort', | ||
'SSS': '3xShort', | ||
'SL': 'Short Long', | ||
'LS': 'Long Short', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;SS:2xShort;SSS:3xShort;SL:Short Long;LS:Long Short;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= FW 1.8 | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_type : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_type : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_type : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay2.Name': { | ||
coap: { | ||
http_publish: '/settings/input/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_type : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay2.Input': { | ||
coap: { | ||
coap_publish: '2301', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/2', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/2', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/2', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Off', | ||
1: 'On' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay2.Event': { | ||
coap: { | ||
coap_publish: '2302' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/2', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'SS': '2xShort', | ||
'SSS': '3xShort', | ||
'SL': 'Short Long', | ||
'LS': 'Long Short', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[0].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/0', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay2.EventCount': { | ||
coap: { | ||
coap_publish: '2303' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/2', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay1.Name': { | ||
coap: { | ||
http_publish: '/settings/input/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_type : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_type : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
'Relay2.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
} | ||
}, | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/1', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/1', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Off;1:On' | ||
} | ||
}, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;SS:2xShort;SSS:3xShort;SL:Short Long;LS:Long Short;L:Long' | ||
} | ||
}, | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_type : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_type : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle' | ||
} | ||
}, | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[1].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/1', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay2.Name': { | ||
coap: { | ||
http_publish: '/settings/input/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/input/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).name : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Input name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay2.Input': { | ||
coap: { | ||
coap_publish: '2301', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/2', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/2', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/input/2', | ||
http_cmd_funct: (value) => { return { input: value }; } | ||
}, | ||
common: { | ||
'name': 'Input On / Off', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Off;1:On' | ||
} | ||
}, | ||
'Relay2.Event': { | ||
coap: { | ||
coap_publish: '2302' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/2', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;SS:2xShort;SSS:3xShort;SL:Short Long;LS:Long Short;L:Long' | ||
} | ||
}, | ||
'Relay2.EventCount': { | ||
coap: { | ||
coap_publish: '2303' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/2', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_type : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_type : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle' | ||
} | ||
}, | ||
'Relay2.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).inputs[2].btn_reverse : undefined; }, | ||
http_cmd: '/settings/input/2', | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyix3: shellyix3 | ||
shellyix3: shellyix3 | ||
}; |
@@ -17,73 +17,73 @@ /* jshint -W097 */ | ||
*/ | ||
let shellymotionsensor = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellymotionsensor = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).bat : undefined; } | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).bat : undefined; } | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).lux : undefined; } | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).vibration : undefined; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).lux : undefined; } | ||
'sensor.motion': { | ||
coap: { | ||
coap_publish: '6107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).motion : undefined; } | ||
}, | ||
common: { | ||
'name': 'Motion', | ||
'type': 'boolean', | ||
'role': 'sensor.motion', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
}, | ||
'sensor.vibration': { | ||
coap: { | ||
coap_publish: '6110', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value != 0; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).vibration : undefined; } | ||
}, | ||
common: { | ||
'name': 'Vibration', | ||
'type': 'boolean', | ||
'role': 'sensor', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.motion': { | ||
coap: { | ||
coap_publish: '6107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).motion : undefined; } | ||
}, | ||
common: { | ||
'name': 'Motion', | ||
'type': 'boolean', | ||
'role': 'sensor.motion', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
}; | ||
@@ -93,3 +93,3 @@ | ||
module.exports = { | ||
shellymotionsensor: shellymotionsensor | ||
shellymotionsensor: shellymotionsensor | ||
}; |
@@ -17,165 +17,165 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyplug = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shellyplug = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
}; | ||
@@ -185,3 +185,3 @@ | ||
module.exports = { | ||
shellyplug: shellyplug | ||
shellyplug: shellyplug | ||
}; |
@@ -18,257 +18,257 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyplugs = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shellyplugs = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'led_wifi_disable': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_status_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_status_disable: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_status_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_status_disable: value }; } | ||
}, | ||
common: { | ||
'name': 'Wi-Fi status light.', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
'led_power_disable': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_power_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_power_disable: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_power_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_power_disable: value }; } | ||
}, | ||
common: { | ||
'name': 'Power status light.', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
coap: { | ||
coap_publish: '3105', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
mqtt_publish_funct: (value) => { return shellyHelper.celsiusToFahrenheit(value); } | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'led_wifi_disable': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_status_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_status_disable: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_status_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_status_disable: value }; } | ||
}, | ||
common: { | ||
'name': 'Wi-Fi status light.', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'led_power_disable': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_power_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_power_disable: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).led_power_disable : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { led_power_disable: value }; } | ||
}, | ||
common: { | ||
'name': 'Power status light.', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
}; | ||
@@ -278,3 +278,3 @@ | ||
module.exports = { | ||
shellyplugs: shellyplugs | ||
shellyplugs: shellyplugs | ||
}; |
@@ -20,811 +20,852 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyrgbw2 = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellyrgbw2 = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 5000, | ||
'unit': 'ms' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/color/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'lights.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/color/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 5000, | ||
'unit': 'ms' | ||
} | ||
}, | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': { | ||
0: 'Off', | ||
1: 'Meteor Shower', | ||
2: 'Gradual Change', | ||
3: 'Flash' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
'white0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/0/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/0/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).meters[0].power : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Power 1', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
'white0.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/0/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'white0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
'white0.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'white1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/1', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/1/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/1/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].effect : undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
'white1.brightness': { | ||
coap: { | ||
coap_publish: '5201', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/1', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/1/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/1/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'white1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': '0:Off;1:Meteor Shower;2:Gradual Change;3:Flash' | ||
} | ||
}, | ||
'lights.rgbw': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return shellyHelper.getColorsFromRGBW(value); } | ||
'white1.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/1', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/1', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return await shellyHelper.getRGBW(self) || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(shellyHelper.getColorsFromRGBW(value)); } | ||
'white2.Switch': { | ||
coap: { | ||
coap_publish: '1301', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/2', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/2/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/2/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Color RGBW', | ||
'type': 'string', | ||
'role': 'level.color.rgb', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
'white2.brightness': { | ||
coap: { | ||
coap_publish: '5301', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/2', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/2/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/2/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
'white2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'lights.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await shellyHelper.getColorsFromHue(self); } | ||
'white2.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/2', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/2', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await shellyHelper.getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getColorsFromHue(self)); } | ||
'white3.Switch': { | ||
coap: { | ||
coap_publish: '1401', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/3', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/3/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/3/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'white0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
'white3.brightness': { | ||
coap: { | ||
coap_publish: '5401', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/3', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/3/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/3/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/0/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/0/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
'white3.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'white3.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/3', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/3', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).meters[0].power : undefined; }, | ||
'input': { | ||
coap: { | ||
coap_publish: '118', | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power 1', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'white0.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
'Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/0/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
'EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'white0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action' | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}, | ||
'white0.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/0', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
'white1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/1', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/1/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/1/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'white1.brightness': { | ||
coap: { | ||
coap_publish: '5201', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/1', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/1/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/1/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'white1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'white1.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/1', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/1', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
'white2.Switch': { | ||
coap: { | ||
coap_publish: '1301', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/2', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/2/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/2/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'white2.brightness': { | ||
coap: { | ||
coap_publish: '5301', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/2', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/2/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/2/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'white2.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/2', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'white2.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/2', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/2', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
'white3.Switch': { | ||
coap: { | ||
coap_publish: '1401', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value === 1 ? true : false; }, | ||
http_cmd: '/white/3', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/3/status', | ||
mqtt_publish_funct: (value) => { return value && JSON.parse(value).ison === true; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/3/set', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({ turn: value === true ? 'on' : 'off' }); } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'white3.brightness': { | ||
coap: { | ||
coap_publish: '5401', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'white') return value; }, | ||
http_cmd: '/white/3', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/white/3/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/white/3/set', | ||
mqtt_cmd_funct: async (value) => { return JSON.stringify({ brightness: value }); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'white3.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/white/3', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action' | ||
} | ||
}, | ||
'white3.Transiton': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/3', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].transition : undefined; }, | ||
http_cmd: '/settings/white/3', | ||
http_cmd_funct: (value) => { return { transition: value }; } | ||
}, | ||
common: { | ||
'name': 'Transition Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'unit': 'ms' | ||
} | ||
}, | ||
'input': { | ||
coap: { | ||
coap_publish: '118', | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyrgbw2: shellyrgbw2 | ||
shellyrgbw2: shellyrgbw2 | ||
}; |
@@ -18,277 +18,288 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyrgbww = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellyrgbww = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'color': 'color', | ||
'white': 'white' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'color:color;white:white' | ||
} | ||
}, | ||
'lights.red': { | ||
coap: { | ||
coap_publish: '5105', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { red: value }; } | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).red : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Red', | ||
'type': 'number', | ||
'role': 'level.color.red', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.green': { | ||
coap: { | ||
coap_publish: '5106', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { green: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).green : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Green', | ||
'type': 'number', | ||
'role': 'level.color.green', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': { | ||
0: 'Off', | ||
1: 'Meteor Shower', | ||
2: 'Gradual Change', | ||
3: 'Breath', | ||
4: 'Flash', | ||
5: 'On/Off Gradual', | ||
6: 'Red/Green Change' | ||
} | ||
} | ||
} | ||
}, | ||
'lights.blue': { | ||
coap: { | ||
coap_publish: '5107', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { blue: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).blue : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Blue', | ||
'type': 'number', | ||
'role': 'level.color.blue', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.white': { | ||
coap: { | ||
coap_publish: '5108', // CoAP >= FW 1.8 | ||
coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { white: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).white : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'White', | ||
'type': 'number', | ||
'role': 'level.color.white', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 255 | ||
} | ||
}, | ||
'lights.gain': { | ||
coap: { | ||
coap_publish: '5102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: async (value, self) => { if ((await shellyHelper.getMode(self)) === 'color') return value; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { gain: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).gain : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Gain', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.temp': { | ||
coap: { | ||
coap_publish: '5103', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { temp: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).temp : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'number', | ||
'role': 'level.temperature', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/color/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.effect': { | ||
coap: { | ||
http_publish: '/settings/light/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { effect: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/color/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).effect : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectColor(self)); } | ||
}, | ||
common: { | ||
'name': 'Effect', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100, | ||
'states': '0:Off;1:Meteor Shower;2:Gradual Change;3:Breath;4:Flash;5:On/Off Gradual;6:Red/Green Change' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyrgbww: shellyrgbww | ||
shellyrgbww: shellyrgbww | ||
}; |
@@ -18,125 +18,125 @@ /* jshint -W097 */ | ||
*/ | ||
let shellysense = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellysense = { | ||
'sensor.battery': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'sensor.humidity': { | ||
coap: { | ||
coap_publish: '3103' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/humidity', | ||
}, | ||
common: { | ||
'name': 'Relative humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.humidity': { | ||
coap: { | ||
coap_publish: '3103' // CoAP >= FW 1.8 | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/humidity', | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
common: { | ||
'name': 'Relative humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'sensor.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
'sensor.motion': { | ||
coap: { | ||
coap_publish: '6107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/motion', | ||
}, | ||
common: { | ||
'name': 'Motion', | ||
'type': 'boolean', | ||
'role': 'sensor.motion', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
'sensor.charger': { | ||
coap: { | ||
coap_publish: '3112', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/charger', | ||
}, | ||
common: { | ||
'name': 'External Power', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
} | ||
}, | ||
'sensor.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
}, | ||
'sensor.motion': { | ||
coap: { | ||
coap_publish: '6107', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/motion', | ||
}, | ||
common: { | ||
'name': 'Motion', | ||
'type': 'boolean', | ||
'role': 'sensor.motion', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.charger': { | ||
coap: { | ||
coap_publish: '3112', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/charger', | ||
}, | ||
common: { | ||
'name': 'External Power', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'sensor.lux': { | ||
coap: { | ||
coap_publish: '3106', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/lux', | ||
}, | ||
common: { | ||
'name': 'Illuminance', | ||
'type': 'number', | ||
'role': 'value.brightness', | ||
'read': true, | ||
'write': false, | ||
'unit': 'Lux' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellysense: shellysense | ||
shellysense: shellysense | ||
}; |
@@ -17,80 +17,80 @@ /* jshint -W097 */ | ||
*/ | ||
let shellysmoke = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
const shellysmoke = { | ||
'bat.value': { | ||
coap: { | ||
coap_publish: '3111' // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/battery', | ||
'smoke.value': { | ||
coap: { | ||
coap_publish: '6105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/smoke', | ||
mqtt_publish_funct: (value) => { | ||
return (value === true || value === 1) ? true : false; | ||
} | ||
}, | ||
common: { | ||
'name': 'Smoke detected', | ||
'type': 'boolean', | ||
'role': 'sensor.alarm.fire', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Battery capacity', | ||
'type': 'number', | ||
'role': 'value.battery', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 100, | ||
'unit': '%' | ||
} | ||
}, | ||
'smoke.value': { | ||
coap: { | ||
coap_publish: '6105', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1; } | ||
'tmp.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
// mqtt_publish: 'shellies/<mqttprefix>/sensor/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/sensor/smoke', | ||
mqtt_publish_funct: (value) => { | ||
return (value === true || value === 1) ? true : false; | ||
} | ||
}, | ||
common: { | ||
'name': 'Smoke detected', | ||
'type': 'boolean', | ||
'role': 'sensor.alarm.fire', | ||
'read': true, | ||
'write': false | ||
'tmp.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
// mqtt_publish: 'shellies/<mqttprefix>/sensor/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
} | ||
}, | ||
'tmp.temperatureC': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tC : undefined; }, | ||
// mqtt_publish: 'shellies/<mqttprefix>/sensor/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'tmp.temperatureF': { | ||
coap: { | ||
coap_publish: '3102', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).tmp.tF : undefined; }, | ||
// mqtt_publish: 'shellies/<mqttprefix>/sensor/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellysmoke: shellysmoke | ||
shellysmoke: shellysmoke | ||
}; |
@@ -20,890 +20,931 @@ /* jshint -W097 */ | ||
let shellyswitch = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shellyswitch = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '4102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay1.Energy': { | ||
coap: { | ||
coap_publish: '4104', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
'Relay1.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
'Shutter.state': { | ||
coap: { | ||
coap_publish: '1102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value[0] === 1 ? 'open' : value[1] === 1 ? 'close' : 'stop'; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: (value) => { return { go: value }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command' | ||
}, | ||
common: { | ||
'name': 'Roller state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'close': 'close', | ||
'open': 'open', | ||
'stop': 'stop' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Shutter.Close': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'close' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'close', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'close'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'close' ? true : false; } | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: async (value,self) => { return { go: 'close', duration: await getSetDuration(self, 'Shutter.Duration') } | ||
}, | ||
common: { | ||
'name': 'Close', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Shutter.Open': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'open' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'open', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'open'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'open' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Open', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Shutter.Pause': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'stop' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'stop', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_cmd_funct: () => { return 'stop'; }, | ||
mqtt_publish_funct: (value) => { return value == 'stop' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Pause', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Shutter.Duration': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Shutter.Duration'); } | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Shutter.Position': { | ||
coap: { | ||
coap_publish: '1103', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value == -1 ? 101 : value; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': value, 'duration': await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/pos', | ||
mqtt_publish_funct: (value) => { return value == -1 ? 101 : value; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command/pos', | ||
mqtt_cmd_funct: (value) => { return value.toString(); } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Shutter.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'detached': 'detached' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Shutter.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Shutter.Swap': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
common: { | ||
'name': 'Button Swap', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Shutter.Power': { | ||
coap: { | ||
coap_publish: '4102', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Shutter.Energy': { | ||
coap: { | ||
coap_publish: '4104', | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/energy', | ||
mqtt_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'relay': 'relay', | ||
'roller': 'shutter' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
'Shutter.StopReason': { | ||
coap: { | ||
coap_publish: '6103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status/rollers/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).stop_reason : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Shutter stop reason', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
}, | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '4102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay1.Energy': { | ||
coap: { | ||
coap_publish: '4104', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.overpowerValue': { | ||
coap: { | ||
coap_publish: '6109', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Shutter.state': { | ||
coap: { | ||
coap_publish: '1102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value[0] === 1 ? 'open' : value[1] === 1 ? 'close' : 'stop'; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: (value) => { return { go: value }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command' | ||
}, | ||
common: { | ||
'name': 'Roller state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'close:close;open:open;stop:stop' | ||
} | ||
}, | ||
'Shutter.Close': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'close' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'close', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'close'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'close' ? true : false; } | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: async (value,self) => { return { go: 'close', duration: await getSetDuration(self, 'Shutter.Duration') } | ||
}, | ||
common: { | ||
'name': 'Close', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Open': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'open' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'open', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'open'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'open' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Open', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Pause': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'stop' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'stop', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_cmd_funct: () => { return 'stop'; }, | ||
mqtt_publish_funct: (value) => { return value == 'stop' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Pause', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Duration': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Shutter.Duration'); } | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Shutter.Position': { | ||
coap: { | ||
coap_publish: '1103', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value == -1 ? 101 : value; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': value, 'duration': await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/pos', | ||
mqtt_publish_funct: (value) => { return value == -1 ? 101 : value; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command/pos', | ||
mqtt_cmd_funct: (value) => { return value.toString(); } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%' | ||
} | ||
}, | ||
'Shutter.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;detached:detached' | ||
} | ||
}, | ||
'Shutter.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Shutter.Swap': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
common: { | ||
'name': 'Button Swap', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Shutter.Power': { | ||
coap: { | ||
coap_publish: '4102', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Shutter.Energy': { | ||
coap: { | ||
coap_publish: '4104', | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/energy', | ||
mqtt_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'relay:relay;roller:shutter' | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.StopReason': { | ||
coap: { | ||
coap_publish: '6103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status/rollers/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).stop_reason : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Shutter stop reason', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
} | ||
@@ -913,3 +954,3 @@ }; | ||
module.exports = { | ||
shellyswitch: shellyswitch | ||
shellyswitch: shellyswitch | ||
}; |
@@ -19,1353 +19,1394 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyswitch25 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shellyswitch25 = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Shutter.swap': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
}, | ||
common: { | ||
'name': 'swap OPEN and CLOSE directions', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Shutter.swap_inputs': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap_inputs : undefined; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap_inputs : undefined; } | ||
}, | ||
common: { | ||
'name': 'inputs are swapped', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Shutter.swap': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap : undefined; } | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'swap OPEN and CLOSE directions', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Shutter.swap_inputs': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap_inputs : undefined; } | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].swap_inputs : undefined; } | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
// coap_publish: '6109', // CoAP >= FW 1.8 | ||
no_display: true | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'inputs are swapped', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '4201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay1.Energy': { | ||
coap: { | ||
coap_publish: '4203', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay1.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay1.overpowerValue': { | ||
coap: { | ||
// coap_publish: '6109', // CoAP >= FW 1.8 | ||
no_display: true | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/overpower_value', | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
coap: { | ||
// coap_publish: '6109', // CoAP >= FW 1.8 | ||
no_display: true | ||
'Shutter.state': { | ||
coap: { | ||
coap_publish: '1102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value[0] === 1 ? 'open' : value[1] === 1 ? 'close' : 'stop'; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: (value) => { return { go: value }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command' | ||
}, | ||
common: { | ||
'name': 'Roller state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'close': 'close', | ||
'open': 'open', | ||
'stop': 'stop' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0/overpower_value', | ||
'Shutter.Close': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'close' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'close', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'close'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'close' ? true : false; } | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => async (value,self) => { return { go: 'close', duration: await getSetDuration(self, 'Shutter.Duration') }; } | ||
}, | ||
common: { | ||
'name': 'Close', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
'Shutter.Open': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'open' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'open', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'open'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'open' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Open', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
mqtt_publish_funct: (value) => { return value === 'on'; } | ||
'Shutter.Pause': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'stop' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'stop', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_publish_funct: (value) => { return value == 'stop' ? true : false; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_cmd_funct: () => { return 'stop'; } | ||
}, | ||
common: { | ||
'name': 'Pause', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Shutter.Duration': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Shutter.Duration'); } | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Shutter.Position': { | ||
coap: { | ||
coap_publish: '1103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === -1 ? undefined : value; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': value, 'duration': await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/pos', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command/pos', | ||
mqtt_cmd_funct: (value) => { return value.toString(); }, | ||
mqtt_publish_funct: (value) => { return value == -1 ? 101 : value; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Shutter.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'detached': 'detached' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Shutter.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Shutter.Power': { | ||
coap: { | ||
coap_publish: '4102', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Shutter.Energy': { | ||
coap: { | ||
coap_publish: '4104', | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/energy', | ||
mqtt_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Shutter.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).temperature : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'relay': 'relay', | ||
'roller': 'shutter' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
'ext.temperatureC1': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '0', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
'ext.temperatureC2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '1', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay1.Power': { | ||
coap: { | ||
coap_publish: '4201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'ext.temperatureC3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '2', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
'ext.temperatureF1': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '0', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay1.Energy': { | ||
coap: { | ||
coap_publish: '4203', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
'ext.temperatureF2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '1', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/energy', | ||
mqtt_publish_funct: (value) => { return Math.round((value / 60) * 100) / 100; } | ||
'ext.temperatureF3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '2', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Shutter.StopReason': { | ||
coap: { | ||
coap_publish: '6103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status/rollers/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).stop_reason : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Shutter stop reason', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
'Favorites.Position1Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].name : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].name : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/1', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Favorites.Position1Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].pos : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].pos : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Favorites.Position1': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position1Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position1Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Favorites.Position2Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].name : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].name : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Favorites.Position2Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].pos : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].pos : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Favorites.Position2': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position2Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position2Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Favorites.Position3Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].name : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].name : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Favorites.Position3Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].pos : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].pos : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 1, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
'Favorites.Position3': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position3Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position3Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
'Favorites.Position4Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].name : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].name : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.overpowerValue': { | ||
coap: { | ||
// coap_publish: '6109', // CoAP >= FW 1.8 | ||
no_display: true | ||
'Favorites.Position4Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].pos : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].pos : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1/overpower_value', | ||
'Favorites.Position4': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position4Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position4Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'overpower Value', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'W', | ||
'read': true, | ||
'write': false, | ||
'def': 0 | ||
} | ||
}, | ||
'Shutter.state': { | ||
coap: { | ||
coap_publish: '1102', // CoAP >= FW 1.8 | ||
// coap_publish_funct: (value) => { return value[0] === 1 ? 'open' : value[1] === 1 ? 'close' : 'stop'; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: (value) => { return { go: value }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command' | ||
}, | ||
common: { | ||
'name': 'Roller state', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'close:close;open:open;stop:stop' | ||
} | ||
}, | ||
'Shutter.Close': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'close' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'close', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; }, | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'close'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'close' ? true : false; } | ||
// http_publish: '/settings', | ||
// http_publish_funct: (value) => { return JSON.parse(value) ? JSON.parse(value).rollers.maxtime : undefined; }, | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => async (value,self) => { return { go: 'close', duration: await getSetDuration(self, 'Shutter.Duration') }; } | ||
}, | ||
common: { | ||
'name': 'Close', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Open': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'open' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'open', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_cmd_funct: () => { return 'open'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_publish_funct: (value) => { return value == 'open' ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Open', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Pause': { | ||
coap: { | ||
// http_cmd: '/roller/0', | ||
// http_cmd_funct: () => { return { go: 'stop' }; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { go: 'stop', duration: await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0', | ||
mqtt_publish_funct: (value) => { return value == 'stop' ? true : false; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command', | ||
mqtt_cmd_funct: () => { return 'stop'; } | ||
}, | ||
common: { | ||
'name': 'Pause', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.Duration': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Shutter.Duration'); } | ||
// http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].maxtime : undefined; }, | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Shutter.Position': { | ||
coap: { | ||
coap_publish: '1103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === -1 ? undefined : value; }, | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': value, 'duration': await shellyHelper.getSetDuration(self, 'Shutter.Duration', 0) }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/pos', | ||
mqtt_cmd: 'shellies/<mqttprefix>/roller/0/command/pos', | ||
mqtt_cmd_funct: (value) => { return value.toString(); }, | ||
mqtt_publish_funct: (value) => { return value == -1 ? 101 : value; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%' | ||
} | ||
}, | ||
'Shutter.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].button_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;detached:detached' | ||
} | ||
}, | ||
'Shutter.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/roller/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Shutter.Power': { | ||
coap: { | ||
coap_publish: '4102', | ||
coap_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/power', | ||
mqtt_publish_funct: (value) => { return (Math.round(value * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Shutter.Energy': { | ||
coap: { | ||
coap_publish: '4104', | ||
coap_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/roller/0/energy', | ||
mqtt_publish_funct: (value) => { return (Math.round((value / 60) * 100) / 100); } | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Shutter.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).rollers[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'temperatureC': { | ||
coap: { | ||
coap_publish: '3104', // CoAP >= FW 1.8 | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).temperature : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/temperature', | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'overtemperature': { | ||
coap: { | ||
coap_publish: '6101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/overtemperature', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Temperature', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'mode': { | ||
coap: { | ||
coap_publish: '9101', // CoAP >= FW 1.8 | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).mode : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { mode: value }; } | ||
}, | ||
common: { | ||
'name': 'Modus', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'relay:relay;roller:shutter' | ||
} | ||
}, | ||
'ext.temperatureC1': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '0', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '1', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '2', 'C') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF1': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '0', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF2': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '1', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureF3': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? shellyHelper.getExtTemp(JSON.parse(value), '2', 'F') : undefined; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature_f/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°F', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'factoryResetFromSwitch': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).factory_reset_from_switch : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { factory_reset_from_switch: value }; } | ||
}, | ||
common: { | ||
'name': 'Factory reset from switch', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Shutter.StopReason': { | ||
coap: { | ||
coap_publish: '6103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
http_publish: '/status/rollers/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).stop_reason : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Shutter stop reason', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Favorites.Position1Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].name : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].name : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position1Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].pos : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[0].pos : undefined; }, | ||
http_cmd: '/settings/favorites/0', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
'Favorites.Position1': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position1Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position1Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position2Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].name : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].name : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position2Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].pos : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[1].pos : undefined; }, | ||
http_cmd: '/settings/favorites/1', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
'Favorites.Position2': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position2Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position2Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position3Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].name : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].name : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position3Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].pos : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[2].pos : undefined; }, | ||
http_cmd: '/settings/favorites/2', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
'Favorites.Position3': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position3Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position3Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position4Name' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].name : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].name : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Position Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Favorites.Position4Pos' : { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].pos : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).favorites[3].pos : undefined; }, | ||
http_cmd: '/settings/favorites/3', | ||
http_cmd_funct: (value) => { return { pos: value }; } | ||
}, | ||
common: { | ||
'name': 'Position', | ||
'type': 'number', | ||
'role': 'level.blind', | ||
'read': true, | ||
'write': true, | ||
'unit': '%', | ||
'min': 0, | ||
'max': 100 | ||
}, | ||
}, | ||
'Favorites.Position4': { | ||
coap: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position4Pos') }; } | ||
}, | ||
mqtt: { | ||
http_cmd: '/roller/0', | ||
http_cmd_funct: async (value, self) => { return { 'go': 'to_pos', 'roller_pos': await shellyHelper.getFavoritePosition(self, 'Favorites.Position4Pos') }; } | ||
}, | ||
common: { | ||
'name': 'Set favorite position', | ||
'type': 'boolean', | ||
'role': 'button', | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
}; | ||
module.exports = { | ||
shellyswitch25: shellyswitch25 | ||
shellyswitch25: shellyswitch25 | ||
}; |
@@ -17,675 +17,704 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyuni = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
const shellyuni = { | ||
'Relay0.Switch': { | ||
coap: { | ||
coap_publish: '1101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay0.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/0', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay0.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Event': { | ||
coap: { | ||
coap_publish: '2102' // CoAP >= 1.8 | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay0.EventCount': { | ||
coap: { | ||
coap_publish: '2103' // CoAP >= 1.8 | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpush': { | ||
coap: { | ||
coap_publish: '2102', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.Input': { | ||
coap: { | ||
coap_publish: '2101', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay0.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].source : undefined; }, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
'S': '1xShort', | ||
'L': 'Long' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Input', | ||
1: 'Detach' | ||
} | ||
//'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay0.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay1.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay0.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/0', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[0].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
'momentary': 'momentary', | ||
'toggle': 'toggle', | ||
'edge': 'edge', | ||
'detached': 'detached', | ||
'action': 'action', | ||
'cycle': 'cycle', | ||
'momentary_on_release': 'momentary_on_release' | ||
} | ||
} | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay0.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay0.Timer'); } | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': { | ||
0: 'normal', | ||
1: 'inverted' | ||
} | ||
} | ||
}, | ||
mqtt: { | ||
no_display: true | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'Relay1.Switch': { | ||
coap: { | ||
coap_publish: '1201', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 ? true : false; }, | ||
http_cmd: '/relay/1', | ||
http_cmd_funct: async (value, self) => { return value === true ? { turn: 'on', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') } : { turn: 'off', timer: await shellyHelper.getSetDuration(self, 'Relay1.Timer') }; } | ||
'ADC.Power': { | ||
coap: { | ||
coap_publish: '3118' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/adc/0', | ||
mqtt_publish_funct: (value) => { return value ? parseFloat(value) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Power Measurement', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 30, | ||
'unit': 'V' | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/relay/1', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/relay/1/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'ADC.Range': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).adcs[0].range : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).adcs[0].range : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Power Range', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 30, | ||
'unit': 'V' | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.ChannelName': { | ||
coap: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings/relay/1', | ||
http_publish_funct: async (value, self) => { return value ? await shellyHelper.setChannelName(self, 'Relay1.ChannelName', JSON.parse(value).name) : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { name: value }; } | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Channel Name', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.Event': { | ||
coap: { | ||
coap_publish: '2202' // CoAP >= 1.8 | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event : undefined; } | ||
'ext.temperatureC4': { | ||
coap: { | ||
coap_publish: '3401', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/3', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Event', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': 'S:1xShort;L:Long' | ||
} | ||
}, | ||
'Relay1.EventCount': { | ||
coap: { | ||
coap_publish: '2203' // CoAP >= 1.8 | ||
'ext.temperatureC5': { | ||
coap: { | ||
coap_publish: '3501', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/4', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input_event/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).event_cnt : undefined; } | ||
'ext.humidity': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'unit': '%' | ||
} | ||
}, | ||
common: { | ||
'name': 'Event Counter', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.longpush': { | ||
coap: { | ||
coap_publish: '2202', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value == 'L' ? true : false; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/longpush/0', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; } | ||
}, | ||
common: { | ||
'name': 'Longpush', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.longpushtime': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).longpush_time : undefined; }, | ||
http_cmd: '/settings', | ||
http_cmd_funct: (value) => { return { longpush_time: value }; } | ||
}, | ||
common: { | ||
'name': 'Longpush Time', | ||
'type': 'number', | ||
'role': 'state', | ||
'unit': 'ms', | ||
'min': 800, | ||
'max': 5000, | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.Input': { | ||
coap: { | ||
coap_publish: '2201', // Coap >= FW 1.8 | ||
coap_publish_funct: (value) => { return value === 1 || value === 2 ? true : false; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/input/1', | ||
mqtt_publish_funct: (value) => { return value == 1 ? true : false; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay1.source': { | ||
coap: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/status', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].source : undefined; }, | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_off : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].auto_on : undefined; }, | ||
http_cmd: '/settings/relay/1', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'Relay1.ButtonType': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_type : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_type: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': 'momentary:momentary;toggle:toggle;edge:edge;detached:detached;action:action;cycle:cycle;momentary_on_release:momentary_on_release' | ||
} | ||
}, | ||
'Relay1.ButtonReverse': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_cmd: '/settings/relay/1', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).relays[1].btn_reverse : undefined; }, | ||
http_cmd_funct: (value) => { return { btn_reverse: value }; } | ||
}, | ||
common: { | ||
'name': 'Button Type', | ||
'type': 'number', | ||
'role': 'state', | ||
'read': true, | ||
'write': true, | ||
'states': '0:normal;1:inverted' | ||
} | ||
}, | ||
'Relay1.Timer': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: async (value, self) => { return await shellyHelper.getSetDuration(self, 'Relay1.Timer'); } | ||
}, | ||
mqtt: { | ||
no_display: true | ||
}, | ||
common: { | ||
'name': 'Duration', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'read': true, | ||
'write': true, | ||
'def': 0, | ||
'unit': 's' | ||
} | ||
}, | ||
'ADC.Power': { | ||
coap: { | ||
coap_publish: '3118' // CoAP >= 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/adc/0', | ||
mqtt_publish_funct: (value) => { return value ? parseFloat(value) : undefined; } | ||
}, | ||
common: { | ||
'name': 'Power Measurement', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 30, | ||
'unit': 'V' | ||
} | ||
}, | ||
'ADC.Range': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).adcs[0].range : undefined; }, | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).adcs[0].range : undefined; }, | ||
}, | ||
common: { | ||
'name': 'Power Range', | ||
'type': 'number', | ||
'role': 'value.voltage', | ||
'read': true, | ||
'write': false, | ||
'min': 0, | ||
'max': 30, | ||
'unit': 'V' | ||
} | ||
}, | ||
'ext.temperatureC1': { | ||
coap: { | ||
coap_publish: '3101', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC2': { | ||
coap: { | ||
coap_publish: '3201', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/1', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC3': { | ||
coap: { | ||
coap_publish: '3301', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/2', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC4': { | ||
coap: { | ||
coap_publish: '3401', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/3', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.temperatureC5': { | ||
coap: { | ||
coap_publish: '3501', // CoAP >= FW 1.8 | ||
//coap_publish_funct: (value) => { return value; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_temperature/4', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.-]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Temperature', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'unit': '°C', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'ext.humidity': { | ||
coap: { | ||
coap_publish: '3103', // CoAP >= FW 1.8 | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/ext_humidity/0', | ||
mqtt_publish_funct: (value) => { return String(value).replace(/[^0-9\.]/g, ''); } | ||
}, | ||
common: { | ||
'name': 'External Humidity', | ||
'type': 'number', | ||
'role': 'value.humidity', | ||
'read': true, | ||
'write': false, | ||
'unit': '%' | ||
} | ||
}, | ||
}; | ||
module.exports = { | ||
shellyuni: shellyuni | ||
shellyuni: shellyuni | ||
}; |
@@ -17,135 +17,135 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyvintage = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
const shellyvintage = { | ||
'lights.Switch': { | ||
coap: { | ||
coap_publish: '1101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value ? true : false; }, | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0', | ||
mqtt_publish_funct: (value) => { return value === 'on'; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/command', | ||
mqtt_cmd_funct: (value) => { return value === true ? 'on' : 'off'; }, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'lights.AutoTimerOff': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_off : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_off: value }; } | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
} | ||
}, | ||
'lights.AutoTimerOn': { | ||
coap: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
'lights.power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return value; }, | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
mqtt: { | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).lights[0].auto_on : undefined; }, | ||
http_cmd: '/settings/light/0', | ||
http_cmd_funct: (value) => { return { auto_on: value }; } | ||
}, | ||
common: { | ||
'name': 'Auto Timer Off', | ||
'type': 'number', | ||
'role': 'level.timer', | ||
'def': 0, | ||
'unit': 's', | ||
'read': true, | ||
'write': true | ||
'lights.energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/energy', | ||
mqtt_publish_funct: (value) => { return value; }, | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wmin' | ||
} | ||
} | ||
}, | ||
'lights.brightness': { | ||
coap: { | ||
coap_publish: '5101', // CoAP >= FW 1.8 | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/status', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).brightness : undefined; }, | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await shellyHelper.getLightsObjectWhite(self)); } | ||
}, | ||
common: { | ||
'name': 'Brightness', | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'read': true, | ||
'write': true, | ||
'min': 0, | ||
'max': 100 | ||
} | ||
}, | ||
'lights.power': { | ||
coap: { | ||
coap_publish: '4101', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/power', | ||
mqtt_publish_funct: (value) => { return value; }, | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'lights.energy': { | ||
coap: { | ||
coap_publish: '4103', // CoAP >= FW 1.8 | ||
coap_publish_funct: (value) => { return value; }, | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/light/0/energy', | ||
mqtt_publish_funct: (value) => { return value; }, | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wmin' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyvintage: shellyvintage | ||
shellyvintage: shellyvintage | ||
}; |
@@ -13,10 +13,10 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyplus1 = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
const shellyplus1 = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -26,26 +26,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'output') | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 1, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 0, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 1, "src": "iobroker", "method": "Switch.Set", "params": {"id": 0, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -55,38 +55,36 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'source') | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'temperatureC': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'temperatureC': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -96,24 +94,24 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'temperature') | ||
) { | ||
return valueObj.params['switch:0'].temperature.tC; | ||
) { | ||
return valueObj.params['switch:0'].temperature.tC; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'temperatureF': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -123,21 +121,21 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'temperature') | ||
) { | ||
return valueObj.params['switch:0'].temperature.tF; | ||
) { | ||
return valueObj.params['switch:0'].temperature.tF; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyplus1: shellyplus1 | ||
shellyplus1: shellyplus1 | ||
}; |
@@ -13,10 +13,10 @@ /* jshint -W097 */ | ||
*/ | ||
let shellyplus1pm = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
const shellyplus1pm = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -26,26 +26,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'output') | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 1, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 0, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 1, "src": "iobroker", "method": "Switch.Set", "params": {"id": 0, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -55,38 +55,36 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'source') | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay0.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -96,25 +94,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'apower') | ||
) { | ||
return valueObj.params['switch:0'].apower; | ||
) { | ||
return valueObj.params['switch:0'].apower; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -124,25 +122,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'aenergy') | ||
) { | ||
return valueObj.params['switch:0'].aenergy.total; | ||
) { | ||
return valueObj.params['switch:0'].aenergy.total; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'temperatureC': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'temperatureC': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -152,24 +150,24 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'temperature') | ||
) { | ||
return valueObj.params['switch:0'].temperature.tC; | ||
) { | ||
return valueObj.params['switch:0'].temperature.tC; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °C', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°C' | ||
} | ||
}, | ||
'temperatureF': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'temperatureF': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -179,21 +177,21 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'temperature') | ||
) { | ||
return valueObj.params['switch:0'].temperature.tF; | ||
) { | ||
return valueObj.params['switch:0'].temperature.tF; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Temperature °F', | ||
'type': 'number', | ||
'role': 'value.temperature', | ||
'read': true, | ||
'write': false, | ||
'unit': '°F' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellyplus1pm: shellyplus1pm | ||
shellyplus1pm: shellyplus1pm | ||
}; |
@@ -13,10 +13,10 @@ /* jshint -W097 */ | ||
*/ | ||
let shellypro4pm = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
const shellypro4pm = { | ||
'Relay0.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -26,26 +26,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'output') | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
) { | ||
return valueObj.params['switch:0'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 1, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 0, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 1, "src": "iobroker", "method": "Switch.Set", "params": {"id": 0, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -55,38 +55,36 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'source') | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
) { | ||
return valueObj.params['switch:0'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay0.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:0', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; } | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay0.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -96,25 +94,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'apower') | ||
) { | ||
return valueObj.params['switch:0'].apower; | ||
) { | ||
return valueObj.params['switch:0'].apower; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay0.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay0.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -124,25 +122,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:0'], 'aenergy') | ||
) { | ||
return valueObj.params['switch:0'].aenergy.total; | ||
) { | ||
return valueObj.params['switch:0'].aenergy.total; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay1.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay1.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -152,26 +150,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:1'], 'output') | ||
) { | ||
return valueObj.params['switch:1'].output; | ||
) { | ||
return valueObj.params['switch:1'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 2, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 1, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 2, "src": "iobroker", "method": "Switch.Set", "params": {"id": 1, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay1.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay1.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -181,38 +179,41 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:1'], 'source') | ||
) { | ||
return valueObj.params['switch:1'].source; | ||
) { | ||
return valueObj.params['switch:1'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay1.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:1', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay1.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:1', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Input', | ||
1: 'Detach' | ||
} | ||
//'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay1.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay1.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -222,25 +223,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:1'], 'apower') | ||
) { | ||
return valueObj.params['switch:1'].apower; | ||
) { | ||
return valueObj.params['switch:1'].apower; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay1.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay1.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -250,25 +251,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:1'], 'aenergy') | ||
) { | ||
return valueObj.params['switch:1'].aenergy.total; | ||
) { | ||
return valueObj.params['switch:1'].aenergy.total; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay2.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay2.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -278,26 +279,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:2'], 'output') | ||
) { | ||
return valueObj.params['switch:2'].output; | ||
) { | ||
return valueObj.params['switch:2'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 3, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 2, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 3, "src": "iobroker", "method": "Switch.Set", "params": {"id": 2, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay2.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay2.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -307,38 +308,41 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:2'], 'source') | ||
) { | ||
return valueObj.params['switch:2'].source; | ||
) { | ||
return valueObj.params['switch:2'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay2.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:2', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay2.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:2', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Input', | ||
1: 'Detach' | ||
} | ||
//'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay2.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay2.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -348,25 +352,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:2'], 'apower') | ||
) { | ||
return valueObj.params['switch:2'].apower; | ||
) { | ||
return valueObj.params['switch:2'].apower; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay2.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay2.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -376,25 +380,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:2'], 'aenergy') | ||
) { | ||
return valueObj.params['switch:2'].aenergy.total; | ||
) { | ||
return valueObj.params['switch:2'].aenergy.total; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
}, | ||
'Relay3.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay3.Switch': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -404,26 +408,26 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:3'], 'output') | ||
) { | ||
return valueObj.params['switch:3'].output; | ||
) { | ||
return valueObj.params['switch:3'].output; | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({'id': 4, 'src': 'iobroker', 'method': 'Switch.Set', 'params': {'id': 3, 'on': value}}); }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
return undefined; | ||
}, | ||
mqtt_cmd: '<mqttprefix>/rpc', | ||
mqtt_cmd_funct: (value) => { return JSON.stringify({"id": 4, "src": "iobroker", "method": "Switch.Set", "params": {"id": 3, "on": value}}) }, | ||
}, | ||
common: { | ||
'name': 'Switch', | ||
'type': 'boolean', | ||
'role': 'switch', | ||
'read': true, | ||
'write': true, | ||
'def': false | ||
} | ||
}, | ||
'Relay3.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay3.source': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -433,38 +437,41 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:3'], 'source') | ||
) { | ||
return valueObj.params['switch:3'].source; | ||
) { | ||
return valueObj.params['switch:3'].source; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'source of last command', | ||
'type': 'string', | ||
'role': 'state', | ||
'read': true, | ||
'write': false | ||
} | ||
}, | ||
'Relay3.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:3', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
'Relay3.Input': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/status/input:3', | ||
mqtt_publish_funct: (value) => { return JSON.parse(value).state; }, | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': { | ||
0: 'Input', | ||
1: 'Detach' | ||
} | ||
//'def': false | ||
} | ||
}, | ||
common: { | ||
'name': 'Input / Detach', | ||
'type': 'boolean', | ||
'role': 'state', | ||
'read': true, | ||
'write': false, | ||
'states': '0:Input;1:Detach' | ||
//'def': false | ||
} | ||
}, | ||
'Relay3.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay3.Power': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -474,25 +481,25 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:3'], 'apower') | ||
) { | ||
return valueObj.params['switch:3'].apower; | ||
) { | ||
return valueObj.params['switch:3'].apower; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Power', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'W' | ||
} | ||
}, | ||
'Relay3.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
'Relay3.Energy': { | ||
mqtt: { | ||
mqtt_publish: '<mqttprefix>/events/rpc', | ||
mqtt_publish_funct: (value) => { | ||
const valueObj = JSON.parse(value); | ||
if ( | ||
Object.prototype.hasOwnProperty.call(valueObj, 'method') && | ||
valueObj.method === 'NotifyStatus' && | ||
@@ -502,22 +509,22 @@ Object.prototype.hasOwnProperty.call(valueObj, 'params') && | ||
Object.prototype.hasOwnProperty.call(valueObj.params['switch:3'], 'aenergy') | ||
) { | ||
return valueObj.params['switch:3'].aenergy.total; | ||
) { | ||
return valueObj.params['switch:3'].aenergy.total; | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
return undefined; | ||
} | ||
}, | ||
common: { | ||
'name': 'Energy', | ||
'type': 'number', | ||
'role': 'value.power', | ||
'read': true, | ||
'write': false, | ||
'def': 0, | ||
'unit': 'Wh' | ||
} | ||
} | ||
}; | ||
module.exports = { | ||
shellypro4pm: shellypro4pm | ||
shellypro4pm: shellypro4pm | ||
}; |
@@ -113,3 +113,3 @@ /* jshint -W097 */ | ||
if (this.adapter.config.polltime == 0) return 0; | ||
let deviceid = this.getDeviceId(); | ||
const deviceid = this.getDeviceId(); | ||
let polltime = undefined; | ||
@@ -143,2 +143,24 @@ | ||
/** | ||
* Change Device ID from #2 to #1 (fimrware verson >= 1.8) | ||
* Example SHRGBW2#1234#2 will change to SHRGBW2#1234#1 | ||
*/ | ||
getOldDeviceInfo(devicename) { | ||
if (devicename && devicename.substr(-2) === '#2') { | ||
return devicename.substr(0, devicename.length - 2) + '#1'; | ||
} else { | ||
return devicename; | ||
} | ||
} | ||
/** | ||
* Get the Shelly Device type with the serialnumber of the device back. | ||
* Device type could be for example SHRGBW2. The serial number of the | ||
* device like 1234 will be added | ||
* Example: SHRGBW2#1234#1 | ||
*/ | ||
getDeviceName() { | ||
return this.devicename ? this.getOldDeviceInfo(this.devicename) : undefined; | ||
} | ||
/** | ||
* Checks if Shelly device type in the configuration exist. If missing | ||
@@ -161,3 +183,3 @@ * you have to add a configuration in the ./lib/devices direcotory | ||
if (this.devicegen === undefined) { | ||
let deviceid = this.getDeviceId(); | ||
const deviceid = this.getDeviceId(); | ||
this.devicegen = datapoints.getDeviceGen(deviceid); | ||
@@ -169,2 +191,6 @@ } | ||
isOnline() { | ||
return this.adapter.isOnline(this.getDeviceName()); | ||
} | ||
/** | ||
@@ -174,3 +200,3 @@ * Missing data will be pulled by http | ||
async httpIoBrokerState() { | ||
if (!this.adapter.isOnline(this.getDeviceName())) { | ||
if (!this.isOnline()) { | ||
this.httpIoBrokerStateTimeout = setTimeout(async () => await this.httpIoBrokerState(), this.adapter.config.polltime * 1000); | ||
@@ -181,11 +207,11 @@ return; | ||
let polltime = this.getPolltime(); | ||
for (let i in this.http) { | ||
let states = this.http[i]; | ||
for (const i in this.http) { | ||
const states = this.http[i]; | ||
try { | ||
let body = await this.requestAsync('http://' + this.getIP() + i); | ||
for (let j in states) { | ||
let state = this.device[states[j]]; | ||
const body = await this.requestAsync('http://' + this.getIP() + i); | ||
for (const j in states) { | ||
const state = this.device[states[j]]; | ||
if (state && state.state) { | ||
let deviceid = this.getDeviceName(); | ||
let stateid = deviceid + '.' + state.state; | ||
const deviceid = this.getDeviceName(); | ||
const stateid = deviceid + '.' + state.state; | ||
let value = body; | ||
@@ -217,3 +243,3 @@ try { | ||
} else { | ||
this.adapter.log.error(`Error in function httpIoBrokerState for state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`Error in function httpIoBrokerState for state ${stateid} for ${this.getName()}: ${error} - value: "${value}"`); | ||
} | ||
@@ -242,141 +268,148 @@ } | ||
return new Promise((resolve, reject) => { | ||
if (Object.keys(this.device).length === 0) { | ||
let devices = datapoints.getDeviceByType(this.getDeviceId(), this.type); | ||
if (devices) { | ||
if (this.type === 'coap') { | ||
devices = recursiveSubStringReplace(devices, new RegExp('<devicetype>', 'g'), this.getDeviceId()); | ||
devices = recursiveSubStringReplace(devices, new RegExp('<deviceid>', 'g'), this.getSerialId()); | ||
} | ||
if (this.type === 'mqtt') { | ||
devices = recursiveSubStringReplace(devices, new RegExp('<mqttprefix>', 'g'), this.mqttprefix); | ||
} | ||
for (let j in devices) { | ||
let hasTypeCmd = false; | ||
let hasTypePublishCmd = false; | ||
let statename = j; | ||
let state = devices[statename]; | ||
state.state = statename; | ||
try { | ||
if (Object.keys(this.device).length === 0) { | ||
let devices = datapoints.getDeviceByType(this.getDeviceId(), this.type); | ||
if (devices) { | ||
if (this.type === 'coap') { | ||
hasTypeCmd = !!state.coap.coap_cmd; | ||
hasTypePublishCmd = !!state.coap.coap_publish; | ||
devices = recursiveSubStringReplace(devices, new RegExp('<devicetype>', 'g'), this.getDeviceId()); | ||
devices = recursiveSubStringReplace(devices, new RegExp('<deviceid>', 'g'), this.getSerialId()); | ||
} | ||
if (this.type === 'mqtt') { | ||
hasTypeCmd = !!state.mqtt.mqtt_cmd; | ||
hasTypePublishCmd = !!state.mqtt.mqtt_publish | ||
devices = recursiveSubStringReplace(devices, new RegExp('<mqttprefix>', 'g'), this.mqttprefix); | ||
} | ||
let deviceid = this.getDeviceName(); | ||
if (!this.states[deviceid] || this.states[deviceid] !== deviceid) { | ||
this.states[deviceid] = deviceid; | ||
this.objectHelper.setOrUpdateObject(deviceid, { | ||
type: 'device', | ||
common: { | ||
name: 'Device ' + deviceid | ||
}, | ||
native: {} | ||
}, ['name']); | ||
} | ||
let channel = statename.split('.').slice(0, 1).join(); | ||
if (channel !== statename) { | ||
let channelid = deviceid + '.' + channel; | ||
if (!this.states[channelid] || this.states[channelid] !== channelid) { | ||
this.states[channelid] = channelid; | ||
this.objectHelper.setOrUpdateObject(channelid, { | ||
type: 'channel', | ||
for (const j in devices) { | ||
let hasTypeCmd = false; | ||
let hasTypePublishCmd = false; | ||
const statename = j; | ||
const state = devices[statename]; | ||
state.state = statename; | ||
if (this.type === 'coap') { | ||
hasTypeCmd = !!state.coap.coap_cmd; | ||
hasTypePublishCmd = !!state.coap.coap_publish; | ||
} | ||
if (this.type === 'mqtt') { | ||
hasTypeCmd = !!state.mqtt.mqtt_cmd; | ||
hasTypePublishCmd = !!state.mqtt.mqtt_publish; | ||
} | ||
const deviceid = this.getDeviceName(); | ||
if (!this.states[deviceid] || this.states[deviceid] !== deviceid) { | ||
this.states[deviceid] = deviceid; | ||
this.objectHelper.setOrUpdateObject(deviceid, { | ||
type: 'device', | ||
common: { | ||
name: 'Channel ' + channel | ||
} | ||
name: 'Device ' + deviceid | ||
}, | ||
native: {} | ||
}, ['name']); | ||
} | ||
} | ||
let stateid = deviceid + '.' + statename; | ||
let controlFunction; | ||
const channel = statename.split('.').slice(0, 1).join(); | ||
if (channel !== statename) { | ||
const channelid = deviceid + '.' + channel; | ||
if (!this.states[channelid] || this.states[channelid] !== channelid) { | ||
this.states[channelid] = channelid; | ||
this.objectHelper.setOrUpdateObject(channelid, { | ||
type: 'channel', | ||
common: { | ||
name: 'Channel ' + channel | ||
} | ||
}, ['name']); | ||
} | ||
} | ||
const stateid = deviceid + '.' + statename; | ||
let controlFunction; | ||
if (state[this.type] && state[this.type].http_cmd && !hasTypeCmd) { | ||
this.adapter.log.silly(`[http controlFunction] Found ${this.type}.http_cmd of state ${stateid} for ${this.getName()}`); | ||
controlFunction = async (value) => { | ||
this.adapter.log.silly(`[http controlFunction] Entered ${this.type}.http_cmd of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
if (state[this.type] && state[this.type].http_cmd && !hasTypeCmd) { | ||
this.adapter.log.silly(`[http controlFunction] Found ${this.type}.http_cmd of state ${stateid} for ${this.getName()}`); | ||
controlFunction = async (value) => { | ||
this.adapter.log.silly(`[http controlFunction] Entered ${this.type}.http_cmd of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
if (state[this.type] && state[this.type].http_cmd_funct) { | ||
try { | ||
value = isAsync(state[this.type].http_cmd_funct) ? await state[this.type].http_cmd_funct(value, this) : state[this.type].http_cmd_funct(value, this); | ||
this.adapter.log.debug(`[http controlFunction] Executing state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
} catch (error) { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
if (state[this.type] && state[this.type].http_cmd_funct) { | ||
try { | ||
value = isAsync(state[this.type].http_cmd_funct) ? await state[this.type].http_cmd_funct(value, this) : state[this.type].http_cmd_funct(value, this); | ||
this.adapter.log.debug(`[http controlFunction] Executing state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()} with value: ${JSON.stringify(value)}`); | ||
} catch (error) { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
} | ||
let body; | ||
try { | ||
// Append value parameters | ||
var url = new URL('http://' + this.getIP() + state[this.type].http_cmd); | ||
Object.keys(value).forEach(key => url.searchParams.append(key, value[key])); | ||
let body; | ||
try { | ||
// Append value parameters | ||
const url = new URL('http://' + this.getIP() + state[this.type].http_cmd); | ||
if (typeof value === 'object') { | ||
Object.keys(value).forEach(key => url.searchParams.append(key, value[key])); | ||
} | ||
body = await this.requestAsync(url); | ||
this.adapter.log.debug(`[http controlFunction] Executing state.${this.type}.http_cmd of state ${stateid} for ${this.getName()} from url: ${url.href}`); | ||
body = await this.requestAsync(url.href); | ||
if (body === 'Bad default state and button type combination!') { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${body}`); | ||
if (body === 'Bad default state and button type combination!') { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${body}`); | ||
} | ||
} catch (error) { | ||
if (body && body === '401 Unauthorized') { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: Wrong http username or http password! Please enter user credentials for restricted login.`); | ||
} else { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
} catch (error) { | ||
if (body && body === '401 Unauthorized') { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: Wrong http username or http password! Please enter user credentials for restricted login.`); | ||
} else { | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
delete this.states[stateid]; | ||
}; | ||
} | ||
delete this.states[stateid]; | ||
}; | ||
} | ||
// MQTT | ||
if (this.type === 'mqtt' && state[this.type] && hasTypeCmd) { | ||
this.adapter.log.silly(`[mqtt controlFunction] Found ${this.type}.mqtt_cmd of state ${stateid} for ${this.getName()}`); | ||
controlFunction = async (value) => { | ||
let cmd = state[this.type].mqtt_cmd; | ||
if (state[this.type] && state[this.type].mqtt_cmd_funct) { | ||
try { | ||
value = isAsync(state[this.type].mqtt_cmd_funct) ? await state[this.type].mqtt_cmd_funct(value, this) : state[this.type].mqtt_cmd_funct(value, this); | ||
this.adapter.log.debug(`[mqtt controlFunction] Executing state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
} catch (error) { | ||
this.adapter.log.error(`[mqtt controlFunction] Error in function state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
// MQTT | ||
if (this.type === 'mqtt' && state[this.type] && hasTypeCmd) { | ||
this.adapter.log.silly(`[mqtt controlFunction] Found ${this.type}.mqtt_cmd of state ${stateid} for ${this.getName()}`); | ||
controlFunction = async (value) => { | ||
const cmd = state[this.type].mqtt_cmd; | ||
if (state[this.type] && state[this.type].mqtt_cmd_funct) { | ||
try { | ||
value = isAsync(state[this.type].mqtt_cmd_funct) ? await state[this.type].mqtt_cmd_funct(value, this) : state[this.type].mqtt_cmd_funct(value, this); | ||
this.adapter.log.debug(`[mqtt controlFunction] Executing state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
} catch (error) { | ||
this.adapter.log.error(`[mqtt controlFunction] Error in function state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
} | ||
this.sendState2Client(cmd, value, this.adapter.config.qos); // TODO: Abstract method? | ||
this.sendState2Client(cmd, value, this.adapter.config.qos); // TODO: Abstract method? | ||
delete this.states[stateid]; | ||
}; | ||
} | ||
delete this.states[stateid]; | ||
}; | ||
} | ||
if (state[this.type] && state[this.type].http_publish && !hasTypePublishCmd) { | ||
if (!this.http[state[this.type].http_publish]) this.http[state[this.type].http_publish] = []; | ||
this.http[state[this.type].http_publish].push(statename); | ||
} | ||
if (state[this.type] && state[this.type].http_publish && !hasTypePublishCmd) { | ||
if (!this.http[state[this.type].http_publish]) this.http[state[this.type].http_publish] = []; | ||
this.http[state[this.type].http_publish].push(statename); | ||
} | ||
// Init value | ||
let value; | ||
// Init value | ||
let value; | ||
if (this.type === 'coap' && state.coap.coap_init_value) { | ||
value = state.coap.coap_init_value; | ||
} | ||
if (this.type === 'coap' && state.coap.coap_init_value) { | ||
value = state.coap.coap_init_value; | ||
} | ||
if (this.type === 'mqtt' && state.mqtt.mqtt_init_value) { | ||
value = state.mqtt.mqtt_init_value; | ||
if (this.type === 'mqtt' && state.mqtt.mqtt_init_value) { | ||
value = state.mqtt.mqtt_init_value; | ||
} | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: state.common | ||
}, ['name'], value, controlFunction); | ||
} | ||
this.device = devices; | ||
} | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: state.common | ||
}, ['name'], value, controlFunction); | ||
} | ||
this.device = devices; | ||
this.objectHelper.processObjectQueue(() => { | ||
resolve(); | ||
}); | ||
} | ||
this.objectHelper.processObjectQueue(() => { | ||
resolve(); | ||
}); | ||
} catch (err) { | ||
reject(err); | ||
} | ||
@@ -391,5 +424,5 @@ }); | ||
async deleteOldStates() { | ||
let id = this.adapter.namespace + '.' + this.getDeviceName(); | ||
let obj = await this.adapter.getAdapterObjectsAsync(); | ||
let devicetype = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
const id = this.adapter.namespace + '.' + this.getDeviceName(); | ||
const obj = await this.adapter.getAdapterObjectsAsync(); | ||
const devicetype = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
@@ -400,6 +433,6 @@ let dps = datapoints.getAll(this.type); | ||
if (dps) { | ||
for (let i in obj) { | ||
let tmpid = obj[i]; | ||
for (const i in obj) { | ||
const tmpid = obj[i]; | ||
if (tmpid && tmpid._id && tmpid.type) { | ||
let stateid = tmpid._id.replace(id + '.', ''); | ||
const stateid = tmpid._id.replace(id + '.', ''); | ||
if (tmpid.type === 'state' && tmpid._id.startsWith(id)) { | ||
@@ -420,8 +453,8 @@ if (!dps[stateid]) { | ||
// delete empty channels | ||
for (let i in obj) { | ||
let tmpidi = obj[i]; | ||
for (const i in obj) { | ||
const tmpidi = obj[i]; | ||
if (tmpidi && tmpidi.type && tmpidi._id && tmpidi.type === 'channel') { | ||
let found = false; | ||
for (let j in obj) { | ||
let tmpidj = obj[j]; | ||
for (const j in obj) { | ||
const tmpidj = obj[j]; | ||
if (!tmpidj) { | ||
@@ -457,4 +490,5 @@ continue; | ||
if (!update) return; | ||
if (this.getDeviceName() === undefined) return; | ||
if (!this.adapter.isOnline(this.getDeviceName())) { | ||
if (!this.isOnline()) { | ||
this.adapter.log.debug(`[firmwareUpdate] Device is offline ${this.getName()}`); | ||
@@ -465,7 +499,13 @@ return; | ||
try { | ||
if (this.getDeviceGen() === 1) { | ||
let body = await this.requestAsync('http://' + this.getIP() + '/ota?update=true'); | ||
this.adapter.log.debug(`[firmwareUpdate] Update result for ${this.getName()}: ${body}`); | ||
} else if (this.getDeviceGen() === 2) { | ||
// TODO | ||
const firmwareUpdateState = await this.adapter.getStateAsync(this.getDeviceName() + '.firmware'); | ||
this.adapter.log.debug(`[firmwareUpdate] received state ${JSON.stringify(firmwareUpdateState)} for ${this.getName()}`); | ||
// Check if device has firmware update | ||
if (firmwareUpdateState && firmwareUpdateState.val) { | ||
if (this.getDeviceGen() === 1) { | ||
const body = await this.requestAsync('http://' + this.getIP() + '/ota?update=true'); | ||
this.adapter.log.debug(`[firmwareUpdate] Update result for ${this.getName()}: ${body}`); | ||
} else if (this.getDeviceGen() === 2) { | ||
// TODO | ||
} | ||
} | ||
@@ -472,0 +512,0 @@ } catch (error) { |
@@ -15,4 +15,4 @@ /* jshint -W097 */ | ||
function isAsync(funct) { | ||
if (funct && funct.constructor) return funct.constructor.name == 'AsyncFunction'; | ||
return undefined; | ||
if (funct && funct.constructor) return funct.constructor.name == 'AsyncFunction'; | ||
return undefined; | ||
} | ||
@@ -26,16 +26,16 @@ | ||
function getCoapValue(objkey, payload) { | ||
let isArray = (typeof objkey !== 'string' && typeof objkey !== 'number'); | ||
if (!isArray) { | ||
let key = Number(objkey); | ||
let index = payload.findIndex((item) => item[1] === key); | ||
return index >= 0 ? payload[index][2] : undefined; | ||
} else { | ||
let ret = []; | ||
for (let i in objkey) { | ||
let key = Number(objkey[i]); | ||
let index = payload.findIndex((item) => item[1] === key); | ||
if (index >= 0) { ret.push(payload[index][2]); } else { ret.push(undefined); } | ||
const isArray = (typeof objkey !== 'string' && typeof objkey !== 'number'); | ||
if (!isArray) { | ||
const key = Number(objkey); | ||
const index = payload.findIndex((item) => item[1] === key); | ||
return index >= 0 ? payload[index][2] : undefined; | ||
} else { | ||
const ret = []; | ||
for (const i in objkey) { | ||
const key = Number(objkey[i]); | ||
const index = payload.findIndex((item) => item[1] === key); | ||
if (index >= 0) { ret.push(payload[index][2]); } else { ret.push(undefined); } | ||
} | ||
return ret; | ||
} | ||
return ret; | ||
} | ||
} | ||
@@ -45,229 +45,207 @@ | ||
function descrToSensor(description) { | ||
let sensors = {}; | ||
if (description && description.sen) { | ||
for (let i in description.sen) { | ||
try { | ||
let sensor = description.sen[i]; | ||
let descr = sensor.D; | ||
let key = sensor.I; | ||
if (descr) sensors[descr.toLowerCase()] = key; | ||
} catch (error) { | ||
// | ||
} | ||
const sensors = {}; | ||
if (description && description.sen) { | ||
for (const i in description.sen) { | ||
try { | ||
const sensor = description.sen[i]; | ||
const descr = sensor.D; | ||
const key = sensor.I; | ||
if (descr) sensors[descr.toLowerCase()] = key; | ||
} catch (error) { | ||
// | ||
} | ||
} | ||
} | ||
} | ||
return sensors; | ||
return sensors; | ||
} | ||
class CoAPClient extends BaseClient { | ||
constructor(adapter, objectHelper, eventEmitter, shelly, devicename, ip, payload, description) { | ||
constructor(adapter, objectHelper, eventEmitter, shelly, devicename, ip, payload, description) { | ||
super('coap', adapter, objectHelper, eventEmitter); | ||
super('coap', adapter, objectHelper, eventEmitter); | ||
this.shelly = shelly; | ||
this.devicename = devicename; | ||
this.ip = ip; | ||
this.shelly = shelly; | ||
this.devicename = devicename; | ||
this.ip = ip; | ||
this.description = description; | ||
this.sensors = descrToSensor(description); | ||
this.description = description; | ||
this.sensors = descrToSensor(description); | ||
this.start(payload, description); | ||
} | ||
/** | ||
* Change Device ID from #2 to #1 (fimrware verson >= 1.8) | ||
* Example SHRGBW2#1234#2 will change to SHRGBW2#1234#1 | ||
*/ | ||
getOldDeviceInfo(devicename) { | ||
if (devicename && devicename.substr(-2) === '#2') { | ||
return devicename.substr(0, devicename.length - 2) + '#1'; | ||
} else { | ||
return devicename; | ||
this.start(payload, description); | ||
} | ||
} | ||
/** | ||
/** | ||
* Get the ID of the Shelly Device. For example: shellyplug-s-12345 | ||
*/ | ||
getId() { | ||
if (!this.id) { | ||
let devicetype = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
let serialid = this.getSerialId(); | ||
if (devicetype && serialid) { | ||
this.id = devicetype + '-' + serialid; | ||
} | ||
getId() { | ||
if (!this.id) { | ||
const devicetype = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
const serialid = this.getSerialId(); | ||
if (devicetype && serialid) { | ||
this.id = devicetype + '-' + serialid; | ||
} | ||
} | ||
return this.id; | ||
} | ||
return this.id; | ||
} | ||
/** | ||
* Get the Shelly Device type with the serialnumber of the device back. | ||
* Device type could be for example SHRGBW2. The serial number of the | ||
* device like 1234 will be added | ||
* Example: SHRGBW2#1234#1 | ||
*/ | ||
getDeviceName() { | ||
return this.getOldDeviceInfo(this.devicename); | ||
} | ||
/** | ||
/** | ||
* Get the Shelly Device type without serialnumber of the device back. | ||
* Example: SHRGBW2 | ||
*/ | ||
getDeviceType() { | ||
if (!this.devicetype) { | ||
let devicename = this.getDeviceName(); | ||
if (typeof devicename === 'string') { | ||
this.devicetype = devicename.split('#').slice(0, 1).join(); | ||
} | ||
getDeviceType() { | ||
if (!this.devicetype) { | ||
const devicename = this.getDeviceName(); | ||
if (typeof devicename === 'string') { | ||
this.devicetype = devicename.split('#').slice(0, 1).join(); | ||
} | ||
} | ||
return this.devicetype; | ||
} | ||
return this.devicetype; | ||
} | ||
/** | ||
/** | ||
* Get the deviceid back without serial number. | ||
* For example, you get shellyplug-s back | ||
*/ | ||
getDeviceId() { | ||
if (!this.deviceid) { | ||
this.deviceid = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
getDeviceId() { | ||
if (!this.deviceid) { | ||
this.deviceid = datapoints.getDeviceNameForCoAP(this.getDeviceType()); | ||
} | ||
return this.deviceid; | ||
} | ||
return this.deviceid; | ||
} | ||
/** | ||
/** | ||
* Get the serialid back without devicename. | ||
* For example, you get 12345 for shellyplug-s-12345 back | ||
*/ | ||
getSerialId() { | ||
if (!this.serialid) { | ||
let devicename = this.getDeviceName(); | ||
if (typeof devicename === 'string') { | ||
let devicetype = devicename.split('#'); | ||
if (devicetype) this.serialid = devicetype[1]; | ||
} | ||
getSerialId() { | ||
if (!this.serialid) { | ||
const devicename = this.getDeviceName(); | ||
if (typeof devicename === 'string') { | ||
const devicetype = devicename.split('#'); | ||
if (devicetype) this.serialid = devicetype[1]; | ||
} | ||
} | ||
return this.serialid; | ||
} | ||
return this.serialid; | ||
} | ||
/** | ||
/** | ||
* Cleanup, destroy this object | ||
*/ | ||
destroy() { | ||
super.destroy(); | ||
destroy() { | ||
super.destroy(); | ||
this.description = undefined; | ||
this.description = undefined; | ||
if (this.listenerus) this.shelly.removeListener('update-device-status', this.listenerus); | ||
if (this.listenerds) this.shelly.removeListener('device-connection-status', this.listenerds); | ||
} | ||
if (this.listenerus) this.shelly.removeListener('update-device-status', this.listenerus); | ||
if (this.listenerds) this.shelly.removeListener('device-connection-status', this.listenerds); | ||
} | ||
getDevices() { | ||
let states = []; | ||
for (let i in this.device) { | ||
let state = this.device[i]; | ||
// if (state.coap && state.coap.coap_publish_funct) states.push(state); | ||
if (state.coap) { | ||
if (state.coap.coap_publish) { | ||
states.push(state); | ||
} else if (state.coap.coap_publish_funct) { | ||
states.push(state); | ||
getDevices() { | ||
const states = []; | ||
for (const i in this.device) { | ||
const state = this.device[i]; | ||
// if (state.coap && state.coap.coap_publish_funct) states.push(state); | ||
if (state.coap) { | ||
if (state.coap.coap_publish) { | ||
states.push(state); | ||
} else if (state.coap.coap_publish_funct) { | ||
states.push(state); | ||
} | ||
} | ||
} | ||
} | ||
return states; | ||
} | ||
return states; | ||
} | ||
/** | ||
/** | ||
* State changes from device will be saved in the ioBroker states | ||
* @param {object} payload - object can be ervery type of value | ||
*/ | ||
async createIoBrokerState(payload) { | ||
this.adapter.log.debug(`[CoAP] Message for ${this.getName()}: ${JSON.stringify(payload)}`); | ||
let dps = this.getDevices(); | ||
for (let i in dps) { | ||
let dp = dps[i]; | ||
let deviceid = this.getDeviceName(); | ||
let stateid = deviceid + '.' + dp.state; | ||
let value = payload; | ||
async createIoBrokerState(payload) { | ||
this.adapter.log.debug(`[CoAP] Message for ${this.getName()}: ${JSON.stringify(payload)}`); | ||
const dps = this.getDevices(); | ||
for (const i in dps) { | ||
const dp = dps[i]; | ||
const deviceid = this.getDeviceName(); | ||
const stateid = deviceid + '.' + dp.state; | ||
let value = payload; | ||
this.adapter.log.silly(`[CoAP] Message with value for ${this.getName()}: state: ${stateid}, payload: ${JSON.stringify(payload)}`); | ||
this.adapter.log.silly(`[CoAP] Message with value for ${this.getName()}: state: ${stateid}, payload: ${JSON.stringify(payload)}`); | ||
try { | ||
if (dp.coap && dp.coap.coap_publish) { | ||
value = getCoapValue(dp.coap.coap_publish, value.G); | ||
if (dp.coap && dp.coap.coap_publish_funct) { | ||
value = isAsync(dp.coap.coap_publish_funct) ? await dp.coap.coap_publish_funct(value, this) : dp.coap.coap_publish_funct(value, this); | ||
} | ||
try { | ||
if (dp.coap && dp.coap.coap_publish) { | ||
value = getCoapValue(dp.coap.coap_publish, value.G); | ||
if (dp.coap && dp.coap.coap_publish_funct) { | ||
value = isAsync(dp.coap.coap_publish_funct) ? await dp.coap.coap_publish_funct(value, this) : dp.coap.coap_publish_funct(value, this); | ||
} | ||
if (dp.common.type === 'boolean' && value === 'false') value = false; | ||
if (dp.common.type === 'boolean' && value === 'true') value = true; | ||
if (dp.common.type === 'number' && value !== undefined) value = Number(value); | ||
if (dp.common.type === 'boolean' && value === 'false') value = false; | ||
if (dp.common.type === 'boolean' && value === 'true') value = true; | ||
if (dp.common.type === 'number' && value !== undefined) value = Number(value); | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
this.adapter.log.debug(`[CoAP] State change ${this.getName()}: state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: dp.common | ||
}, ['name'], value); | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
this.adapter.log.debug(`[CoAP] State change ${this.getName()}: state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: dp.common | ||
}, ['name'], value); | ||
} | ||
} | ||
} | ||
} catch (error) { | ||
this.adapter.log.error(`[CoAP] Error ${error} in function dp.coap.coap_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
} | ||
} catch (error) { | ||
this.adapter.log.error(`[CoAP] Error ${error} in function dp.mqtt.coap_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
this.objectHelper.processObjectQueue(() => { }); | ||
} | ||
this.objectHelper.processObjectQueue(() => { }); | ||
} | ||
async start(payload, description) { | ||
if (this.deviceExists()) { | ||
let polltime = this.getPolltime(); | ||
if (polltime > 0) { | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! No polling`); | ||
} | ||
async start(payload, description) { | ||
if (this.deviceExists()) { | ||
const polltime = this.getPolltime(); | ||
if (polltime > 0) { | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! No polling`); | ||
} | ||
this.adapter.log.debug(`[CoAP] 1. Shelly device info for ${this.getDeviceName()}: ${JSON.stringify(description)}`); | ||
this.adapter.log.debug(`[CoAP] 2. Shelly device info for ${this.getDeviceName()}: ${JSON.stringify(payload)}`); | ||
this.adapter.log.debug(`[CoAP] 1. Shelly device info for ${this.getDeviceName()}: ${JSON.stringify(description)}`); | ||
this.adapter.log.debug(`[CoAP] 2. Shelly device info for ${this.getDeviceName()}: ${JSON.stringify(payload)}`); | ||
this.deleteOldStates(); | ||
await this.createObjects(); | ||
this.deleteOldStates(); | ||
await this.createObjects(); | ||
// Fill hostname | ||
await this.adapter.setStateAsync(this.getDeviceName() + '.hostname', {val: this.getIP(), ack: true}); | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
// Fill hostname | ||
await this.adapter.setStateAsync(this.getDeviceName() + '.hostname', {val: this.getIP(), ack: true}); | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
this.httpIoBrokerState(); | ||
this.httpIoBrokerState(); | ||
if (payload) this.createIoBrokerState(payload); | ||
if (payload) this.createIoBrokerState(payload); | ||
this.listener(); | ||
} else { | ||
this.adapter.log.error(`[CoAP] Shelly Device unknown, configuration for Shelly device ${this.getName()} does not exist!`); | ||
this.adapter.log.error(`[CoAP] 1. Send developer following info for ${this.getDeviceName()}: ${JSON.stringify(description)}`); | ||
this.adapter.log.error(`[CoAP] 2. Send developer following info for ${this.getDeviceName()}: ${JSON.stringify(payload)}`); | ||
this.listener(); | ||
} else { | ||
this.adapter.log.error(`[CoAP] Device unknown, configuration for Shelly device ${this.getName()} does not exist!`); | ||
this.adapter.log.error(`[CoAP] 1. Send developer following info for ${this.getDeviceName()}: ${JSON.stringify(description)}`); | ||
this.adapter.log.error(`[CoAP] 2. Send developer following info for ${this.getDeviceName()}: ${JSON.stringify(payload)}`); | ||
} | ||
} | ||
} | ||
listener() { | ||
this.shelly.on('error', (err) => { | ||
this.adapter.log.debug(`[CoAP] Error handling Shelly data: ${err}`); | ||
}); | ||
listener() { | ||
this.shelly.on('error', (err) => { | ||
this.adapter.log.debug(`[CoAP] Listener - error handling data: ${err}`); | ||
}); | ||
this.shelly.on('update-device-status', this.listenerus = (devicename, payload) => { | ||
if (this.getOldDeviceInfo(devicename) === this.getDeviceName()) { | ||
this.createIoBrokerState(payload); | ||
} | ||
}); | ||
this.shelly.on('update-device-status', this.listenerus = (devicename, payload) => { | ||
if (this.getOldDeviceInfo(devicename) === this.getDeviceName()) { | ||
this.createIoBrokerState(payload); | ||
} | ||
}); | ||
this.shelly.on('device-connection-status', this.listenerds = (devicename, connected) => { | ||
this.adapter.log.debug(`[CoAP] Connection update received for ${devicename}: ${connected}`); | ||
if (this.getOldDeviceInfo(devicename) === this.getDeviceName()) { | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
} | ||
}); | ||
} | ||
this.shelly.on('device-connection-status', this.listenerds = (devicename, connected) => { | ||
this.adapter.log.debug(`[CoAP] Connection update received for ${devicename}: ${connected}`); | ||
if (this.getOldDeviceInfo(devicename) === this.getDeviceName()) { | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
} | ||
}); | ||
} | ||
} | ||
@@ -277,95 +255,96 @@ | ||
constructor(adapter, objectHelper, eventEmitter) { | ||
constructor(adapter, objectHelper, eventEmitter) { | ||
//if (!(this instanceof CoAPServer)) return new CoAPServer(adapter, objectHelper, eventEmitter); | ||
super(adapter, objectHelper, eventEmitter); | ||
super(adapter, objectHelper, eventEmitter); | ||
this.clients = {}; | ||
this.blacklist = {}; | ||
} | ||
this.clients = {}; | ||
this.blacklist = {}; | ||
} | ||
isBlackListed(deviceId) { | ||
if (deviceId && this.blacklist[deviceId]) { | ||
return true; | ||
} | ||
if (deviceId && this.adapter.config.blacklist) { | ||
for (let i in this.adapter.config.blacklist) { | ||
let key = this.adapter.config.blacklist[i]; | ||
if (key.id && deviceId) { | ||
let reg = new RegExp(key.id, 'gm'); | ||
let res = deviceId.match(reg); | ||
if (res) { | ||
this.blacklist[deviceId] = deviceId; | ||
isBlackListed(deviceId) { | ||
if (deviceId && this.blacklist[deviceId]) { | ||
return true; | ||
} | ||
} | ||
} | ||
if (deviceId && this.adapter.config.blacklist) { | ||
for (const i in this.adapter.config.blacklist) { | ||
const key = this.adapter.config.blacklist[i]; | ||
if (key.id && deviceId) { | ||
const reg = new RegExp(key.id, 'gm'); | ||
const res = deviceId.match(reg); | ||
if (res) { | ||
this.blacklist[deviceId] = deviceId; | ||
return true; | ||
} | ||
} | ||
} | ||
} | ||
return false; | ||
} | ||
return false; | ||
} | ||
listen() { | ||
let options = {}; | ||
if (this.adapter.config.httpusername && this.adapter.config.httppassword) { | ||
options = { | ||
logger: this.adapter.log.debug, | ||
user: this.adapter.config.httpusername, | ||
password: this.adapter.config.httppassword, | ||
multicastInterface: null | ||
}; | ||
} else { | ||
options = { | ||
logger: this.adapter.log.debug | ||
}; | ||
} | ||
listen() { | ||
let options = {}; | ||
if (this.adapter.config.httpusername && this.adapter.config.httppassword) { | ||
options = { | ||
logger: this.adapter.log.debug, | ||
user: this.adapter.config.httpusername, | ||
password: this.adapter.config.httppassword, | ||
multicastInterface: null | ||
}; | ||
} else { | ||
options = { | ||
logger: this.adapter.log.debug | ||
}; | ||
} | ||
if (this.adapter.config.coapbind && this.adapter.config.coapbind != '0.0.0.0') { | ||
options.multicastInterface = this.adapter.config.coapbind; | ||
} | ||
if (this.adapter.config.coapbind && this.adapter.config.coapbind != '0.0.0.0') { | ||
options.multicastInterface = this.adapter.config.coapbind; | ||
} | ||
let shelly = new Shelly(options); | ||
this.adapter.log.debug(`[CoAP] Starting shelly listener with options: ${JSON.stringify(options)}`); | ||
const shelly = new Shelly(options); | ||
shelly.on('error', (err) => { | ||
this.adapter.log.debug(`[CoAP] Error handling Shelly data: ${err}`); | ||
}); | ||
shelly.on('error', (err) => { | ||
this.adapter.log.debug(`[CoAP] Error - handling data: ${err}`); | ||
}); | ||
shelly.on('update-device-status', (devicename, status) => { | ||
this.adapter.log.debug(`[CoAP] Status update received for ${devicename}: ${JSON.stringify(status)}`); | ||
shelly.on('update-device-status', (devicename, status) => { | ||
this.adapter.log.debug(`[CoAP] Status update received for ${devicename}: ${JSON.stringify(status)}`); | ||
if (devicename && typeof devicename === 'string') { | ||
shelly.getDeviceDescription(devicename, (err, devicename, description, ip) => { | ||
if (!err && devicename && ip) { | ||
// if ip address change of coap device change | ||
if (this.clients[devicename] && this.clients[devicename].getIP() !== ip) { | ||
this.clients[devicename].destroy(); | ||
delete this.clients[devicename]; | ||
if (devicename && typeof devicename === 'string') { | ||
shelly.getDeviceDescription(devicename, (err, devicename, description, ip) => { | ||
if (!err && devicename && ip) { | ||
// if ip address change of coap device change | ||
if (this.clients[devicename] && this.clients[devicename].getIP() !== ip) { | ||
this.clients[devicename].destroy(); | ||
delete this.clients[devicename]; | ||
} | ||
if (!this.clients[devicename]) { | ||
if (!this.isBlackListed(devicename) && !this.isBlackListed(ip)) { | ||
this.clients[devicename] = new CoAPClient(this.adapter, this.objectHelper, this.eventEmitter, shelly, devicename, ip, status, description); | ||
} | ||
} | ||
} | ||
}); | ||
} else { | ||
this.adapter.log.debug(`[CoAP] Device Id is missing: ${devicename}`); | ||
} | ||
if (!this.clients[devicename]) { | ||
if (!this.isBlackListed(devicename) && !this.isBlackListed(ip)) { | ||
this.clients[devicename] = new CoAPClient(this.adapter, this.objectHelper, this.eventEmitter, shelly, devicename, ip, status, description); | ||
} | ||
}); | ||
shelly.on('disconnect', () => { | ||
for (const i in this.clients) { | ||
this.clients[i].destroy(); | ||
delete this.clients[i]; | ||
} | ||
} | ||
}); | ||
} else { | ||
this.adapter.log.debug(`[CoAP] Device Id is missing: ${devicename}`); | ||
} | ||
}); | ||
shelly.on('disconnect', () => { | ||
for (let i in this.clients) { | ||
this.clients[i].destroy(); | ||
delete this.clients[i]; | ||
} | ||
}); | ||
shelly.listen(() => { | ||
this.adapter.log.info('[CoAP] Listening for packets in the network'); | ||
}); | ||
} | ||
shelly.listen(() => { | ||
this.adapter.log.info('[CoAP] Listening for Shelly packets in the network'); | ||
}); | ||
} | ||
} | ||
module.exports = { | ||
CoAPServer: CoAPServer | ||
CoAPServer: CoAPServer | ||
}; |
@@ -21,4 +21,4 @@ /* jshint -W097 */ | ||
function isAsync(funct) { | ||
if (funct && funct.constructor) return funct.constructor.name == 'AsyncFunction'; | ||
return undefined; | ||
if (funct && funct.constructor) return funct.constructor.name == 'AsyncFunction'; | ||
return undefined; | ||
} | ||
@@ -33,40 +33,40 @@ | ||
function recursiveSubStringReplace(source, pattern, replacement) { | ||
function recursiveReplace(objSource) { | ||
switch (typeof objSource) { | ||
case 'string': | ||
return objSource.replace(pattern, replacement); | ||
case 'object': | ||
if (objSource === null) { | ||
return null; | ||
function recursiveReplace(objSource) { | ||
switch (typeof objSource) { | ||
case 'string': | ||
return objSource.replace(pattern, replacement); | ||
case 'object': | ||
if (objSource === null) { | ||
return null; | ||
} | ||
Object.keys(objSource).forEach(function (property) { | ||
objSource[property] = recursiveReplace(objSource[property]); | ||
}); | ||
return objSource; | ||
default: | ||
return objSource; | ||
} | ||
Object.keys(objSource).forEach(function (property) { | ||
objSource[property] = recursiveReplace(objSource[property]); | ||
}); | ||
return objSource; | ||
default: | ||
return objSource; | ||
} | ||
} | ||
return recursiveReplace(source); | ||
return recursiveReplace(source); | ||
} | ||
class MQTTClient extends BaseClient { | ||
constructor(adapter, objectHelper, eventEmitter, stream) { | ||
constructor(adapter, objectHelper, eventEmitter, stream) { | ||
super('mqtt', adapter, objectHelper, eventEmitter); | ||
super('mqtt', adapter, objectHelper, eventEmitter); | ||
this.stream = stream; | ||
this.stream = stream; | ||
this.packet; | ||
this.mqttprefix; | ||
this.qos = {}; | ||
this.messageIds = []; | ||
this.messageId = 1; | ||
this.packet; | ||
this.mqttprefix; | ||
this.qos = {}; | ||
this.messageIds = []; | ||
this.messageId = 1; | ||
this.client; | ||
this.client; | ||
this.start(); | ||
} | ||
this.start(); | ||
} | ||
/** | ||
/** | ||
* to get sure, that an instance will be start more than one, we check for running instances | ||
@@ -76,33 +76,33 @@ * if an instance run with same name (shellyswitch-12345), we destroy the old instance | ||
*/ | ||
static _registerRun(self) { | ||
if (self) { | ||
if (!this.clientlist) this.clientlist = {}; | ||
let name = self.getId(); | ||
if (name && this.clientlist[name]) this.clientlist[name].destroy(); | ||
this.clientlist[name] = self; | ||
static _registerRun(self) { | ||
if (self) { | ||
if (!this.clientlist) this.clientlist = {}; | ||
const name = self.getId(); | ||
if (name && this.clientlist[name]) this.clientlist[name].destroy(); | ||
this.clientlist[name] = self; | ||
} | ||
} | ||
} | ||
/** | ||
/** | ||
* Get IP of device back. For example | ||
* 192.168.1.2 | ||
*/ | ||
getIP() { | ||
if (!this.ip) { | ||
if (this.stream && this.stream.remoteAddress) this.ip = this.stream.remoteAddress; | ||
getIP() { | ||
if (!this.ip) { | ||
if (this.stream && this.stream.remoteAddress) this.ip = this.stream.remoteAddress; | ||
} | ||
return this.ip; | ||
} | ||
return this.ip; | ||
} | ||
/** | ||
/** | ||
* Get the ID of the Shelly Device. For example: shellyplug-s-12345 | ||
*/ | ||
getId() { | ||
if (!this.id) { | ||
if (this.packet && this.packet.clientId) this.id = this.packet.clientId; | ||
getId() { | ||
if (!this.id) { | ||
if (this.packet && this.packet.clientId) this.id = this.packet.clientId; | ||
} | ||
return this.id; | ||
} | ||
return this.id; | ||
} | ||
/** | ||
/** | ||
* Get the Shelly Device type with the serialnumber of the device back. | ||
@@ -113,76 +113,76 @@ * Device type could be for example SHRGBW2. The serial number of the | ||
*/ | ||
getDeviceName() { | ||
if (!this.devicename) { | ||
const deviceType = this.getDeviceType(); | ||
const serialId = this.getSerialId(); | ||
if (deviceType && serialId) { | ||
this.devicename = deviceType + '#' + serialId + '#1'; | ||
} | ||
getDeviceName() { | ||
if (!this.devicename) { | ||
const deviceType = this.getDeviceType(); | ||
const serialId = this.getSerialId(); | ||
if (deviceType && serialId) { | ||
this.devicename = deviceType + '#' + serialId + '#1'; | ||
} | ||
} | ||
return this.devicename; | ||
} | ||
return this.devicename; | ||
} | ||
/** | ||
/** | ||
* Get the Shelly Device type without serialnumber of the device back. | ||
* Example: SHRGBW2 | ||
*/ | ||
getDeviceType() { | ||
if (!this.devicetype) { | ||
let deviceid = this.getDeviceId(); | ||
this.devicetype = datapoints.getDeviceNameForMQTT(deviceid); | ||
getDeviceType() { | ||
if (!this.devicetype) { | ||
const deviceid = this.getDeviceId(); | ||
this.devicetype = datapoints.getDeviceNameForMQTT(deviceid); | ||
} | ||
return this.devicetype; | ||
} | ||
return this.devicetype; | ||
} | ||
/** | ||
/** | ||
* Get the deviceid back without serial number. | ||
* For example, you get shellyplug-s for shellyplug-s-12345 back | ||
*/ | ||
getDeviceId() { | ||
if (!this.deviceid) { | ||
let id = this.getId(); | ||
if (id) { | ||
id = id.replace(/(.+?)\/(.+?)\/(.*)/, '$2'); | ||
this.deviceid = id.replace(/(.+)-(.+)/, '$1'); | ||
} | ||
getDeviceId() { | ||
if (!this.deviceid) { | ||
let id = this.getId(); | ||
if (id) { | ||
id = id.replace(/(.+?)\/(.+?)\/(.*)/, '$2'); | ||
this.deviceid = id.replace(/(.+)-(.+)/, '$1'); | ||
} | ||
} | ||
return this.deviceid; | ||
} | ||
return this.deviceid; | ||
} | ||
/** | ||
/** | ||
* Get the serialid back without devicename. | ||
* For example, you get 12345 for shellyplug-s-12345 back | ||
*/ | ||
getSerialId() { | ||
if (!this.serialid) { | ||
let id = this.getId(); | ||
if (id) { | ||
id = id.replace(/(.+?)\/(.+?)\/(.*)/, '$2'); | ||
this.serialid = id.replace(/(.+)-(.+)/, '$2'); | ||
} | ||
getSerialId() { | ||
if (!this.serialid) { | ||
let id = this.getId(); | ||
if (id) { | ||
id = id.replace(/(.+?)\/(.+?)\/(.*)/, '$2'); | ||
this.serialid = id.replace(/(.+)-(.+)/, '$2'); | ||
} | ||
} | ||
return this.serialid; | ||
} | ||
return this.serialid; | ||
} | ||
/** | ||
/** | ||
* Cleanup, destroy this object | ||
*/ | ||
destroy() { | ||
super.destroy(); | ||
destroy() { | ||
super.destroy(); | ||
for (let messageId in this.qos) { | ||
if (this.qos[messageId].resendid) clearTimeout(this.qos[messageId].resendid); | ||
} | ||
for (const messageId in this.qos) { | ||
if (this.qos[messageId].resendid) clearTimeout(this.qos[messageId].resendid); | ||
} | ||
this.qos = {}; | ||
this.messageId = 1; | ||
this.mqttprefix = undefined; | ||
this.qos = {}; | ||
this.messageId = 1; | ||
this.mqttprefix = undefined; | ||
if (this.client) { | ||
this.client.removeAllListeners(); | ||
this.client.destroy(); | ||
if (this.client) { | ||
this.client.removeAllListeners(); | ||
this.client.destroy(); | ||
} | ||
} | ||
} | ||
/** | ||
/** | ||
* Sends MQTT Messages, for example to change a state | ||
@@ -196,361 +196,361 @@ * @param {*} topic | ||
*/ | ||
sendState2Client(topic, state, qos, dup, retain, cb) { | ||
if (typeof qos === 'function') { | ||
cb = qos; | ||
dup = false; | ||
qos = undefined; | ||
sendState2Client(topic, state, qos, dup, retain, cb) { | ||
if (typeof qos === 'function') { | ||
cb = qos; | ||
dup = false; | ||
qos = undefined; | ||
} | ||
if (typeof dup === 'function') { | ||
cb = dup; | ||
dup = false; | ||
retain = undefined; | ||
} | ||
if (typeof retain === 'function') { | ||
cb = retain; | ||
retain = undefined; | ||
} | ||
qos = qos ? Number.parseInt(qos) : 0; | ||
this.messageId &= 0xFFFFFFFF; | ||
this.messageId++; | ||
this.adapter.log.debug(`[MQTT] Send state to ${this.getName()}: ${topic} = ${state} (${this.messageId})`); | ||
this.client.publish({ topic: topic, payload: state, qos: qos, retain: retain, messageId: this.messageId }, cb); | ||
// if qos > 0 recognize message | ||
if (qos > 0) { | ||
this.deleteResendState2ClientFromTopic(topic); | ||
this.resendState2Client('publish', this.messageId, { topic: topic, payload: state, qos: qos, dup: true, retain: retain, messageId: this.messageId }); | ||
} | ||
} | ||
if (typeof dup === 'function') { | ||
cb = dup; | ||
dup = false; | ||
retain = undefined; | ||
resendState2Client(cmd, messageId, message) { | ||
const retaintime = 5 * 1000; | ||
if (!this.qos[messageId] || this.qos[messageId].cmd !== cmd || this.qos[messageId].message !== message) { | ||
this.qos[messageId] = { | ||
ts: Date.now(), | ||
cmd: cmd, | ||
count: 0, | ||
message: message | ||
}; | ||
} | ||
if (this.qos[messageId] && this.qos[messageId].count < 10) { | ||
clearTimeout(this.qos[messageId].resendid); | ||
this.qos[messageId].resendid = setTimeout(() => { | ||
if (this.qos[messageId]) { | ||
const ts = Date.now(); | ||
this.qos[messageId].count++; | ||
this.qos[messageId].ts = ts; | ||
switch (this.qos[messageId].cmd) { | ||
case 'publish': | ||
this.client.publish(this.qos[messageId].message); | ||
break; | ||
case 'pubrel': | ||
this.client.pubrel({ messageId: messageId }); | ||
break; | ||
case 'pubrec': | ||
this.client.pubrec({ messageId: messageId }); | ||
break; | ||
case 'pubcomp': | ||
this.client.pubcomp({ messageId: messageId }); | ||
break; | ||
default: | ||
break; | ||
} | ||
this.resendState2Client(cmd, messageId, message); | ||
} | ||
}, retaintime); | ||
} | ||
} | ||
if (typeof retain === 'function') { | ||
cb = retain; | ||
retain = undefined; | ||
} | ||
qos = qos ? Number.parseInt(qos) : 0; | ||
this.messageId &= 0xFFFFFFFF; | ||
this.messageId++; | ||
this.adapter.log.debug(`[MQTT] Send state to ${this.getName()}: ${topic} = ${state} (${this.messageId})`); | ||
this.client.publish({ topic: topic, payload: state, qos: qos, retain: retain, messageId: this.messageId }, cb); | ||
// if qos > 0 recognize message | ||
if (qos > 0) { | ||
this.deleteResendState2ClientFromTopic(topic); | ||
this.resendState2Client('publish', this.messageId, { topic: topic, payload: state, qos: qos, dup: true, retain: retain, messageId: this.messageId }); | ||
} | ||
} | ||
resendState2Client(cmd, messageId, message) { | ||
let retaintime = 5 * 1000; | ||
if (!this.qos[messageId] || this.qos[messageId].cmd !== cmd || this.qos[messageId].message !== message) { | ||
this.qos[messageId] = { | ||
ts: Date.now(), | ||
cmd: cmd, | ||
count: 0, | ||
message: message | ||
}; | ||
} | ||
if (this.qos[messageId] && this.qos[messageId].count < 10) { | ||
clearTimeout(this.qos[messageId].resendid); | ||
this.qos[messageId].resendid = setTimeout(() => { | ||
deleteResendState2Client(messageId) { | ||
if (this.qos[messageId]) { | ||
let ts = Date.now(); | ||
this.qos[messageId].count++; | ||
this.qos[messageId].ts = ts; | ||
switch (this.qos[messageId].cmd) { | ||
case 'publish': | ||
this.client.publish(this.qos[messageId].message); | ||
break; | ||
case 'pubrel': | ||
this.client.pubrel({ messageId: messageId }); | ||
break; | ||
case 'pubrec': | ||
this.client.pubrec({ messageId: messageId }); | ||
break; | ||
case 'pubcomp': | ||
this.client.pubcomp({ messageId: messageId }); | ||
break; | ||
default: | ||
break; | ||
} | ||
this.resendState2Client(cmd, messageId, message); | ||
clearTimeout(this.qos[messageId].resendid); | ||
delete this.qos[messageId]; | ||
} | ||
}, retaintime); | ||
} | ||
} | ||
deleteResendState2Client(messageId) { | ||
if (this.qos[messageId]) { | ||
clearTimeout(this.qos[messageId].resendid); | ||
delete this.qos[messageId]; | ||
deleteResendState2ClientFromTopic(topic) { | ||
for (const messageId in this.qos) { | ||
if (this.qos[messageId].message && this.qos[messageId].cmd === 'publish' && this.qos[messageId].message.topic === topic) { | ||
clearTimeout(this.qos[messageId].resendid); | ||
delete this.qos[messageId]; | ||
} | ||
} | ||
} | ||
} | ||
deleteResendState2ClientFromTopic(topic) { | ||
for (let messageId in this.qos) { | ||
if (this.qos[messageId].message && this.qos[messageId].cmd === 'publish' && this.qos[messageId].message.topic === topic) { | ||
clearTimeout(this.qos[messageId].resendid); | ||
delete this.qos[messageId]; | ||
} | ||
getResendState2Client(messageId) { | ||
return this.qos[messageId]; | ||
} | ||
} | ||
getResendState2Client(messageId) { | ||
return this.qos[messageId]; | ||
} | ||
getDevices(topic) { | ||
let states = []; | ||
for (let i in this.device) { | ||
let state = this.device[i]; | ||
if (state.mqtt && state.mqtt.mqtt_publish && topic === state.mqtt.mqtt_publish) { | ||
states.push(state); | ||
} | ||
getDevices(topic) { | ||
const states = []; | ||
for (const i in this.device) { | ||
const state = this.device[i]; | ||
if (state.mqtt && state.mqtt.mqtt_publish && topic === state.mqtt.mqtt_publish) { | ||
states.push(state); | ||
} | ||
} | ||
return states; | ||
} | ||
return states; | ||
} | ||
/** | ||
/** | ||
* State changes from device will be saved in the ioBroker states | ||
* @param {object} payload - object can be ervery type of value | ||
*/ | ||
async createIoBrokerState(topic, payload) { | ||
this.adapter.log.debug(`[MQTT] Message for ${this.getName()}: ${topic} / ${JSON.stringify(payload)} (${payload.toString()})`); | ||
async createIoBrokerState(topic, payload) { | ||
this.adapter.log.debug(`[MQTT] Message for ${this.getName()}: ${topic} / ${JSON.stringify(payload)} (${payload.toString()})`); | ||
let dps = this.getDevices(topic); | ||
for (let i in dps) { | ||
let dp = dps[i]; | ||
let deviceid = this.getDeviceName(); | ||
let stateid = deviceid + '.' + dp.state; | ||
let value = payload.toString(); | ||
const dps = this.getDevices(topic); | ||
for (const i in dps) { | ||
const dp = dps[i]; | ||
const deviceid = this.getDeviceName(); | ||
const stateid = deviceid + '.' + dp.state; | ||
let value = payload.toString(); | ||
this.adapter.log.silly(`[MQTT] Message with value for ${this.getName()}: ${topic} -> state: ${stateid}, value: ${value}`); | ||
this.adapter.log.silly(`[MQTT] Message with value for ${this.getName()}: ${topic} -> state: ${stateid}, value: ${value}`); | ||
try { | ||
if (dp.mqtt && dp.mqtt.mqtt_publish === topic) { | ||
if (dp.mqtt && dp.mqtt.mqtt_publish_funct) { | ||
value = isAsync(dp.mqtt.mqtt_publish_funct) ? await dp.mqtt.mqtt_publish_funct(value, this) : dp.mqtt.mqtt_publish_funct(value, this); | ||
} | ||
try { | ||
if (dp.mqtt && dp.mqtt.mqtt_publish === topic) { | ||
if (dp.mqtt && dp.mqtt.mqtt_publish_funct) { | ||
value = isAsync(dp.mqtt.mqtt_publish_funct) ? await dp.mqtt.mqtt_publish_funct(value, this) : dp.mqtt.mqtt_publish_funct(value, this); | ||
} | ||
if (dp.common.type === 'boolean' && value === 'false') value = false; | ||
if (dp.common.type === 'boolean' && value === 'true') value = true; | ||
if (dp.common.type === 'number' && value !== undefined) value = Number(value); | ||
if (dp.common.type === 'boolean' && value === 'false') value = false; | ||
if (dp.common.type === 'boolean' && value === 'true') value = true; | ||
if (dp.common.type === 'number' && value !== undefined) value = Number(value); | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
this.adapter.log.debug(`[MQTT] State change ${this.getName()}: ${topic} -> state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: dp.common | ||
}, ['name'], value); | ||
} | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
this.adapter.log.debug(`[MQTT] State change ${this.getName()}: ${topic} -> state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
this.objectHelper.setOrUpdateObject(stateid, { | ||
type: 'state', | ||
common: dp.common | ||
}, ['name'], value); | ||
} | ||
} | ||
} catch (error) { | ||
this.adapter.log.error(`[MQTT] Error ${error} in function dp.mqtt.mqtt_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
} | ||
} catch (error) { | ||
this.adapter.log.error(`[MQTT] Error ${error} in function dp.mqtt.mqtt_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
this.objectHelper.processObjectQueue(() => { }); | ||
} | ||
this.objectHelper.processObjectQueue(() => { }); | ||
} | ||
start() { | ||
this.client = mqtt(this.stream); | ||
this.listener(); | ||
} | ||
start() { | ||
this.client = mqtt(this.stream); | ||
this.listener(); | ||
} | ||
async setMqttPrefixHttp() { | ||
let body; | ||
let params; | ||
async setMqttPrefixHttp() { | ||
let body; | ||
let params; | ||
if (this.mqttprefix) { | ||
return this.mqttprefix; | ||
} | ||
if (this.mqttprefix) { | ||
return this.mqttprefix; | ||
} | ||
if (this.getDeviceGen() == 2) { | ||
// TODO get prefix from /rpc/Shelly.GetDeviceInfo (id) | ||
this.mqttprefix = this.getDeviceId(); | ||
return this.mqttprefix; | ||
} | ||
if (this.getDeviceGen() == 2) { | ||
// TODO get prefix from /rpc/Shelly.GetDeviceInfo (id) | ||
this.mqttprefix = this.getDeviceId(); | ||
return this.mqttprefix; | ||
} | ||
try { | ||
body = await this.requestAsync('http://' + this.getIP() + '/settings'); | ||
if (body) { | ||
let settings = JSON.parse(body); | ||
this.mqttprefix = settings.mqtt.id; | ||
return this.mqttprefix; | ||
} | ||
} catch (error) { | ||
if (body && body === '401 Unauthorized') { | ||
this.adapter.log.error(`[MQTT] Wrong http username or http password! Please enter the user credential from restricted login for ${this.getName()}`); | ||
} else { | ||
this.adapter.log.error(`[MQTT] Error in function setMqttPrefixHttp() for request' + JSON.stringify(params) + ' for ${this.getName()}: ${error}`); | ||
} | ||
try { | ||
body = await this.requestAsync('http://' + this.getIP() + '/settings'); | ||
if (body) { | ||
const settings = JSON.parse(body); | ||
this.mqttprefix = settings.mqtt.id; | ||
return this.mqttprefix; | ||
} | ||
} catch (error) { | ||
if (body && body === '401 Unauthorized') { | ||
this.adapter.log.error(`[MQTT] Wrong http username or http password! Please enter the user credential from restricted login for ${this.getName()}`); | ||
} else { | ||
this.adapter.log.error(`[MQTT] Error in function setMqttPrefixHttp() for request' + JSON.stringify(params) + ' for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
return undefined; | ||
} | ||
return undefined; | ||
} | ||
setMqttPrefixByWill(topic) { | ||
setMqttPrefixByWill(topic) { | ||
// Gen1: "shellies/huhu-shellybutton1-A4CF12F454A3/online" | ||
// Gen2: "shellyplus1pm-44179394d4d4/online" | ||
if (this.mqttprefix) { | ||
return this.mqttprefix; | ||
} else { | ||
if (topic) { | ||
let arr = topic.split('/'); | ||
if (this.getDeviceGen() == 1) { | ||
if (arr[0] === 'shellies') { | ||
this.mqttprefix = arr[1]; | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 1): ${this.mqttprefix}`); | ||
if (this.mqttprefix) { | ||
return this.mqttprefix; | ||
} | ||
} else if (this.getDeviceGen() == 2) { | ||
this.mqttprefix = arr.slice(0, -1).join('/'); | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 2): ${this.mqttprefix}`); | ||
return this.mqttprefix; | ||
} else { | ||
if (topic) { | ||
const arr = topic.split('/'); | ||
if (this.getDeviceGen() == 1) { | ||
if (arr[0] === 'shellies') { | ||
this.mqttprefix = arr[1]; | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 1): ${this.mqttprefix}`); | ||
return this.mqttprefix; | ||
} | ||
} else if (this.getDeviceGen() == 2) { | ||
this.mqttprefix = arr.slice(0, -1).join('/'); | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 2): ${this.mqttprefix}`); | ||
return this.mqttprefix; | ||
} | ||
} | ||
return undefined; | ||
} | ||
} | ||
return undefined; | ||
} | ||
} | ||
listener() { | ||
listener() { | ||
// client connected | ||
this.client.on('connect', async (packet) => { | ||
this.packet = packet; | ||
this.adapter.log.debug(`[MQTT] Client connected: ${JSON.stringify(packet)}`); | ||
if (this.deviceExists()) { | ||
if (packet.username === this.adapter.config.mqttusername && packet.password !== undefined && packet.password.toString() === this.adapter.config.mqttpassword) { | ||
// check for existing instances | ||
MQTTClient._registerRun(this); | ||
let polltime = this.getPolltime(); | ||
if (polltime > 0) { | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! No polling`); | ||
} | ||
this.client.on('connect', async (packet) => { | ||
this.packet = packet; | ||
this.adapter.log.debug(`[MQTT] Client connected: ${JSON.stringify(packet)}`); | ||
if (this.deviceExists()) { | ||
if (packet.username === this.adapter.config.mqttusername && packet.password !== undefined && packet.password.toString() === this.adapter.config.mqttpassword) { | ||
// check for existing instances | ||
MQTTClient._registerRun(this); | ||
const polltime = this.getPolltime(); | ||
if (polltime > 0) { | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! No polling`); | ||
} | ||
// Letzer Wille speichern | ||
if (packet.will) { | ||
this.will = packet.will; | ||
} | ||
// Letzer Wille speichern | ||
if (packet.will) { | ||
this.will = packet.will; | ||
} | ||
if (this.will && this.will.topic) { | ||
this.setMqttPrefixByWill(this.will.topic); | ||
} else { | ||
await this.setMqttPrefixHttp(); | ||
} | ||
if (this.will && this.will.topic) { | ||
this.setMqttPrefixByWill(this.will.topic); | ||
} else { | ||
await this.setMqttPrefixHttp(); | ||
} | ||
this.deleteOldStates(); | ||
await this.createObjects(); | ||
this.deleteOldStates(); | ||
await this.createObjects(); | ||
// Fill hostname | ||
await this.adapter.setStateAsync(this.getDeviceName() + '.hostname', {val: this.getIP(), ack: true}); | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
// Fill hostname | ||
await this.adapter.setStateAsync(this.getDeviceName() + '.hostname', {val: this.getIP(), ack: true}); | ||
this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
this.httpIoBrokerState(); | ||
this.httpIoBrokerState(); | ||
this.client.connack({ returnCode: 0 }); | ||
// this.client.connack({ returnCode: 0, sessionPresent }); | ||
} else { | ||
this.adapter.log.error(`[MQTT] Wrong MQTT authentification for: ${this.getName()}`); | ||
this.client.connack({ returnCode: 4 }); | ||
} | ||
} else { | ||
this.adapter.log.error(`[MQTT] Shelly device unknown, configuration for Shelly device ${this.getName()} does not exist!`); | ||
this.client.connack({ returnCode: 4 }); | ||
} | ||
}); | ||
this.client.on('close', (status) => { | ||
this.adapter.log.info(`[MQTT] Close Client: ${this.getName()} (${status})`); | ||
this.destroy(); | ||
}); | ||
this.client.on('error', (error) => { | ||
// this.adapter.log.info(`[MQTT] Error Client: ${this.getName()} (${error})`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('disconnect', () => { | ||
this.adapter.log.info(`[MQTT] Client Disconnect: ${this.getName()}`); | ||
this.destroy(); | ||
}); | ||
this.client.on('timeout', () => { | ||
this.adapter.log.info(`[MQTT] Client Timeout: ${this.getName()}`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('publish', (packet) => { | ||
this.adapter.log.silly(`[MQTT] Publish: ${this.getName()} - ${JSON.stringify(packet)}`); | ||
if (packet.payload) { | ||
this.adapter.log.debug(`[MQTT] Publish: ${this.getName()} - topic: ${packet.topic}, payload: ${packet.payload.toString()}`); | ||
} | ||
// the ip address in docker container ist sometimes in stream.remoteAddress. We replace it, with the announce address | ||
if (packet.topic === 'shellies/announce' && packet.payload) { | ||
try { | ||
let ip = JSON.parse(packet.payload).ip; | ||
if (ip) this.ip = ip; | ||
this.client.connack({ returnCode: 0 }); | ||
// this.client.connack({ returnCode: 0, sessionPresent }); | ||
} else { | ||
this.adapter.log.error(`[MQTT] Wrong MQTT authentification for: ${this.getName()}`); | ||
this.client.connack({ returnCode: 4 }); | ||
} | ||
} else { | ||
this.adapter.log.error(`[MQTT] Shelly device unknown, configuration for Shelly device ${this.getName()} does not exist!`); | ||
this.client.connack({ returnCode: 4 }); | ||
} | ||
}); | ||
this.client.on('close', (status) => { | ||
this.adapter.log.info(`[MQTT] Close Client: ${this.getName()} (${status})`); | ||
this.destroy(); | ||
}); | ||
this.client.on('error', (error) => { | ||
// this.adapter.log.info(`[MQTT] Error Client: ${this.getName()} (${error})`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('disconnect', () => { | ||
this.adapter.log.info(`[MQTT] Client Disconnect: ${this.getName()}`); | ||
this.destroy(); | ||
}); | ||
this.client.on('timeout', () => { | ||
this.adapter.log.info(`[MQTT] Client Timeout: ${this.getName()}`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('publish', (packet) => { | ||
this.adapter.log.silly(`[MQTT] Publish: ${this.getName()} - ${JSON.stringify(packet)}`); | ||
if (packet.payload) { | ||
this.adapter.log.debug(`[MQTT] Publish: ${this.getName()} - topic: ${packet.topic}, payload: ${packet.payload.toString()}`); | ||
} | ||
//this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
} catch (error) { | ||
// we do not change anything | ||
} | ||
} | ||
this.createIoBrokerState(packet.topic, packet.payload); | ||
switch (packet.qos) { | ||
case 1: | ||
this.client.puback({ messageId: packet.messageId }); | ||
break; | ||
case 2: | ||
this.client.pubrec({ messageId: packet.messageId }); | ||
this.resendState2Client('pubrec', packet.messageId); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
// this.client pinged | ||
this.client.on('pingreq', () => { | ||
// send a pingresp | ||
this.client.pingresp(); | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubrec', (packet) => { | ||
let qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'publish') { | ||
this.client.pubrel({ messageId: packet.messageId }); | ||
this.resendState2Client('pubrel', packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrec for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubcomp', (packet) => { | ||
let qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'pubrec') { | ||
this.deleteResendState2Client(packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubcomp for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubrel', (packet) => { | ||
let qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'pubrec') { | ||
this.deleteResendState2Client(packet.messageId); | ||
this.client.pubcomp({ messageId: packet.messageId }); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrel for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// the ip address in docker container ist sometimes in stream.remoteAddress. We replace it, with the announce address | ||
if (packet.topic === 'shellies/announce' && packet.payload) { | ||
try { | ||
const ip = JSON.parse(packet.payload).ip; | ||
if (ip) this.ip = ip; | ||
// response for QoS1 | ||
this.client.on('puback', (packet) => { | ||
// remove this message from queue | ||
let qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'publish') { | ||
this.deleteResendState2Client(packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received puback for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
//this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
} catch (error) { | ||
// we do not change anything | ||
} | ||
} | ||
this.createIoBrokerState(packet.topic, packet.payload); | ||
switch (packet.qos) { | ||
case 1: | ||
this.client.puback({ messageId: packet.messageId }); | ||
break; | ||
case 2: | ||
this.client.pubrec({ messageId: packet.messageId }); | ||
this.resendState2Client('pubrec', packet.messageId); | ||
break; | ||
default: | ||
break; | ||
} | ||
}); | ||
// this.client pinged | ||
this.client.on('pingreq', () => { | ||
// send a pingresp | ||
this.client.pingresp(); | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubrec', (packet) => { | ||
const qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'publish') { | ||
this.client.pubrel({ messageId: packet.messageId }); | ||
this.resendState2Client('pubrel', packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrec for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubcomp', (packet) => { | ||
const qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'pubrec') { | ||
this.deleteResendState2Client(packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubcomp for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// response for QoS2 | ||
this.client.on('pubrel', (packet) => { | ||
const qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'pubrec') { | ||
this.deleteResendState2Client(packet.messageId); | ||
this.client.pubcomp({ messageId: packet.messageId }); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrel for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
this.client.on('unsubscribe', (packet) => { | ||
this.adapter.log.debug(`[MQTT] Unsubscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
this.client.unsuback({ messageId: packet.messageId }); | ||
}); | ||
// response for QoS1 | ||
this.client.on('puback', (packet) => { | ||
// remove this message from queue | ||
const qosmsg = this.getResendState2Client(packet.messageId); | ||
if (qosmsg && qosmsg.cmd === 'publish') { | ||
this.deleteResendState2Client(packet.messageId); | ||
} else { | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received puback for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
// this.client subscribed | ||
this.client.on('subscribe', (packet) => { | ||
// send a suback with messageId and granted QoS level | ||
this.adapter.log.debug(`[MQTT] Subscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
const granted = []; | ||
for (let i in packet.subscriptions) { | ||
granted.push(packet.subscriptions[i].qos); | ||
let topic = packet.subscriptions[i].topic; | ||
} | ||
if (packet.topic) { | ||
this.adapter.log.debug(`[MQTT] Subscribe topic ${this.getName()}: ${packet.topic}`); | ||
} | ||
this.client.suback({ granted: granted, messageId: packet.messageId }); | ||
}); | ||
} | ||
this.client.on('unsubscribe', (packet) => { | ||
this.adapter.log.debug(`[MQTT] Unsubscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
this.client.unsuback({ messageId: packet.messageId }); | ||
}); | ||
// this.client subscribed | ||
this.client.on('subscribe', (packet) => { | ||
// send a suback with messageId and granted QoS level | ||
this.adapter.log.debug(`[MQTT] Subscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
const granted = []; | ||
for (const i in packet.subscriptions) { | ||
granted.push(packet.subscriptions[i].qos); | ||
const topic = packet.subscriptions[i].topic; | ||
} | ||
if (packet.topic) { | ||
this.adapter.log.debug(`[MQTT] Subscribe topic ${this.getName()}: ${packet.topic}`); | ||
} | ||
this.client.suback({ granted: granted, messageId: packet.messageId }); | ||
}); | ||
} | ||
} | ||
@@ -560,54 +560,54 @@ | ||
constructor(adapter, objectHelper, eventEmitter) { | ||
constructor(adapter, objectHelper, eventEmitter) { | ||
//if (!(this instanceof MQTTServer)) return new MQTTServer(adapter, objectHelper, eventEmitter); | ||
super(adapter, objectHelper, eventEmitter); | ||
super(adapter, objectHelper, eventEmitter); | ||
this.messageId = 1; | ||
this.server = new net.Server(); | ||
this.clients = []; | ||
} | ||
this.messageId = 1; | ||
this.server = new net.Server(); | ||
this.clients = []; | ||
} | ||
listen() { | ||
listen() { | ||
// let clientlist = {}; | ||
this.server.on('connection', (stream) => { | ||
let client = new MQTTClient(this.adapter, this.objectHelper, this.eventEmitter, stream); | ||
stream.on('timeout', () => { | ||
this.adapter.log.info('Server Timeout for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
client.destroy(); | ||
stream.destroy(); | ||
}); | ||
stream.on('unload', () => { | ||
this.adapter.log.info('Server Unload for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
client.destroy(); | ||
stream.destroy(); | ||
}); | ||
stream.on('error', () => { | ||
// this.adapter.log.info('Stream Error for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
if (client) { | ||
client.destroy(); | ||
stream.destroy(); | ||
} | ||
}); | ||
stream.on('close', () => { | ||
// this.adapter.log.debug('Stream Close for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
}); | ||
stream.on('end', () => { | ||
this.adapter.log.debug('Stream Ends for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
}); | ||
}); | ||
this.server.on('close', () => { | ||
this.adapter.log.info('Closing listender '); | ||
}); | ||
this.server.on('error', (error) => { | ||
this.adapter.log.error('Error in listender ' + error); | ||
}); | ||
// listen on port 1883 | ||
this.server.listen(this.adapter.config.port, this.adapter.config.bind, () => { | ||
}); | ||
} | ||
this.server.on('connection', (stream) => { | ||
const client = new MQTTClient(this.adapter, this.objectHelper, this.eventEmitter, stream); | ||
stream.on('timeout', () => { | ||
this.adapter.log.info('Server Timeout for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
client.destroy(); | ||
stream.destroy(); | ||
}); | ||
stream.on('unload', () => { | ||
this.adapter.log.info('Server Unload for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
client.destroy(); | ||
stream.destroy(); | ||
}); | ||
stream.on('error', () => { | ||
// this.adapter.log.info('Stream Error for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
if (client) { | ||
client.destroy(); | ||
stream.destroy(); | ||
} | ||
}); | ||
stream.on('close', () => { | ||
// this.adapter.log.debug('Stream Close for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
}); | ||
stream.on('end', () => { | ||
this.adapter.log.debug('Stream Ends for ' + stream.remoteAddress + ' (' + client.getName() + ')'); | ||
}); | ||
}); | ||
this.server.on('close', () => { | ||
this.adapter.log.info('Closing listender '); | ||
}); | ||
this.server.on('error', (error) => { | ||
this.adapter.log.error('Error in listender ' + error); | ||
}); | ||
// listen on port 1883 | ||
this.server.listen(this.adapter.config.port, this.adapter.config.bind, () => { | ||
}); | ||
} | ||
} | ||
module.exports = { | ||
MQTTServer: MQTTServer | ||
MQTTServer: MQTTServer | ||
}; |
@@ -15,8 +15,8 @@ /* jshint -W097 */ | ||
function celsiusToFahrenheit(celsius) { | ||
try { | ||
let fahrenheit = celsius * 1.8 + 32; | ||
return Math.round(fahrenheit * 100) / 100; | ||
} catch (error) { | ||
return undefined; | ||
} | ||
try { | ||
const fahrenheit = celsius * 1.8 + 32; | ||
return Math.round(fahrenheit * 100) / 100; | ||
} catch (error) { | ||
return undefined; | ||
} | ||
} | ||
@@ -29,31 +29,31 @@ | ||
function fahrenheitToCelsius(fahrenheit) { | ||
try { | ||
let celsius = (fahrenheit - 32) * 5 / 9; | ||
return Math.round(celsius * 100) / 100; | ||
} catch (error) { | ||
return undefined; | ||
} | ||
try { | ||
const celsius = (fahrenheit - 32) * 5 / 9; | ||
return Math.round(celsius * 100) / 100; | ||
} catch (error) { | ||
return undefined; | ||
} | ||
} | ||
/** | ||
* | ||
* @param {*} self | ||
* @param {*} devicename - Name of the device like 'livingroom' | ||
* | ||
* @param {*} self | ||
* @param {*} devicename - Name of the device like 'livingroom' | ||
*/ | ||
async function setDeviceName(self, devicename) { | ||
let name = devicename; | ||
let deviceid = self.getDeviceName(); | ||
let obj = await self.adapter.getObjectAsync(deviceid); | ||
// if (!name) name = 'Device ' + deviceid; | ||
if (name && obj && obj.common && name !== obj.common.name) { | ||
obj.common.name = name; | ||
await self.adapter.setObjectAsync(deviceid, obj); | ||
self.states[deviceid] = name; | ||
} | ||
return devicename; | ||
const name = devicename; | ||
const deviceid = self.getDeviceName(); | ||
const obj = await self.adapter.getObjectAsync(deviceid); | ||
// if (!name) name = 'Device ' + deviceid; | ||
if (name && obj && obj.common && name !== obj.common.name) { | ||
obj.common.name = name; | ||
await self.adapter.setObjectAsync(deviceid, obj); | ||
self.states[deviceid] = name; | ||
} | ||
return devicename; | ||
} | ||
/** | ||
* | ||
* @param {*} self | ||
* | ||
* @param {*} self | ||
* @param {*} state - channel like Relay0.Channel | ||
@@ -63,15 +63,15 @@ * @param {*} channelename - Name of the channel like 'channel 1 like livingroom' | ||
async function setChannelName(self, state, channelename) { | ||
let name = channelename; | ||
let channel = state.split('.').slice(0, -1).join(); | ||
if (channel) { | ||
let channelid = self.getDeviceName() + '.' + channel; | ||
let obj = await self.adapter.getObjectAsync(channelid); | ||
// if (!name) name = 'Channel ' + state.split('.').slice(0, 1).join(); | ||
if (name && obj && obj.common && name !== obj.common.name) { | ||
obj.common.name = name; | ||
await self.adapter.setObjectAsync(channelid, obj); | ||
self.states[channelid] = name; | ||
const name = channelename; | ||
const channel = state.split('.').slice(0, -1).join(); | ||
if (channel) { | ||
const channelid = self.getDeviceName() + '.' + channel; | ||
const obj = await self.adapter.getObjectAsync(channelid); | ||
// if (!name) name = 'Channel ' + state.split('.').slice(0, 1).join(); | ||
if (name && obj && obj.common && name !== obj.common.name) { | ||
obj.common.name = name; | ||
await self.adapter.setObjectAsync(channelid, obj); | ||
self.states[channelid] = name; | ||
} | ||
} | ||
} | ||
return channelename; | ||
return channelename; | ||
} | ||
@@ -86,37 +86,23 @@ | ||
function uptimeString(uptime) { | ||
if (uptime < 0) { | ||
uptime = 0; | ||
} | ||
if (uptime < 0) { | ||
uptime = 0; | ||
} | ||
let timeDifference = new Date(uptime * 1000); | ||
let secondsInADay = 60 * 60 * 1000 * 24; | ||
let secondsInAHour = 60 * 60 * 1000; | ||
let days = Math.floor(timeDifference / (secondsInADay) * 1); | ||
let hours = Math.floor((timeDifference % (secondsInADay)) / (secondsInAHour) * 1); | ||
let mins = Math.floor(((timeDifference % (secondsInADay)) % (secondsInAHour)) / (60 * 1000) * 1); | ||
let secs = Math.floor((((timeDifference % (secondsInADay)) % (secondsInAHour)) % (60 * 1000)) / 1000 * 1); | ||
const timeDifference = new Date(uptime * 1000); | ||
const secondsInADay = 60 * 60 * 1000 * 24; | ||
const secondsInAHour = 60 * 60 * 1000; | ||
const days = Math.floor(timeDifference / (secondsInADay) * 1); | ||
let hours = Math.floor((timeDifference % (secondsInADay)) / (secondsInAHour) * 1); | ||
let mins = Math.floor(((timeDifference % (secondsInADay)) % (secondsInAHour)) / (60 * 1000) * 1); | ||
let secs = Math.floor((((timeDifference % (secondsInADay)) % (secondsInAHour)) % (60 * 1000)) / 1000 * 1); | ||
if (hours < 10) { hours = '0' + hours; } | ||
if (mins < 10) { mins = '0' + mins; } | ||
if (secs < 10) { secs = '0' + secs; } | ||
if (hours < 10) { hours = '0' + hours; } | ||
if (mins < 10) { mins = '0' + mins; } | ||
if (secs < 10) { secs = '0' + secs; } | ||
if (days > 0) { | ||
return days + 'D' + hours + ':' + mins + ':' + secs; | ||
} else { | ||
return hours + ':' + mins + ':' + secs; | ||
} | ||
} | ||
/** | ||
* get the CoAP value by key | ||
* @param {integer} key - like 112 | ||
* @param {array} array - [[0,111,0],[0,112,1]] | ||
*/ | ||
function getCoapValue(key, array) { | ||
if (array) { | ||
for (let k in array) { | ||
if (array[k][1] === key) return array[k][2]; | ||
if (days > 0) { | ||
return days + 'D' + hours + ':' + mins + ':' + secs; | ||
} else { | ||
return hours + ':' + mins + ':' + secs; | ||
} | ||
} | ||
return undefined; | ||
} | ||
@@ -131,22 +117,22 @@ | ||
function getExtTemp(value, key, unit) { | ||
let unitkey = ''; | ||
switch (unit) { | ||
case 'C': | ||
unitkey = 'tC'; | ||
break; | ||
case 'F': | ||
unitkey = 'tF'; | ||
break; | ||
default: | ||
return 0; | ||
} | ||
if (value && value.hasOwnProperty('ext_temperature') && value.ext_temperature.hasOwnProperty(key) && value.ext_temperature[key].hasOwnProperty(unitkey)) { | ||
return value.ext_temperature[key][unitkey]; | ||
} else { | ||
return 0; | ||
} | ||
let unitkey = ''; | ||
switch (unit) { | ||
case 'C': | ||
unitkey = 'tC'; | ||
break; | ||
case 'F': | ||
unitkey = 'tF'; | ||
break; | ||
default: | ||
return 0; | ||
} | ||
if (value && value.hasOwnProperty('ext_temperature') && value.ext_temperature.hasOwnProperty(key) && value.ext_temperature[key].hasOwnProperty(unitkey)) { | ||
return value.ext_temperature[key][unitkey]; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
/** | ||
* Get external humidity for device with key | ||
* Get external humidity for device with key | ||
* @param {*} value - like JSON.parse(value) | ||
@@ -156,7 +142,7 @@ * @param {*} key - '0', '1', .... | ||
function getExtHum(value, key) { | ||
if (value && value.hasOwnProperty('ext_humidity') && value.ext_humidity.hasOwnProperty(key) && value.ext_humidity[key].hasOwnProperty('hum')) { | ||
return value.ext_humidity[key]['hum']; | ||
} else { | ||
return 0; | ||
} | ||
if (value && value.hasOwnProperty('ext_humidity') && value.ext_humidity.hasOwnProperty(key) && value.ext_humidity[key].hasOwnProperty('hum')) { | ||
return value.ext_humidity[key]['hum']; | ||
} else { | ||
return 0; | ||
} | ||
} | ||
@@ -166,40 +152,40 @@ | ||
* | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getLightsObjectColor(self) { | ||
let id = self.getDeviceName(); | ||
let obj = { | ||
'ison': 'lights.Switch', | ||
'mode': 'lights.mode', | ||
'red': 'lights.red', | ||
'green': 'lights.green', | ||
'blue': 'lights.blue', | ||
'white': 'lights.white', | ||
'gain': 'lights.gain', | ||
'temp': 'lights.temp', | ||
'brightness': 'lights.brightness', | ||
'effect': 'lights.effect' | ||
}; | ||
for (let i in obj) { | ||
let stateId = id + '.' + obj[i]; | ||
let state = await self.adapter.getStateAsync(stateId); | ||
obj[i] = state ? state.val : undefined; | ||
} | ||
return obj; | ||
const id = self.getDeviceName(); | ||
const obj = { | ||
'ison': 'lights.Switch', | ||
'mode': 'lights.mode', | ||
'red': 'lights.red', | ||
'green': 'lights.green', | ||
'blue': 'lights.blue', | ||
'white': 'lights.white', | ||
'gain': 'lights.gain', | ||
'temp': 'lights.temp', | ||
'brightness': 'lights.brightness', | ||
'effect': 'lights.effect' | ||
}; | ||
for (const i in obj) { | ||
const stateId = id + '.' + obj[i]; | ||
const state = await self.adapter.getStateAsync(stateId); | ||
obj[i] = state ? state.val : undefined; | ||
} | ||
return obj; | ||
} | ||
async function getLightsObjectWhite(self) { | ||
let id = self.getDeviceName(); | ||
let obj = { | ||
'ison': 'lights.Switch', | ||
'white': 'lights.white', | ||
'temp': 'lights.temp', | ||
'brightness': 'lights.brightness' | ||
}; | ||
for (let i in obj) { | ||
let stateId = id + '.' + obj[i]; | ||
let state = await self.adapter.getStateAsync(stateId); | ||
obj[i] = state ? state.val : undefined; | ||
} | ||
return obj; | ||
const id = self.getDeviceName(); | ||
const obj = { | ||
'ison': 'lights.Switch', | ||
'white': 'lights.white', | ||
'temp': 'lights.temp', | ||
'brightness': 'lights.brightness' | ||
}; | ||
for (const i in obj) { | ||
const stateId = id + '.' + obj[i]; | ||
const state = await self.adapter.getStateAsync(stateId); | ||
obj[i] = state ? state.val : undefined; | ||
} | ||
return obj; | ||
} | ||
@@ -212,6 +198,6 @@ | ||
function intToHex(number) { | ||
if (!number) number = 0; | ||
let hex = number.toString(16); | ||
hex = ('00' + hex).slice(-2).toUpperCase(); // 'a' -> '0A' | ||
return hex; | ||
if (!number) number = 0; | ||
let hex = number.toString(16); | ||
hex = ('00' + hex).slice(-2).toUpperCase(); // 'a' -> '0A' | ||
return hex; | ||
} | ||
@@ -224,4 +210,4 @@ | ||
function hextoInt(hex) { | ||
if (!hex) hex = '00'; | ||
return parseInt(hex, 16); | ||
if (!hex) hex = '00'; | ||
return parseInt(hex, 16); | ||
} | ||
@@ -231,32 +217,32 @@ | ||
* get the RGBW value for red, green, blue, white value | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getRGBW(self) { | ||
let id = self.getDeviceName(); | ||
let stateId; | ||
let state; | ||
stateId = id + '.lights.red'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valred = state ? state.val : 0; | ||
stateId = id + '.lights.green'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valgreen = state ? state.val : 0; | ||
stateId = id + '.lights.blue'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valblue = state ? state.val : 0; | ||
stateId = id + '.lights.white'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valwhite = state ? state.val : 0; | ||
return '#' + intToHex(valred) + intToHex(valgreen) + intToHex(valblue) + intToHex(valwhite); | ||
const id = self.getDeviceName(); | ||
let stateId; | ||
let state; | ||
stateId = id + '.lights.red'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valred = state ? state.val : 0; | ||
stateId = id + '.lights.green'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valgreen = state ? state.val : 0; | ||
stateId = id + '.lights.blue'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valblue = state ? state.val : 0; | ||
stateId = id + '.lights.white'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valwhite = state ? state.val : 0; | ||
return '#' + intToHex(valred) + intToHex(valgreen) + intToHex(valblue) + intToHex(valwhite); | ||
} | ||
function getColorsFromRGBW(value) { | ||
value = value || '#00000000'; | ||
let obj = { | ||
red: hextoInt(value.substr(1, 2) || '00'), | ||
green: hextoInt(value.substr(3, 2) || '00'), | ||
blue: hextoInt(value.substr(5, 2) || '00'), | ||
white: hextoInt(value.substr(7, 2) || '00') | ||
}; | ||
return obj; | ||
value = value || '#00000000'; | ||
const obj = { | ||
red: hextoInt(value.substr(1, 2) || '00'), | ||
green: hextoInt(value.substr(3, 2) || '00'), | ||
blue: hextoInt(value.substr(5, 2) || '00'), | ||
white: hextoInt(value.substr(7, 2) || '00') | ||
}; | ||
return obj; | ||
} | ||
@@ -267,50 +253,50 @@ | ||
async function getHsvFromRgb(self) { | ||
let value = await getRGBW(self); | ||
let rgbw = getColorsFromRGBW(value); | ||
let hsv = colorconv.rgbToHsv(rgbw.red, rgbw.green, rgbw.blue); | ||
return { | ||
hue: hsv[0], | ||
saturation: hsv[1], | ||
brightness: hsv[2] | ||
}; | ||
const value = await getRGBW(self); | ||
const rgbw = getColorsFromRGBW(value); | ||
const hsv = colorconv.rgbToHsv(rgbw.red, rgbw.green, rgbw.blue); | ||
return { | ||
hue: hsv[0], | ||
saturation: hsv[1], | ||
brightness: hsv[2] | ||
}; | ||
} | ||
async function getColorsFromHue(self) { | ||
let id = self.getDeviceName(); | ||
let stateId; | ||
let state; | ||
stateId = id + '.lights.hue'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valhue = state ? state.val : 0; | ||
stateId = id + '.lights.saturation'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valsaturation = state ? state.val : 0; | ||
// stateId = id + '.lights.value'; | ||
stateId = id + '.lights.gain'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valvalue = state ? state.val : 0; | ||
let rgb = colorconv.hsvToRgb(valhue, valsaturation, valvalue); | ||
let obj = { | ||
red: rgb[0], | ||
green: rgb[1], | ||
blue: rgb[2], | ||
}; | ||
return obj; | ||
const id = self.getDeviceName(); | ||
let stateId; | ||
let state; | ||
stateId = id + '.lights.hue'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valhue = state ? state.val : 0; | ||
stateId = id + '.lights.saturation'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valsaturation = state ? state.val : 0; | ||
// stateId = id + '.lights.value'; | ||
stateId = id + '.lights.gain'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
const valvalue = state ? state.val : 0; | ||
const rgb = colorconv.hsvToRgb(valhue, valsaturation, valvalue); | ||
const obj = { | ||
red: rgb[0], | ||
green: rgb[1], | ||
blue: rgb[2], | ||
}; | ||
return obj; | ||
} | ||
async function getPowerFactor(self, channel) { | ||
// let stateVoltage = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.Voltage'); | ||
let statePower = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.Power'); | ||
let stateReactivePower = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.ReactivePower'); | ||
let pf = 0.00; | ||
if (statePower && stateReactivePower) { | ||
// let stateVoltage = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.Voltage'); | ||
const statePower = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.Power'); | ||
const stateReactivePower = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter' + channel + '.ReactivePower'); | ||
let pf = 0.00; | ||
if (statePower && stateReactivePower) { | ||
// let voltage = stateVoltage.val; | ||
let power = statePower.val; | ||
let reactive = stateReactivePower.val; | ||
if (Math.abs(power) + Math.abs(reactive) > 1.5) { | ||
pf = power / Math.sqrt(power * power + reactive * reactive); | ||
pf = Math.round(pf * 100) / 100; | ||
const power = statePower.val; | ||
const reactive = stateReactivePower.val; | ||
if (Math.abs(power) + Math.abs(reactive) > 1.5) { | ||
pf = power / Math.sqrt(power * power + reactive * reactive); | ||
pf = Math.round(pf * 100) / 100; | ||
} | ||
} | ||
} | ||
return pf; | ||
return pf; | ||
} | ||
@@ -320,12 +306,12 @@ | ||
* For EM3, it was not a good idea to implement this function. To far away from standard | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getTotalSumm(self) { | ||
let calctotal = 0.00; | ||
let TotalPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Total'); | ||
let TotalPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Total'); | ||
let TotalPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Total'); | ||
calctotal = (TotalPhase1.val + TotalPhase2.val + TotalPhase3.val); | ||
calctotal = Math.round(calctotal * 100) / 100; | ||
return calctotal; | ||
let calctotal = 0.00; | ||
const TotalPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Total'); | ||
const TotalPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Total'); | ||
const TotalPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Total'); | ||
calctotal = (TotalPhase1.val + TotalPhase2.val + TotalPhase3.val); | ||
calctotal = Math.round(calctotal * 100) / 100; | ||
return calctotal; | ||
} | ||
@@ -335,9 +321,9 @@ | ||
async function getTotalReturnedSumm(self) { | ||
let calctotal = 0.00; | ||
let TotalPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Total_Returned'); | ||
let TotalPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Total_Returned'); | ||
let TotalPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Total_Returned'); | ||
calctotal = (TotalPhase1.val + TotalPhase2.val + TotalPhase3.val); | ||
calctotal = Math.round(calctotal * 100) / 100; | ||
return calctotal; | ||
let calctotal = 0.00; | ||
const TotalPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Total_Returned'); | ||
const TotalPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Total_Returned'); | ||
const TotalPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Total_Returned'); | ||
calctotal = (TotalPhase1.val + TotalPhase2.val + TotalPhase3.val); | ||
calctotal = Math.round(calctotal * 100) / 100; | ||
return calctotal; | ||
} | ||
@@ -348,12 +334,12 @@ | ||
* For EM3, it was not a good idea to implement this function. To far away from standard | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getCurrentSumm(self) { | ||
let calccurrent = 0.00; | ||
let CurrentPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Current'); | ||
let CurrentPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Current'); | ||
let CurrentPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Current'); | ||
calccurrent = (CurrentPhase1.val + CurrentPhase2.val + CurrentPhase3.val); | ||
calccurrent = Math.round(calccurrent * 100) / 100; | ||
return calccurrent; | ||
let calccurrent = 0.00; | ||
const CurrentPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Current'); | ||
const CurrentPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Current'); | ||
const CurrentPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Current'); | ||
calccurrent = (CurrentPhase1.val + CurrentPhase2.val + CurrentPhase3.val); | ||
calccurrent = Math.round(calccurrent * 100) / 100; | ||
return calccurrent; | ||
} | ||
@@ -363,12 +349,12 @@ | ||
* For EM3, it was not a good idea to implement this function. To far away from standard | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getPowerSumm(self) { | ||
let calcPower = 0.00; | ||
let PowerPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Power'); | ||
let PowerPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Power'); | ||
let PowerPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Power'); | ||
calcPower = (PowerPhase1.val + PowerPhase2.val + PowerPhase3.val); | ||
calcPower = Math.round(calcPower * 100) / 100; | ||
return calcPower; | ||
let calcPower = 0.00; | ||
const PowerPhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Power'); | ||
const PowerPhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Power'); | ||
const PowerPhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Power'); | ||
calcPower = (PowerPhase1.val + PowerPhase2.val + PowerPhase3.val); | ||
calcPower = Math.round(calcPower * 100) / 100; | ||
return calcPower; | ||
} | ||
@@ -378,16 +364,16 @@ | ||
* For EM3, it was not a good idea to implement this function. To far away from standard | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getVoltageCalc(self, vtype) { | ||
let calcVoltage = 0.00; | ||
let VoltagePhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Voltage'); | ||
let VoltagePhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Voltage'); | ||
let VoltagePhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Voltage'); | ||
if (vtype == 'mean') { | ||
calcVoltage = ((VoltagePhase1.val + VoltagePhase2.val + VoltagePhase3.val) / 3); | ||
} else { | ||
calcVoltage = ((VoltagePhase1.val + VoltagePhase2.val + VoltagePhase3.val) / Math.sqrt(3)); | ||
} | ||
calcVoltage = Math.round(calcVoltage * 100) / 100; | ||
return calcVoltage; | ||
let calcVoltage = 0.00; | ||
const VoltagePhase1 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter0.Voltage'); | ||
const VoltagePhase2 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter1.Voltage'); | ||
const VoltagePhase3 = await self.adapter.getStateAsync(self.getDeviceName() + '.Emeter2.Voltage'); | ||
if (vtype == 'mean') { | ||
calcVoltage = ((VoltagePhase1.val + VoltagePhase2.val + VoltagePhase3.val) / 3); | ||
} else { | ||
calcVoltage = ((VoltagePhase1.val + VoltagePhase2.val + VoltagePhase3.val) / Math.sqrt(3)); | ||
} | ||
calcVoltage = Math.round(calcVoltage * 100) / 100; | ||
return calcVoltage; | ||
} | ||
@@ -397,14 +383,14 @@ | ||
* Get golor mode like white or color | ||
* @param {*} self | ||
* @param {*} self | ||
*/ | ||
async function getMode(self) { | ||
let id = self.getDeviceName(); | ||
let stateId = id + '.mode'; | ||
let state = await self.adapter.getStateAsync(stateId); | ||
return state ? state.val : undefined; | ||
const id = self.getDeviceName(); | ||
const stateId = id + '.mode'; | ||
const state = await self.adapter.getStateAsync(stateId); | ||
return state ? state.val : undefined; | ||
} | ||
/** | ||
* Timer | ||
* @param {*} self | ||
* Timer | ||
* @param {*} self | ||
* @param {*} id - like 'Relay0.Timer' | ||
@@ -414,16 +400,16 @@ * @param {*} newval - 10 | ||
async function getSetDuration(self, id, newval) { | ||
try { | ||
id = self.getDeviceName() + '.' + id; | ||
let state = await self.adapter.getStateAsync(id); | ||
let value; | ||
if (state) { | ||
value = state.val > 0 ? state.val : 0; | ||
try { | ||
id = self.getDeviceName() + '.' + id; | ||
const state = await self.adapter.getStateAsync(id); | ||
let value; | ||
if (state) { | ||
value = state.val > 0 ? state.val : 0; | ||
} | ||
if (newval >= 0) { | ||
await self.adapter.setStateAsync(id, { val: newval, ack: true }); | ||
} | ||
return value; | ||
} catch (error) { | ||
return 0; | ||
} | ||
if (newval >= 0) { | ||
await self.adapter.setStateAsync(id, { val: newval, ack: true }); | ||
} | ||
return value; | ||
} catch (error) { | ||
return 0; | ||
} | ||
} | ||
@@ -437,10 +423,10 @@ | ||
async function getFavoritePosition(self, id) { | ||
let node = self.getDeviceName() + '.' + id; | ||
let state = await self.adapter.getStateAsync(node); | ||
return state ? state.val : undefined; | ||
const node = self.getDeviceName() + '.' + id; | ||
const state = await self.adapter.getStateAsync(node); | ||
return state ? state.val : undefined; | ||
} | ||
/** | ||
* | ||
* @param {*} self - self object | ||
* | ||
* @param {*} self - self object | ||
* @param {*} id - id of state like relay0.switch | ||
@@ -452,14 +438,14 @@ * @param {*} value - value like true | ||
function setAndInitValue(self, id, value, initvalue, ms) { | ||
id = self.getDeviceName() + '.' + id; | ||
if (!ms) ms = 100; | ||
if (value != initvalue) setTimeout(async () => { | ||
self.states[id] = initvalue; | ||
await self.adapter.setStateAsync(id, { val: initvalue, ack: true }); | ||
}, ms); | ||
return value; | ||
id = self.getDeviceName() + '.' + id; | ||
if (!ms) ms = 100; | ||
if (value != initvalue) setTimeout(async () => { | ||
self.states[id] = initvalue; | ||
await self.adapter.setStateAsync(id, { val: initvalue, ack: true }); | ||
}, ms); | ||
return value; | ||
} | ||
/** | ||
* | ||
* @param {*} self - self object | ||
* | ||
* @param {*} self - self object | ||
* @param {*} id - id of state like relay0.switch | ||
@@ -469,43 +455,43 @@ * @param {*} value - value like false or 'huhu' | ||
async function setValueForId(self, id, value) { | ||
id = self.getDeviceName() + '.' + id; | ||
await self.adapter.setStateAsync(id, { val: value, ack: true }); | ||
id = self.getDeviceName() + '.' + id; | ||
await self.adapter.setStateAsync(id, { val: value, ack: true }); | ||
} | ||
async function getValue(self, id) { | ||
try { | ||
if (id && id[0] !== '.') id = '.' + id; | ||
let state = await self.adapter.getStateAsync(self.getDeviceName() + id); | ||
if (state) { return state.val; } else { return undefined; } | ||
} catch (error) { | ||
return undefined; | ||
} | ||
try { | ||
if (id && id[0] !== '.') id = '.' + id; | ||
const state = await self.adapter.getStateAsync(self.getDeviceName() + id); | ||
if (state) { return state.val; } else { return undefined; } | ||
} catch (error) { | ||
return undefined; | ||
} | ||
} | ||
module.exports = { | ||
celsiusToFahrenheit: celsiusToFahrenheit, | ||
fahrenheitToCelsius: fahrenheitToCelsius, | ||
setDeviceName: setDeviceName, | ||
setChannelName: setChannelName, | ||
uptimeString: uptimeString, | ||
getExtTemp: getExtTemp, | ||
getExtHum: getExtHum, | ||
getLightsObjectColor: getLightsObjectColor, | ||
getLightsObjectWhite: getLightsObjectWhite, | ||
intToHex: intToHex, | ||
getHsvFromRgb: getHsvFromRgb, | ||
getColorsFromHue: getColorsFromHue, | ||
getColorsFromRGBW: getColorsFromRGBW, | ||
getPowerFactor: getPowerFactor, | ||
getTotalSumm: getTotalSumm, | ||
getTotalReturnedSumm: getTotalReturnedSumm, | ||
getCurrentSumm: getCurrentSumm, | ||
getPowerSumm: getPowerSumm, | ||
getVoltageCalc: getVoltageCalc, | ||
getMode: getMode, | ||
getSetDuration: getSetDuration, | ||
getFavoritePosition: getFavoritePosition, | ||
getRGBW: getRGBW, | ||
setAndInitValue: setAndInitValue, | ||
setValueForId: setValueForId, | ||
getValue: getValue | ||
celsiusToFahrenheit: celsiusToFahrenheit, | ||
fahrenheitToCelsius: fahrenheitToCelsius, | ||
setDeviceName: setDeviceName, | ||
setChannelName: setChannelName, | ||
uptimeString: uptimeString, | ||
getExtTemp: getExtTemp, | ||
getExtHum: getExtHum, | ||
getLightsObjectColor: getLightsObjectColor, | ||
getLightsObjectWhite: getLightsObjectWhite, | ||
intToHex: intToHex, | ||
getHsvFromRgb: getHsvFromRgb, | ||
getColorsFromHue: getColorsFromHue, | ||
getColorsFromRGBW: getColorsFromRGBW, | ||
getPowerFactor: getPowerFactor, | ||
getTotalSumm: getTotalSumm, | ||
getTotalReturnedSumm: getTotalReturnedSumm, | ||
getCurrentSumm: getCurrentSumm, | ||
getPowerSumm: getPowerSumm, | ||
getVoltageCalc: getVoltageCalc, | ||
getMode: getMode, | ||
getSetDuration: getSetDuration, | ||
getFavoritePosition: getFavoritePosition, | ||
getRGBW: getRGBW, | ||
setAndInitValue: setAndInitValue, | ||
setValueForId: setValueForId, | ||
getValue: getValue | ||
}; |
@@ -1,2 +0,2 @@ | ||
const axios = require("axios"); | ||
const axios = require('axios'); | ||
@@ -13,3 +13,3 @@ /** | ||
// [] instanceof Object === true | ||
return Object.prototype.toString.call(it) === "[object Object]"; | ||
return Object.prototype.toString.call(it) === '[object Object]'; | ||
} | ||
@@ -25,3 +25,3 @@ | ||
return Array.isArray(it); | ||
return Object.prototype.toString.call(it) === "[object Array]"; | ||
return Object.prototype.toString.call(it) === '[object Array]'; | ||
} | ||
@@ -37,3 +37,3 @@ | ||
async function translateText(text, targetLang, yandex) { | ||
if (targetLang === "en") { | ||
if (targetLang === 'en') { | ||
return text; | ||
@@ -56,4 +56,4 @@ } | ||
async function translateYandex(text, targetLang, yandex) { | ||
if (targetLang === "zh-cn") { | ||
targetLang = "zh"; | ||
if (targetLang === 'zh-cn') { | ||
targetLang = 'zh'; | ||
} | ||
@@ -66,3 +66,3 @@ try { | ||
} | ||
throw new Error("Invalid response for translate request"); | ||
throw new Error('Invalid response for translate request'); | ||
} catch (e) { | ||
@@ -87,3 +87,3 @@ throw new Error(`Could not translate to "${targetLang}": ${e}`); | ||
} | ||
throw new Error("Invalid response for translate request"); | ||
throw new Error('Invalid response for translate request'); | ||
} catch (e) { | ||
@@ -90,0 +90,0 @@ throw new Error(`Could not translate to "${targetLang}": ${e}`); |
@@ -274,3 +274,3 @@ /* jshint -W097 */ | ||
if (this.config.keys) { | ||
native.blacklist = this.config.keys.map(b => { return { id: b.blacklist } }); | ||
native.blacklist = this.config.keys.map(b => { return { id: b.blacklist }; }); | ||
native.keys = null; | ||
@@ -282,3 +282,3 @@ } | ||
await this.extendForeignObjectAsync('system.adapter.' + this.namespace, { native: native }); | ||
return true; | ||
@@ -285,0 +285,0 @@ } |
{ | ||
"name": "iobroker.shelly", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"description": "Shelly", | ||
@@ -43,3 +43,3 @@ "author": { | ||
"digest-fetch": "^1.2.1", | ||
"mqtt": "^4.3.4", | ||
"mqtt": "^4.3.5", | ||
"mqtt-connection": "^4.1.0", | ||
@@ -53,6 +53,6 @@ "node-fetch": "^2.6.7", | ||
"devDependencies": { | ||
"@alcalzone/release-script": "^3.5.0", | ||
"@alcalzone/release-script-plugin-iobroker": "^3.5.0", | ||
"@alcalzone/release-script": "^3.5.2", | ||
"@alcalzone/release-script-plugin-iobroker": "^3.5.1", | ||
"@alcalzone/release-script-plugin-license": "^3.5.0", | ||
"@iobroker/testing": "^2.5.2", | ||
"@iobroker/testing": "^2.5.4", | ||
"@types/chai": "^4.3.0", | ||
@@ -62,12 +62,12 @@ "@types/chai-as-promised": "^7.1.4", | ||
"@types/mocha": "^9.1.0", | ||
"@types/node": "^17.0.10", | ||
"@types/node": "^17.0.16", | ||
"@types/proxyquire": "^1.3.28", | ||
"@types/sinon": "^10.0.8", | ||
"@types/sinon": "^10.0.11", | ||
"@types/sinon-chai": "^3.2.8", | ||
"axios": "^0.24.0", | ||
"chai": "^4.3.4", | ||
"axios": "^0.25.0", | ||
"chai": "^4.3.6", | ||
"chai-as-promised": "^7.1.1", | ||
"eslint": "^8.7.0", | ||
"eslint": "^8.8.0", | ||
"gulp": "^4.0.2", | ||
"mocha": "^9.1.4", | ||
"mocha": "^9.2.0", | ||
"proxyquire": "^2.1.3", | ||
@@ -74,0 +74,0 @@ "sinon": "^12.0.1", |
@@ -85,2 +85,8 @@ ![Logo](admin/shelly.png) | ||
--> | ||
### 5.1.3 (2022-02-13) | ||
* (klein0r) Changed common.states strings to objects | ||
* (klein0r) Just perform firmware update if an available update was detected | ||
* (klein0r) Extended logging for CoAP | ||
### 5.1.2 (2022-01-29) | ||
@@ -87,0 +93,0 @@ * (klein0r) Fixed Shelly UNI ADC voltage |
782714
16451
425
Updatedmqtt@^4.3.5