iobroker.shelly
Advanced tools
Comparing version 5.1.0 to 5.1.1
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"news": { | ||
"5.1.1": { | ||
"en": "Fixed firmware auto update\nUpdated timeouts\nAdded command source for shelly 2.5\nAdded color for device objects as online indicator", | ||
"de": "Automatisches Firmware-Update behoben\nAktualisierte Zeitüberschreitungen\nBefehlsquelle für Shelly 2.5 hinzugefügt\nFarbe für Geräteobjekte als Online-Anzeige hinzugefügt", | ||
"ru": "Исправлено автоматическое обновление прошивки\nОбновленные тайм-ауты\nДобавлен источник команд для shelly 2.5.\nДобавлен цвет для объектов устройства в качестве онлайн-индикатора.", | ||
"pt": "Atualização automática de firmware corrigida\nTempos limite atualizados\nFonte de comando adicionada para shelly 2.5\nCor adicionada para objetos de dispositivo como indicador online", | ||
"nl": "Vaste automatische firmware-update\nBijgewerkte time-outs\nCommandobron toegevoegd voor shelly 2.5\nKleur toegevoegd voor apparaatobjecten als online indicator", | ||
"fr": "Correction de la mise à jour automatique du firmware\nDélais d'attente mis à jour\nAjout de la source de commande pour shelly 2.5\nAjout de couleur pour les objets de l'appareil en tant qu'indicateur en ligne", | ||
"it": "Risolto il problema con l'aggiornamento automatico del firmware\nTimeout aggiornati\nAggiunta la sorgente dei comandi per shelly 2.5\nAggiunto colore per gli oggetti del dispositivo come indicatore online", | ||
"es": "Actualización automática de firmware fijo\nTiempos de espera actualizados\nFuente de comando agregada para Shelly 2.5\nSe agregó color para los objetos del dispositivo como indicador en línea.", | ||
"pl": "Naprawiono automatyczną aktualizację oprogramowania\nZaktualizowano limity czasu\nDodano źródło poleceń dla Shelly 2.5\nDodano kolor dla obiektów urządzenia jako wskaźnika online", | ||
"zh-cn": "固定固件自动更新\n更新超时\n为 shelly 2.5 添加了命令源\n为设备对象添加了颜色作为在线指示器" | ||
}, | ||
"5.1.0": { | ||
@@ -77,14 +89,2 @@ "en": "Added input states for generation 2 devices\nFixed online state management and adapter indicator\nFixed long push data type for some devices\nFixed fahrenheit temperature states\nCode refactoring\nUpdated documentation", | ||
"zh-cn": "错误修正" | ||
}, | ||
"4.0.8": { | ||
"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": "错误修正" | ||
} | ||
@@ -199,3 +199,3 @@ }, | ||
"pwd": false, | ||
"polltime": 5, | ||
"polltime": 15, | ||
"timeout": 0.25, | ||
@@ -202,0 +202,0 @@ "protocol": "coap", |
@@ -49,3 +49,2 @@ /* jshint -W097 */ | ||
http_publish_funct: async (value, self) => { | ||
if (self.adapter.config.autoupdate) await self.firmwareUpdate(value && JSON.parse(value).update.has_update); | ||
return value ? JSON.parse(value).update.has_update : undefined; | ||
@@ -57,3 +56,2 @@ } | ||
mqtt_publish_funct: async (value, self) => { | ||
if (self.adapter.config.autoupdate) await self.firmwareUpdate(value && JSON.parse(value).new_fw); | ||
return value ? JSON.parse(value).new_fw : false; | ||
@@ -60,0 +58,0 @@ } |
@@ -336,2 +336,19 @@ /* jshint -W097 */ | ||
}, | ||
'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 | ||
} | ||
}, | ||
'Relay0.overpowerValue': { | ||
@@ -637,2 +654,19 @@ coap: { | ||
}, | ||
'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.overpowerValue': { | ||
@@ -868,2 +902,19 @@ coap: { | ||
}, | ||
'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': { | ||
@@ -870,0 +921,0 @@ coap: { |
@@ -45,3 +45,4 @@ /* jshint -W097 */ | ||
this.timerid = null; | ||
this.httpIoBrokerStateTimeout = null; | ||
this.firmwareUpdatePollingTimeout = null; | ||
@@ -64,3 +65,3 @@ this.active = true; | ||
this.httptimeout = 5 * 1000; | ||
this.httptimeout = 8 * 1000; | ||
@@ -76,3 +77,3 @@ // Handle firmware updates | ||
if (this.getDeviceGen() === 1) { | ||
this.adapter.log.debug(`HTTP request (requestAsync) to gen 1 device with basic auth: "${url}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP request to gen 1 device with basic auth: "${url}"`); | ||
const client = new DigestFetch(this.adapter.config.httpusername, this.adapter.config.httppassword, { basic: true }); | ||
@@ -82,3 +83,3 @@ client.fetch(url, {timeout: this.httptimeout}) | ||
.then(text => { | ||
this.adapter.log.debug(`HTTP response (requestAsync) of gen 1 device with basic auth: "${url}" -> "${text}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP response of gen 1 device with basic auth: "${url}" -> "${text}"`); | ||
resolve(text); | ||
@@ -88,3 +89,3 @@ }) | ||
} else if (this.getDeviceGen() === 2) { | ||
this.adapter.log.debug(`HTTP request (requestAsync) to gen 2 device with digest auth: "${url}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP request to gen 2 device with digest auth: "${url}"`); | ||
const client = new DigestFetch('admin', this.adapter.config.httppassword, { algorithm: 'MD5' }); // Username is always admin | ||
@@ -94,3 +95,3 @@ client.fetch(url, {timeout: this.httptimeout}) | ||
.then(text => { | ||
this.adapter.log.debug(`HTTP response (requestAsync) of gen 2 device with digest auth: "${url}" -> "${text}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP response of gen 2 device with digest auth: "${url}" -> "${text}"`); | ||
resolve(text); | ||
@@ -101,7 +102,7 @@ }) | ||
} else { | ||
this.adapter.log.debug(`HTTP request (requestAsync) to gen ${this.getDeviceGen()} device without auth: "${url}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP request to gen ${this.getDeviceGen()} device without auth: "${url}"`); | ||
fetch(url, {timeout: this.httptimeout}) | ||
.then(res => res.text()) | ||
.then(text => { | ||
this.adapter.log.debug(`HTTP response (requestAsync) of gen ${this.getDeviceGen()} device without auth: "${url}" -> "${text}"`); | ||
this.adapter.log.silly(`[requestAsync] HTTP response of gen ${this.getDeviceGen()} device without auth: "${url}" -> "${text}"`); | ||
resolve(text); | ||
@@ -115,3 +116,3 @@ }) | ||
/** | ||
* get the Polltime for a device | ||
* Returns the polltime for a device (in seconds) | ||
*/ | ||
@@ -130,3 +131,3 @@ getPolltime() { | ||
return this.adapter.config.polltime; | ||
return this.adapter.config.polltime; // Default = instance config | ||
} | ||
@@ -179,3 +180,3 @@ | ||
if (!this.adapter.isOnline(this.getDeviceName())) { | ||
this.timerid = setTimeout(async () => await this.httpIoBrokerState(), 1000); | ||
this.httpIoBrokerStateTimeout = setTimeout(async () => await this.httpIoBrokerState(), this.adapter.config.polltime * 1000); | ||
return; | ||
@@ -233,3 +234,3 @@ } | ||
if (this.http && Object.keys(this.http).length > 0 && polltime > 0) { | ||
this.timerid = setTimeout(async () => await this.httpIoBrokerState(), polltime * 1000); | ||
this.httpIoBrokerStateTimeout = setTimeout(async () => await this.httpIoBrokerState(), polltime * 1000); | ||
} | ||
@@ -267,3 +268,3 @@ } | ||
} | ||
if (this.type === 'mqtt') { | ||
@@ -302,8 +303,12 @@ hasTypeCmd = !!state.mqtt.mqtt_cmd; | ||
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()}`); | ||
controlFunction = async (value) => { | ||
this.adapter.log.silly(`[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); | ||
} catch (error) { | ||
this.adapter.log.error(`Error in function state.${this.type}.http_cmd_funct for state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[controlFunction] Error in function state.${this.type}.http_cmd_funct of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
@@ -321,11 +326,12 @@ } | ||
if (body === 'Bad default state and button type combination!') { | ||
this.adapter.log.error(`Error in function state.${this.type}.http_cmd for state ${stateid} for ${this.getName()}: ${body}`); | ||
this.adapter.log.error(`[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(`Error in function state.${this.type}.http_cmd for state ${stateid} for ${this.getName()}: Wrong http username or http password! Please enter user credentials for restricted login.`); | ||
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.`); | ||
} else { | ||
this.adapter.log.error(`Error in function state.${this.type}.http_cmd for state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[controlFunction] Error in function state.${this.type}.http_cmd of state ${stateid} for ${this.getName()}: ${error}`); | ||
} | ||
} | ||
delete this.states[stateid]; | ||
@@ -343,6 +349,7 @@ }; | ||
} catch (error) { | ||
this.adapter.log.error(`Error in function state.${this.type}.mqtt_cmd_funct for state ${stateid} for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[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? | ||
delete this.states[stateid]; | ||
@@ -445,3 +452,3 @@ }; | ||
await this.firmwareUpdate(true); | ||
this.autoupdateid = setTimeout(async () => await this.firmwareUpdatePolling(), 60 * 1000); | ||
this.firmwareUpdatePollingTimeout = setTimeout(async () => await this.firmwareUpdatePolling(), 15 * 60 * 1000); // Every 15 Minutes | ||
} | ||
@@ -453,10 +460,16 @@ } | ||
this.adapter.log.debug('Calling function firmwareUpdate'); | ||
if (!this.adapter.isOnline(this.getDeviceName())) { | ||
this.adapter.log.debug(`[firmwareUpdate] Device is offline ${this.getName()}`); | ||
return; | ||
} | ||
try { | ||
let body = await this.requestAsync('http://' + this.getIP() + '/ota?update=true'); | ||
this.adapter.log.debug(`Executed firmware update for ${this.getName()}: ${body}`); | ||
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 | ||
} | ||
} catch (error) { | ||
this.adapter.log.error(`Error in function firmwareUpdate and request for ${this.getName()}: ${error}`); | ||
this.adapter.log.error(`[firmwareUpdate] Error in update request for ${this.getName()}: ${error}`); | ||
} | ||
@@ -469,3 +482,4 @@ } | ||
clearTimeout(this.timerid); | ||
clearTimeout(this.httpIoBrokerStateTimeout); | ||
clearTimeout(this.firmwareUpdatePollingTimeout); | ||
@@ -472,0 +486,0 @@ this.active = false; |
@@ -112,3 +112,7 @@ /* jshint -W097 */ | ||
if (!this.devicename) { | ||
this.devicename = this.getDeviceType() + '#' + this.getSerialId() + '#1'; | ||
const deviceType = this.getDeviceType(); | ||
const serialId = this.getSerialId(); | ||
if (deviceType && serialId) { | ||
this.devicename = deviceType + '#' + serialId + '#1'; | ||
} | ||
} | ||
@@ -207,3 +211,3 @@ return this.devicename; | ||
this.messageId++; | ||
this.adapter.log.debug('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); | ||
@@ -217,3 +221,2 @@ // if qos > 0 recognize message | ||
resendState2Client(cmd, messageId, message) { | ||
@@ -294,3 +297,4 @@ let retaintime = 5 * 1000; | ||
async createIoBrokerState(topic, payload) { | ||
this.adapter.log.debug(`MQTT Message for ${this.getName()}: ${topic} / ${JSON.stringify(payload)} (${payload.toString()})`); | ||
this.adapter.log.debug(`[MQTT] Message for ${this.getName()}: ${topic} / ${JSON.stringify(payload)} (${payload.toString()})`); | ||
let dps = this.getDevices(topic); | ||
@@ -302,3 +306,5 @@ for (let i in dps) { | ||
let value = payload.toString(); | ||
// this.adapter.log.debug(`MQTT Message for ${this.getName()}: ${topic} -> state: ${stateid}, value: ${value}`); | ||
this.adapter.log.silly(`[MQTT] Message for ${this.getName()}: ${topic} -> state: ${stateid}, value: ${value}`); | ||
try { | ||
@@ -311,6 +317,5 @@ if (dp.mqtt && dp.mqtt.mqtt_publish === topic) { | ||
if (dp.common.type === 'number' && value !== undefined) value = Number(value); | ||
// this.adapter.log.debug('createIoBrokerState(), State : ' + stateid + ', Value: ' + JSON.stringify(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)) { | ||
this.adapter.log.debug('State change : ' + stateid + ', Value: ' + JSON.stringify(value) + ' for ' + this.getName()); | ||
this.adapter.log.debug('MQTT Message for ' + this.getId() + ' : ' + topic + ' = ' + value); | ||
this.adapter.log.debug(`[MQTT] State change ${this.getName()}: ${topic} -> state: ${stateid}, value: ${JSON.stringify(value)}`); | ||
this.states[stateid] = value; | ||
@@ -324,3 +329,3 @@ this.objectHelper.setOrUpdateObject(stateid, { | ||
} catch (error) { | ||
this.adapter.log.error('Error ' + error + ' in function dp.mqtt.mqtt_publish_funct for state ' + stateid + ' for ' + this.getName()); | ||
this.adapter.log.error(`[MQTT] Error ${error} in function dp.mqtt.mqtt_publish_funct of state ${stateid} for ${this.getName()}`); | ||
} | ||
@@ -359,5 +364,5 @@ } | ||
if (body && body === '401 Unauthorized') { | ||
this.adapter.log.error('Wrong http username or http password! Please enter the user credential from restricted login for ' + this.getName()); | ||
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('Error in function setMqttPrefixHttp() for request' + JSON.stringify(params) + ' for ' + this.getName() + ' (' + error + ')'); | ||
this.adapter.log.error(`[MQTT] Error in function setMqttPrefixHttp() for request' + JSON.stringify(params) + ' for ${this.getName()}: ${error}`); | ||
} | ||
@@ -380,3 +385,3 @@ } | ||
this.mqttprefix = arr[1]; | ||
this.adapter.log.debug('setMqttPrefixByWill (Gen 1) : ' + this.mqttprefix); | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 1): ${this.mqttprefix}`); | ||
return this.mqttprefix; | ||
@@ -386,3 +391,3 @@ } | ||
this.mqttprefix = arr.slice(0, -1).join('/'); | ||
this.adapter.log.debug('setMqttPrefixByWill (Gen 2) : ' + this.mqttprefix); | ||
this.adapter.log.debug(`[MQTT] setMqttPrefixByWill (Gen 2): ${this.mqttprefix}`); | ||
return this.mqttprefix; | ||
@@ -406,5 +411,5 @@ } | ||
if (polltime > 0) { | ||
this.adapter.log.info('Shelly device ' + this.getName() + ' with MQTT connected! Polltime set to ' + polltime + ' sec.'); | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! Polltime set to ${polltime} sec.`); | ||
} else { | ||
this.adapter.log.info('Shelly device ' + this.getName() + ' with MQTT connected! No polling'); | ||
this.adapter.log.info(`[MQTT] Device ${this.getName()} connected! No polling`); | ||
} | ||
@@ -435,7 +440,7 @@ | ||
} else { | ||
this.adapter.log.error('Wrong MQTT authentification for : ' + this.getName()); | ||
this.adapter.log.error(`[MQTT] Wrong MQTT authentification for: ${this.getName()}`); | ||
this.client.connack({ returnCode: 4 }); | ||
} | ||
} else { | ||
this.adapter.log.error(`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()} for MQTT does not exist!`); | ||
this.client.connack({ returnCode: 4 }); | ||
@@ -445,20 +450,22 @@ } | ||
this.client.on('close', (status) => { | ||
this.adapter.log.info('Close Client: ' + this.getName() + ' (' + status + ')'); | ||
this.adapter.log.info(`[MQTT] Close Client: ${this.getName()} (${status})`); | ||
this.destroy(); | ||
}); | ||
this.client.on('error', (error) => { | ||
// this.adapter.log.info('Error Client : ' + this.getName() + ' (' + error + ')'); | ||
// this.adapter.log.info(`[MQTT] Error Client: ${this.getName()} (${error})`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('disconnect', () => { | ||
this.adapter.log.info('Client Disconnect : ' + this.getName()); | ||
this.adapter.log.info(`[MQTT] Client Disconnect: ${this.getName()}`); | ||
this.destroy(); | ||
}); | ||
this.client.on('timeout', () => { | ||
this.adapter.log.info('Client Timeout : ' + this.getName()); | ||
this.adapter.log.info(`[MQTT] Client Timeout: ${this.getName()}`); | ||
// this.destroy(); | ||
}); | ||
this.client.on('publish', (packet) => { | ||
this.adapter.log.debug('Publish packet for ' + this.getName() + ' : ' + JSON.stringify(packet)); | ||
if (packet.payload) this.adapter.log.debug('Publish ' + this.getName() + ' payload: ' + packet.topic + ' = ' + packet.payload.toString()); | ||
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()}`); | ||
} | ||
@@ -501,3 +508,3 @@ // the ip address in docker container ist sometimes in stream.remoteAddress. We replace it, with the announce address | ||
} else { | ||
this.adapter.log.warn('Client ' + this.getName() + ' received pubrec for unknown messageId ' + packet.messageId); | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrec for unknown messageId: ${packet.messageId}`); | ||
} | ||
@@ -511,3 +518,3 @@ }); | ||
} else { | ||
this.adapter.log.warn('Client ' + this.getName() + ' received pubcomp for unknown messageId ' + packet.messageId); | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubcomp for unknown messageId: ${packet.messageId}`); | ||
} | ||
@@ -522,3 +529,3 @@ }); | ||
} else { | ||
this.adapter.log.warn('Client ' + this.getName() + ' received pubrel for unknown messageId ' + packet.messageId); | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received pubrel for unknown messageId: ${packet.messageId}`); | ||
} | ||
@@ -534,9 +541,8 @@ }); | ||
} else { | ||
this.adapter.log.warn('Client ' + this.getName() + ' received puback for unknown messageId ' + packet.messageId); | ||
this.adapter.log.warn(`[MQTT] Client ${this.getName()} received puback for unknown messageId: ${packet.messageId}`); | ||
} | ||
}); | ||
this.client.on('unsubscribe', (packet) => { | ||
this.adapter.log.debug('Unsubscribe for ' + this.getName() + ' : ' + JSON.stringify(packet)); | ||
this.adapter.log.debug(`[MQTT] Unsubscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
this.client.unsuback({ messageId: packet.messageId }); | ||
@@ -548,3 +554,3 @@ }); | ||
// send a suback with messageId and granted QoS level | ||
this.adapter.log.debug('Subscribe for ' + this.getName() + ' : ' + JSON.stringify(packet)); | ||
this.adapter.log.debug(`[MQTT] Subscribe ${this.getName()}: ${JSON.stringify(packet)}`); | ||
const granted = []; | ||
@@ -554,13 +560,9 @@ for (let i in packet.subscriptions) { | ||
let topic = packet.subscriptions[i].topic; | ||
// this.adapter.log.debug('publish topic: ' + topic); | ||
} | ||
if (packet.topic) this.adapter.log.debug('subscribe topic: ' + packet.topic); | ||
// this.adapter.log.info('Will: ' + packet.will); | ||
if (packet.topic) { | ||
this.adapter.log.debug(`[MQTT] Subscribe topic ${this.getName()}: ${packet.topic}`); | ||
} | ||
this.client.suback({ granted: granted, messageId: packet.messageId }); | ||
}); | ||
// timeout idle streams after 5 minutes | ||
// this.client.stream.setTimeout(1000 * 60 * 5); | ||
} | ||
} | ||
@@ -618,3 +620,2 @@ | ||
} | ||
} | ||
@@ -621,0 +622,0 @@ |
37
main.js
@@ -24,3 +24,3 @@ /* jshint -W097 */ | ||
this.serverCoap = null; | ||
this.pollTimeout = null; | ||
this.onlineCheckTimeout = null; | ||
@@ -108,5 +108,5 @@ this.onlineDevices = {}; | ||
onUnload(callback) { | ||
if (this.pollTimeout) { | ||
this.clearTimeout(this.pollTimeout); | ||
this.pollTimeout = null; | ||
if (this.onlineCheckTimeout) { | ||
this.clearTimeout(this.onlineCheckTimeout); | ||
this.onlineCheckTimeout = null; | ||
} | ||
@@ -145,5 +145,5 @@ | ||
if (this.pollTimeout) { | ||
this.clearTimeout(this.pollTimeout); | ||
this.pollTimeout = null; | ||
if (this.onlineCheckTimeout) { | ||
this.clearTimeout(this.onlineCheckTimeout); | ||
this.onlineCheckTimeout = null; | ||
} | ||
@@ -173,9 +173,11 @@ | ||
this.pollTimeout = this.setTimeout(() => { | ||
this.pollTimeout = null; | ||
this.onlineCheckTimeout = this.setTimeout(() => { | ||
this.onlineCheckTimeout = null; | ||
this.onlineCheck(); | ||
}, 60 * 1000); // Restart online check | ||
}, 60 * 1000); // Restart online check in 60 Seconds | ||
} | ||
async onDeviceStatusUpdate(deviceId, status) { | ||
if (!deviceId) return; | ||
this.log.debug(`onDeviceStatusUpdate: ${deviceId}: ${status}`); | ||
@@ -186,3 +188,3 @@ | ||
if (knownDevices.indexOf(deviceId) === -1) { | ||
// this.log.debug(`${deviceId} is not in list of known devices: ${JSON.stringify(knownDevices)}`); | ||
this.log.silly(`${deviceId} is not in list of known devices: ${JSON.stringify(knownDevices)}`); | ||
return; | ||
@@ -198,2 +200,7 @@ } | ||
await this.setStateAsync(idOnline, { val: status, ack: true }); | ||
await this.extendObjectAsync(deviceId, { | ||
common: { | ||
color: status ? '#46a100' : '#ff0400' | ||
} | ||
}); | ||
} | ||
@@ -239,4 +246,10 @@ | ||
await this.setStateAsync(idOnline, { val: false, ack: true }); | ||
this.setStateAsync('info.connection', false, true); | ||
await this.extendObjectAsync(deviceId, { | ||
common: { | ||
color: '#ff0400' | ||
} | ||
}); | ||
} | ||
this.setStateAsync('info.connection', false, true); | ||
} | ||
@@ -243,0 +256,0 @@ |
{ | ||
"name": "iobroker.shelly", | ||
"version": "5.1.0", | ||
"version": "5.1.1", | ||
"description": "Shelly", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -85,2 +85,8 @@ ![Logo](admin/shelly.png) | ||
--> | ||
### 5.1.1 (2022-01-26) | ||
* (klein0r) Fixed firmware auto update | ||
* (klein0r) Updated timeouts | ||
* (klein0r) Added command source for shelly 2.5 | ||
* (klein0r) Added color for device objects as online indicator | ||
### 5.1.0 (2022-01-25) | ||
@@ -87,0 +93,0 @@ * (klein0r) Added input states for generation 2 devices |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
704256
16064
414
2