iobroker.shelly
Advanced tools
Comparing version 3.2.5 to 3.2.6
@@ -17,2 +17,3 @@ /*global systemDictionary:true */ | ||
"MQTT settings": { "en": "MQTT settings", "de": "MQTT-Einstellungen", "ru": "Настройки MQTT", "pt": "Configurações MQTT", "nl": "MQTT-instellingen", "fr": "Paramètres MQTT", "it": "Impostazioni MQTT", "es": "Configuraciones MQTT", "pl": "Ustawienia MQTT", "zh-cn": "MQTT设置"}, | ||
"COAP Listen IP": { "en": "COAP Listen IP", "de": "COAP-Listen-IP", "ru": "COAP Listen IP", "pt": "COAP Listen IP", "nl": "COAP Listen IP", "fr": "COAP Listen IP", "it": "COAP Ascolta IP", "es": "COAP Listen IP", "pl": "COAP Słuchaj IP", "zh-cn": "COAP监听IP"}, | ||
"Manual": { "en": "Manual", "de": "Manual", "ru": "Вручную", "pt": "Manual", "nl": "Met de hand", "fr": "Manuel", "it": "Manuale", "es": "Manual", "pl": "Manual", "zh-cn": "手册"}, | ||
@@ -19,0 +20,0 @@ "Password": { "en": "Password", "de": "Passwort", "ru": "пароль", "pt": "Senha", "nl": "Wachtwoord", "fr": "Mot de passe", "it": "Parola d'ordine", "es": "Contraseña", "pl": "Hasło", "zh-cn": "密码"}, |
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "3.2.5", | ||
"version": "3.2.6", | ||
"news": { | ||
"3.2.6": { | ||
"en": "Bugfixing", | ||
"de": "Fehlerbehebung", | ||
"ru": "Исправление ошибок", | ||
"pt": "Corrigindo erro", | ||
"nl": "bugfixing", | ||
"fr": "Correction de bugs", | ||
"it": "bugfixing", | ||
"es": "Corrección de errores", | ||
"pl": "Naprawa błędów", | ||
"zh-cn": "Bugfixing" | ||
}, | ||
"3.2.4": { | ||
@@ -234,2 +246,3 @@ "en": "Bugfixing for Shelly 1", | ||
"bind": "0.0.0.0", | ||
"coapbind": "0.0.0.0", | ||
"port": 1882, | ||
@@ -288,2 +301,2 @@ "mqttpassword": "mqttuser", | ||
] | ||
} | ||
} |
@@ -55,3 +55,3 @@ /* jshint -W097 */ | ||
class CoAPClient { | ||
constructor(adapter, objectHelper, eventEmitter, shelly, deviceId, ip, payload) { | ||
constructor(adapter, objectHelper, eventEmitter, shelly, devicename, ip, payload) { | ||
this.active = true; | ||
@@ -62,3 +62,3 @@ this.adapter = adapter; | ||
this.shelly = shelly; | ||
this.deviceId = deviceId; | ||
this.devicename = devicename; | ||
this.ip = ip; | ||
@@ -71,3 +71,2 @@ this.states = {}; | ||
this.id; | ||
this.devicename; | ||
this.devicetype; | ||
@@ -110,3 +109,3 @@ this.deviceid; | ||
getDeviceName() { | ||
return this.deviceId; | ||
return this.devicename; | ||
} | ||
@@ -120,3 +119,6 @@ | ||
if (!this.devicetype) { | ||
this.devicetype = this.deviceId.split('#').slice(0, 1).join(); | ||
let devicename = this.getDeviceName(); | ||
if (typeof devicename === 'string') { | ||
this.devicetype = devicename.split('#').slice(0, 1).join(); | ||
} | ||
} | ||
@@ -143,3 +145,3 @@ return this.devicetype; | ||
if (!this.serialid) { | ||
let devicetype = this.deviceId.split('#'); | ||
let devicetype = this.devicename.split('#'); | ||
if (devicetype) this.serialid = devicetype[1]; | ||
@@ -182,3 +184,3 @@ } | ||
clearTimeout(this.autoupdateid); | ||
this.deviceId = undefined; | ||
this.devicename = undefined; | ||
this.http = {}; | ||
@@ -189,3 +191,2 @@ this.states = {}; | ||
this.id = undefined; | ||
this.devicename = undefined; | ||
this.devicetype = undefined; | ||
@@ -536,10 +537,10 @@ this.deviceid = undefined; | ||
}); | ||
this.shelly.on('update-device-status', this.listenerus = (deviceId, payload) => { | ||
if (deviceId === this.deviceId) { | ||
this.shelly.on('update-device-status', this.listenerus = (devicename, payload) => { | ||
if (devicename === this.devicename) { | ||
this.createIoBrokerState(payload); | ||
} | ||
}); | ||
this.shelly.on('device-connection-status', this.listenerds = (deviceId, connected) => { | ||
this.adapter.log.debug('Connection update received for ' + deviceId + ': ' + connected); | ||
if (deviceId === this.deviceId) { | ||
this.shelly.on('device-connection-status', this.listenerds = (devicename, connected) => { | ||
this.adapter.log.debug('Connection update received for ' + devicename + ': ' + connected); | ||
if (devicename === this.devicename) { | ||
// adapter.setState(deviceId + '.online', connected, true); | ||
@@ -590,3 +591,4 @@ } | ||
user: this.adapter.config.httpusername, | ||
password: this.adapter.config.httppassword | ||
password: this.adapter.config.httppassword, | ||
multicastInterface: null | ||
}; | ||
@@ -598,2 +600,5 @@ } else { | ||
} | ||
if (this.adapter.config.coapbind && this.adapter.config.coapbind != '0.0.0.0') { | ||
options.multicastInterface = this.adapter.config.coapbind; | ||
} | ||
let shelly = new Shelly(options); | ||
@@ -639,2 +644,2 @@ shelly.on('error', (err) => { | ||
CoAPServer: CoAPServer | ||
}; | ||
}; |
@@ -35,3 +35,5 @@ /** | ||
return [h, s, l]; | ||
// return [h, s, l]; | ||
// return [h * 360, s * 100, l * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(l * 100)]; | ||
} | ||
@@ -51,2 +53,6 @@ | ||
function hslToRgb(h, s, l) { | ||
h = h / 360; | ||
s = s / 100; | ||
l = l / 100; | ||
let r, g, b; | ||
@@ -66,3 +72,4 @@ | ||
return [r * 255, g * 255, b * 255]; | ||
// return [r * 255, g * 255, b * 255]; | ||
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)]; | ||
} | ||
@@ -102,3 +109,5 @@ | ||
return [h, s, v]; | ||
// return [h, s, v]; | ||
// return [h * 360, s * 100, v * 100]; | ||
return [Math.round(h * 360), Math.round(s * 100), Math.round(v * 100)]; | ||
} | ||
@@ -118,4 +127,7 @@ | ||
function hsvToRgb(h, s, v) { | ||
h = h / 360; | ||
s = s / 100; | ||
v = v / 100; | ||
let r, g, b; | ||
let i = Math.floor(h * 6); | ||
@@ -136,7 +148,11 @@ let f = h * 6 - i; | ||
return [r * 255, g * 255, 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 | ||
*/ | ||
@@ -143,0 +159,0 @@ function hue2rgb(p, q, t) { |
@@ -9,2 +9,4 @@ | ||
const colorconv = require('../colorconv'); | ||
function intToHex(number) { | ||
@@ -74,2 +76,37 @@ if (!number) number = 0; | ||
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] | ||
} | ||
} | ||
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; | ||
} | ||
/** | ||
@@ -284,3 +321,3 @@ * Shelly Bulb | ||
'type': 'number', | ||
'role': 'level.brightness', | ||
'role': 'level.color.brightness', | ||
'read': true, | ||
@@ -384,2 +421,48 @@ 'write': true, | ||
} | ||
}, | ||
'lights.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/shellybulb-<deviceid>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/shellybulb-<deviceid>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await 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 getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/shellybulb-<deviceid>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/shellybulb-<deviceid>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
} | ||
@@ -386,0 +469,0 @@ }; |
@@ -40,2 +40,13 @@ | ||
function getColorsFromRGBW(value) { | ||
value = value || '#00000000'; | ||
let obj = { | ||
red: hextoInt(value.substr(1, 2)), | ||
green: hextoInt(value.substr(3, 2)), | ||
blue: hextoInt(value.substr(5, 2)), | ||
white: hextoInt(value.substr(7, 2)) | ||
}; | ||
return obj; | ||
} | ||
async function getLightsObject(self) { | ||
@@ -71,2 +82,37 @@ let id = self.getDeviceName(); | ||
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] | ||
} | ||
} | ||
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; | ||
} | ||
/** | ||
@@ -73,0 +119,0 @@ * Shelly Bulb Duo |
@@ -11,3 +11,3 @@ /* jshint -W097 */ | ||
coap: { | ||
coap_publish_funct: (value) => { return value.G[0][2] === 1 ? true : false; }, | ||
coap_publish_funct: (value) => { return value.G[1][2] === 1 ? true : false; }, | ||
http_cmd: '/relay/0', | ||
@@ -14,0 +14,0 @@ http_cmd_funct: (value) => { return value === true ? { turn: 'on' } : { turn: 'off' }; }, |
@@ -8,2 +8,4 @@ /* jshint -W097 */ | ||
const colorconv = require('../colorconv'); | ||
function intToHex(number) { | ||
@@ -76,2 +78,37 @@ if (!number) number = 0; | ||
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] | ||
} | ||
} | ||
async function getColorsFromHue(self) { | ||
let id = self.getDeviceName(); | ||
let stateId; | ||
let state; | ||
stateId = id + '.color.hue'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valhue = state ? state.val : 0; | ||
stateId = id + '.color.saturation'; | ||
state = await self.adapter.getStateAsync(stateId); | ||
let valsaturation = state ? state.val : 0; | ||
// stateId = id + '.lights.value'; | ||
stateId = id + '.color.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; | ||
} | ||
/** | ||
@@ -303,2 +340,48 @@ * Shelly RGBW2 | ||
}, | ||
'color.hue': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).hue || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/shellyrgbw2-<deviceid>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).hue || undefined; }, | ||
mqtt_cmd: 'shellies/shellyrgbw2-<deviceid>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Hue', | ||
'type': 'number', | ||
'role': 'level.color.hue', | ||
'min': 0, | ||
'max': 360, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'color.saturation': { | ||
coap: { | ||
http_publish: '/color/0', | ||
http_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).saturation || undefined; }, | ||
http_cmd: '/color/0', | ||
http_cmd_funct: async (value, self) => { return await getColorsFromHue(self); } | ||
}, | ||
mqtt: { | ||
mqtt_publish: 'shellies/shellyrgbw2-<deviceid>/color/0/status', | ||
mqtt_publish_funct: async (value, self) => { return (await getHsvFromRgb(self)).saturation || undefined; }, | ||
mqtt_cmd: 'shellies/shellyrgbw2-<deviceid>/color/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return JSON.stringify(await getColorsFromHue(self)); } | ||
}, | ||
common: { | ||
'name': 'Saturation', | ||
'type': 'number', | ||
'role': 'level.color.saturation', | ||
'min': 0, | ||
'max': 100, | ||
'read': false, | ||
'write': true | ||
} | ||
}, | ||
'white0.Switch': { | ||
@@ -305,0 +388,0 @@ coap: { |
@@ -8,2 +8,3 @@ /* jshint -W097 */ | ||
const colorconv = require('../colorconv'); | ||
@@ -10,0 +11,0 @@ async function getLightsObject(self) { |
@@ -145,3 +145,3 @@ /* jshint -W097 */ | ||
getDeviceName() { | ||
if (!this.devicname) { | ||
if (!this.devicename) { | ||
this.devicename = this.getDeviceType() + '#' + this.getSerialId() + '#1'; | ||
@@ -392,2 +392,3 @@ } | ||
let tmpid = obj[i]; | ||
if (!tmpid) continue; | ||
let stateid = tmpid._id.replace(id + '.', ''); | ||
@@ -394,0 +395,0 @@ if (tmpid.type === 'state' && tmpid._id.startsWith(id)) { |
{ | ||
"name": "iobroker.shelly", | ||
"version": "3.2.5", | ||
"version": "3.2.6", | ||
"description": "Shelly", | ||
@@ -39,2 +39,3 @@ "author": { | ||
"shelly-iot": "^1.0.6", | ||
"xml2js": "0.4.19", | ||
"xmlbuilder": "^15.1.1" | ||
@@ -41,0 +42,0 @@ }, |
@@ -55,5 +55,7 @@ ![Logo](admin/shelly.png) | ||
### 3.2.5 (13.04.2020) | ||
* (Apollon77) - Update Dependencies incl shelly-lib to prevent exceptions | ||
* (Apollon77) - Add Sentry for error/crash reporting (active with js-controller 3.0) | ||
### 3.2.6 (27.04.2020) | ||
* (Apollon77) - Update Dependencies incl shelly-lib to prevent exceptions | ||
* (Apollon77) - Add Sentry for error/crash reporting (active with js-controller 3.0) | ||
* (Stübi - Add for hue two new datapoints for Shelly Bulb and RGBW2 | ||
* (@SamLowrie) - Add option to set a specific multicast interface for CoAP server | ||
@@ -60,0 +62,0 @@ ### 3.2.4 (11.04.2020) |
@@ -17,2 +17,3 @@ /* jshint -W097 */ | ||
let adapter; | ||
@@ -19,0 +20,0 @@ |
Sorry, the diff of this file is not supported yet
4002761
8281
214
9
+ Addedxml2js@0.4.19
+ Addedxml2js@0.4.19(transitive)
+ Addedxmlbuilder@9.0.7(transitive)