iobroker.shelly
Advanced tools
Comparing version 5.1.1 to 5.1.2
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"news": { | ||
"5.1.2": { | ||
"en": "Fixed Shelly UNI ADC voltage\nFixed dimmer brightness values handling\nLogging improvements for offline devices", | ||
"de": "Feste Shelly UNI ADC-Spannung\nDie Handhabung der Dimmer-Helligkeitswerte wurde korrigiert\nProtokollierungsverbesserungen für Offline-Geräte", | ||
"ru": "Фиксированное напряжение Shelly UNI ADC\nИсправлена обработка значений яркости диммера\nУлучшения ведения журналов для автономных устройств", | ||
"pt": "Tensão Shelly UNI ADC fixa\nManipulação de valores de brilho de dimmer fixo\nMelhorias de registro para dispositivos offline", | ||
"nl": "Vaste Shelly UNI ADC-spanning\nVaste dimmer helderheidswaarden verwerking\nLogboekverbeteringen voor offline apparaten", | ||
"fr": "Tension Shelly UNI ADC fixe\nGestion des valeurs de luminosité du gradateur fixe\nAméliorations de la journalisation pour les appareils hors ligne", | ||
"it": "Tensione Shelly UNI ADC fissa\nRisolto il problema con la gestione dei valori di luminosità più deboli\nMiglioramenti alla registrazione per i dispositivi offline", | ||
"es": "Voltaje fijo Shelly UNI ADC\nManejo de valores de brillo de dimmer fijo\nMejoras en el registro para dispositivos sin conexión", | ||
"pl": "Naprawiono napięcie Shelly UNI ADC\nNaprawiono obsługę wartości jasności ściemniacza\nUlepszenia logowania dla urządzeń offline", | ||
"zh-cn": "固定 Shelly UNI ADC 电压\n固定调光器亮度值处理\n离线设备的日志记录改进" | ||
}, | ||
"5.1.1": { | ||
@@ -77,14 +89,2 @@ "en": "Fixed firmware auto update\nUpdated timeouts\nAdded command source for shelly 2.5\nAdded color for device objects as online indicator", | ||
"zh-cn": "几个修复和调整\n修复温度最高警告\n卸载时销毁 Coap 和 MQTT 服务器" | ||
}, | ||
"4.0.9-beta-1": { | ||
"en": "Bugfixing", | ||
"de": "Bugfixing", | ||
"ru": "Исправление ошибок", | ||
"pt": "Corrigindo erro", | ||
"nl": "Bugfixing", | ||
"fr": "Correction de bugs", | ||
"it": "bugfixing", | ||
"es": "Corrección de errores", | ||
"pl": "Naprawa błędów", | ||
"zh-cn": "错误修正" | ||
} | ||
@@ -91,0 +91,0 @@ }, |
@@ -67,3 +67,3 @@ | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
}, | ||
@@ -74,3 +74,3 @@ mqtt: { | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: value }) : undefined; } | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
}, | ||
@@ -77,0 +77,0 @@ common: { |
@@ -64,3 +64,3 @@ | ||
http_cmd: '/light/0', | ||
http_cmd_funct: (value) => { return { brightness: value }; } | ||
http_cmd_funct: (value) => { return { brightness: Math.round(value) }; } | ||
}, | ||
@@ -71,3 +71,3 @@ mqtt: { | ||
mqtt_cmd: 'shellies/<mqttprefix>/light/0/set', | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: value }) : undefined; } | ||
mqtt_cmd_funct: async (value, self) => { return value >= 0 ? JSON.stringify({ brightness: Math.round(value) }) : undefined; } | ||
}, | ||
@@ -74,0 +74,0 @@ common: { |
@@ -545,4 +545,4 @@ /* jshint -W097 */ | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/adcs/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).voltage : undefined; } | ||
mqtt_publish: 'shellies/<mqttprefix>/adc/0', | ||
mqtt_publish_funct: (value) => { return value ? parseFloat(value) : undefined; } | ||
}, | ||
@@ -566,4 +566,4 @@ common: { | ||
mqtt: { | ||
mqtt_publish: 'shellies/<mqttprefix>/adcs/0', | ||
mqtt_publish_funct: (value) => { return value ? JSON.parse(value).range : undefined; } | ||
http_publish: '/settings', | ||
http_publish_funct: (value) => { return value ? JSON.parse(value).adcs[0].range : undefined; }, | ||
}, | ||
@@ -570,0 +570,0 @@ common: { |
@@ -204,3 +204,3 @@ /* jshint -W097 */ | ||
if (error.name && error.name.startsWith('TypeError')) { | ||
this.adapter.log.debug('Could not find property for state ' + stateid + ' for ' + this.getName() + ' (' + error + ')'); | ||
this.adapter.log.debug(`Could not find property for state ${stateid} for ${this.getName()}: ${error}`); | ||
} else { | ||
@@ -218,5 +218,6 @@ if (polltime > 0 && polltime < 60) polltime = 60; | ||
} | ||
this.objectHelper.processObjectQueue(() => { }); | ||
} catch (error) { | ||
this.adapter.log.error(`HTTP request (httpIoBrokerState) error: ${JSON.stringify(error)}`); | ||
this.adapter.log.debug(`HTTP request (httpIoBrokerState) error: ${JSON.stringify(error)}`); | ||
} | ||
@@ -293,12 +294,12 @@ } | ||
if (state[this.type] && state[this.type].http_cmd && !hasTypeCmd) { | ||
this.adapter.log.silly(`[controlFunction] Found ${this.type}.http_cmd of state ${stateid} for ${this.getName()}`); | ||
this.adapter.log.silly(`[http controlFunction] Found ${this.type}.http_cmd of state ${stateid} for ${this.getName()}`); | ||
controlFunction = async (value) => { | ||
this.adapter.log.silly(`[controlFunction] Entered ${this.type}.http_cmd of state ${stateid} for ${this.getName()} with value: ${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 { | ||
this.adapter.log.silly(`[controlFunction] Executing state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()} with value: ${value}`); | ||
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(`[controlFunction] Error in function state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
@@ -316,9 +317,9 @@ } | ||
if (body === 'Bad default state and button type combination!') { | ||
this.adapter.log.error(`[controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${body}`); | ||
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(`[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.`); | ||
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(`[controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[http controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
@@ -333,2 +334,3 @@ } | ||
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) => { | ||
@@ -339,4 +341,5 @@ let cmd = state[this.type].mqtt_cmd; | ||
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(`[controlFunction] Error in function state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[mqtt controlFunction] Error in function state.${this.type}.mqtt_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
@@ -403,5 +406,5 @@ } | ||
delete obj[tmpid._id]; | ||
this.adapter.log.info('Delete old state: ' + tmpid._id); | ||
this.adapter.log.info(`Delete old state: ${tmpid._id}`); | ||
} catch (error) { | ||
this.adapter.log.error('Cound not delete old state: ' + tmpid._id); | ||
this.adapter.log.error(`Cound not delete old state: ${tmpid._id}`); | ||
} | ||
@@ -430,7 +433,7 @@ } | ||
try { | ||
this.adapter.log.info('Delete old channel: ' + tmpidi._id); | ||
this.adapter.log.info(`Delete old channel: ${tmpidi._id}`); | ||
await this.adapter.delObjectAsync(tmpidi._id); | ||
delete obj[tmpidi._id]; | ||
} catch (error) { | ||
this.adapter.log.error('Could not delete old channel: ' + tmpidi._id); | ||
this.adapter.log.error(`Could not delete old channel: ${tmpidi._id}`); | ||
} | ||
@@ -437,0 +440,0 @@ } |
@@ -183,3 +183,3 @@ /* jshint -W097 */ | ||
async createIoBrokerState(payload) { | ||
this.adapter.log.debug('CoAP Message for ' + this.getDeviceName() + ' : ' + JSON.stringify(payload)); | ||
this.adapter.log.debug(`[CoAP] Message for ${this.getName()}: ${JSON.stringify(payload)}`); | ||
let dps = this.getDevices(); | ||
@@ -191,3 +191,5 @@ for (let i in dps) { | ||
let value = payload; | ||
// this.adapter.log.debug('Create State : ' + stateid + ', Payload: ' + JSON.stringify(payload) + ' for ' + this.getDeviceName()); | ||
this.adapter.log.silly(`[CoAP] Message with value for ${this.getName()}: state: ${stateid}, payload: ${JSON.stringify(payload)}`); | ||
try { | ||
@@ -205,3 +207,3 @@ if (dp.coap && dp.coap.coap_publish) { | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
this.adapter.log.debug('State change : ' + stateid + ', Value: ' + JSON.stringify(value) + ' for ' + this.getName()); | ||
this.adapter.log.debug(`[CoAP] State change ${this.getName()}: state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
@@ -216,3 +218,3 @@ this.objectHelper.setOrUpdateObject(stateid, { | ||
} catch (error) { | ||
this.adapter.log.error('Error ' + error + ' in function dp.coap.coap_publish_funct for state ' + stateid + ' for ' + this.getName()); | ||
this.adapter.log.error(`[CoAP] Error ${error} in function dp.mqtt.coap_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
@@ -227,9 +229,9 @@ } | ||
if (polltime > 0) { | ||
this.adapter.log.info('Shelly device ' + this.getName() + ' with CoAP connected! Polltime set to ' + polltime + ' sec.'); | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info('Shelly device ' + this.getName() + ' with CoAP connected! No polling'); | ||
this.adapter.log.info(`[CoAP] Device ${this.getName()} connected! No polling`); | ||
} | ||
this.adapter.log.debug('1. Shelly device Info: ' + this.getDeviceName() + ' : ' + JSON.stringify(description)); | ||
this.adapter.log.debug('2. Shelly device Info: ' + 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)}`); | ||
@@ -249,5 +251,5 @@ this.deleteOldStates(); | ||
} else { | ||
this.adapter.log.error('Shelly Device unknown, configuration for Shelly device ' + this.getName() + ' for CoAP does not exist!'); | ||
this.adapter.log.error('1. Send developer following Info: ' + this.getDeviceName() + ' : ' + JSON.stringify(description)); | ||
this.adapter.log.error('2. Send developer following Info: ' + this.getDeviceName() + ' : ' + JSON.stringify(payload)); | ||
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)}`); | ||
} | ||
@@ -258,3 +260,3 @@ } | ||
this.shelly.on('error', (err) => { | ||
this.adapter.log.debug('Error handling Shelly data: ' + err); | ||
this.adapter.log.debug(`[CoAP] Error handling Shelly data: ${err}`); | ||
}); | ||
@@ -269,3 +271,3 @@ | ||
this.shelly.on('device-connection-status', this.listenerds = (devicename, connected) => { | ||
this.adapter.log.debug('Connection update received for ' + devicename + ': ' + connected); | ||
this.adapter.log.debug(`[CoAP] Connection update received for ${devicename}: ${connected}`); | ||
if (this.getOldDeviceInfo(devicename) === this.getDeviceName()) { | ||
@@ -331,7 +333,7 @@ this.adapter.emit('deviceStatusUpdate', this.getDeviceName(), true); // Device online | ||
shelly.on('error', (err) => { | ||
this.adapter.log.debug('Error handling Shelly data: ' + err); | ||
this.adapter.log.debug(`[CoAP] Error handling Shelly data: ${err}`); | ||
}); | ||
shelly.on('update-device-status', (devicename, status) => { | ||
this.adapter.log.debug(`Status update received for ${devicename}: ${JSON.stringify(status)}`); | ||
this.adapter.log.debug(`[CoAP] Status update received for ${devicename}: ${JSON.stringify(status)}`); | ||
@@ -354,3 +356,3 @@ if (devicename && typeof devicename === 'string') { | ||
} else { | ||
this.adapter.log.debug('Device Id is missing ' + devicename); | ||
this.adapter.log.debug(`[CoAP] Device Id is missing: ${devicename}`); | ||
} | ||
@@ -367,3 +369,3 @@ }); | ||
shelly.listen(() => { | ||
this.adapter.log.info('Listening for Shelly packets in the network'); | ||
this.adapter.log.info('[CoAP] Listening for Shelly packets in the network'); | ||
}); | ||
@@ -370,0 +372,0 @@ } |
@@ -210,3 +210,3 @@ /* jshint -W097 */ | ||
this.messageId++; | ||
this.adapter.log.debug('[MQTT] Send state to ' + this.getName() + ' : ' + topic + ' = ' + state + ' (' + 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); | ||
@@ -304,12 +304,14 @@ // if qos > 0 recognize message | ||
this.adapter.log.silly(`[MQTT] Message 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) | ||
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); | ||
// this.adapter.log.debug('[MQTT] createIoBrokerState(), State : ' + stateid + ', Value: ' + JSON.stringify(value)); | ||
if (value !== undefined && (!Object.prototype.hasOwnProperty.call(this.states, stateid) || this.states[stateid] !== value || this.adapter.config.updateUnchangedObjects)) { | ||
@@ -396,3 +398,3 @@ this.adapter.log.debug(`[MQTT] State change ${this.getName()}: ${topic} -> state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.packet = packet; | ||
this.adapter.log.debug('client connected: ' + JSON.stringify(packet)); | ||
this.adapter.log.debug(`[MQTT] Client connected: ${JSON.stringify(packet)}`); | ||
if (this.deviceExists()) { | ||
@@ -436,3 +438,3 @@ if (packet.username === this.adapter.config.mqttusername && packet.password !== undefined && packet.password.toString() === this.adapter.config.mqttpassword) { | ||
} else { | ||
this.adapter.log.error(`[MQTT] Shelly Device unknown, configuration for Shelly device ${this.getName()} for MQTT does not exist!`); | ||
this.adapter.log.error(`[MQTT] Shelly device unknown, configuration for Shelly device ${this.getName()} does not exist!`); | ||
this.client.connack({ returnCode: 4 }); | ||
@@ -439,0 +441,0 @@ } |
@@ -83,20 +83,23 @@ /* jshint -W097 */ | ||
function uptimeString(uptime) { | ||
if (uptime) { | ||
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); | ||
if (hours < 10) { hours = '0' + hours; } | ||
if (mins < 10) { mins = '0' + mins; } | ||
if (secs < 10) { secs = '0' + secs; } | ||
if (days > 0) { | ||
uptime = days + 'D' + hours + ':' + mins + ':' + secs; | ||
} else { | ||
uptime = hours + ':' + mins + ':' + secs; | ||
} | ||
if (uptime < 0) { | ||
uptime = 0; | ||
} | ||
return uptime; | ||
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); | ||
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; | ||
} | ||
} | ||
@@ -103,0 +106,0 @@ |
{ | ||
"name": "iobroker.shelly", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"description": "Shelly", | ||
@@ -85,3 +85,4 @@ "author": { | ||
"scripts": { | ||
"test": "npm run test:package && npm run test:unit", | ||
"test": "npm run test:js && npm run test:package", | ||
"test:js": "mocha --config test/mocharc.custom.json \"{!(node_modules|test)/**/*.test.js,*.test.js,test/**/test!(PackageFiles|Startup).js}\"", | ||
"test:package": "mocha test/package --exit", | ||
@@ -88,0 +89,0 @@ "test:unit": "mocha test/unit --exit", |
@@ -85,2 +85,7 @@ ![Logo](admin/shelly.png) | ||
--> | ||
### 5.1.2 (2022-01-29) | ||
* (klein0r) Fixed Shelly UNI ADC voltage | ||
* (klein0r) Fixed dimmer brightness values handling | ||
* (klein0r) Logging improvements for offline devices | ||
### 5.1.1 (2022-01-26) | ||
@@ -87,0 +92,0 @@ * (klein0r) Fixed firmware auto update |
706073
16066
419