iobroker.shelly
Advanced tools
Comparing version 2.0.7 to 2.0.8
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"news": { | ||
"2.0.8": { | ||
"en": "Bugfixing, polling new Shelly status must be at least 1 sec ago", | ||
"de": "Fehlerbehbung, neuer Shelly Status darf maximal 1 mal pro Sek. gepolled werden" | ||
}, | ||
"2.0.7": { | ||
@@ -141,2 +145,3 @@ "en": "Bugfixing for objects AutoTimerOn and AutoTimeroff", | ||
"polltime": 10, | ||
"timeout": 0.25, | ||
"keys": [ | ||
@@ -143,0 +148,0 @@ { |
@@ -178,6 +178,8 @@ /* jshint -W097 */ | ||
"type": "number", | ||
"role": "level", | ||
"role": "level.blind", | ||
"read": true, | ||
"write": true, | ||
"unit": "%" | ||
"unit": "%", | ||
"min": 0, | ||
"max": 100 | ||
}, | ||
@@ -184,0 +186,0 @@ 'mode': { |
{ | ||
"name": "iobroker.shelly", | ||
"version": "2.0.7", | ||
"version": "2.0.8", | ||
"description": "Shelly", | ||
@@ -33,3 +33,3 @@ "author": { | ||
"@apollon/iobroker-tools": "^0.1.0", | ||
"@iobroker/adapter-core": "^1.0.1", | ||
"@iobroker/adapter-core": "^1.0.3", | ||
"ping": "^0.2.1", | ||
@@ -40,2 +40,3 @@ "request": "^2.79.0", | ||
"devDependencies": { | ||
"axios": "^0.18.0", | ||
"chai": "^4.2.0", | ||
@@ -45,3 +46,3 @@ "eslint": "^5.11.1", | ||
"eslint-plugin-import": "^2.14.0", | ||
"gulp": "^3.9.1", | ||
"gulp": "^4.0.0", | ||
"mocha": "^4.1.0" | ||
@@ -48,0 +49,0 @@ }, |
@@ -41,2 +41,5 @@ ![Logo](admin/shelly.png) | ||
### 2.0.8 (31.01.2019) | ||
* Bugfixing, polling new Shelly status must be at least 1 sec ago | ||
### 2.0.7 (21.01.2019) | ||
@@ -43,0 +46,0 @@ * Bugfixing for objects AutoTimerOn and AutoTimeroff |
142
shelly.js
@@ -178,3 +178,3 @@ /* jshint -W097 */ | ||
function createChannel(deviceId, state) { | ||
@@ -281,2 +281,6 @@ let arr = state.split('.'); | ||
let now = Date.now(); | ||
let sec = (now - knownDevices[deviceId].ts) / 1000; // seconds | ||
let timeout = adapter.config.timeout || 0.25; // seconds | ||
if (typeof status === 'function') { | ||
@@ -287,2 +291,8 @@ callback = status; | ||
// wir pollen maximal jede Sekunde den neuen Status | ||
if (sec < timeout) { | ||
return callback && callback(); | ||
} | ||
knownDevices[deviceId].ts = now; | ||
adapter.log.debug('Update Shelly States for ' + deviceId); | ||
@@ -394,30 +404,33 @@ if (deviceId && typeof deviceId === 'string') { | ||
// get status from CoAP Message | ||
let ids = getIoBrokerStatesFromObj(status); | ||
for (let i in ids) { | ||
let id = i; | ||
let value = ids[i]; | ||
let controlFunction; | ||
// historical mapping | ||
if (status) { | ||
let ids = getIoBrokerStatesFromObj(status); | ||
for (let i in ids) { | ||
let id = i; | ||
let value = ids[i]; | ||
let controlFunction; | ||
// historical mapping | ||
switch (id) { | ||
case 'G2': | ||
id = 'Relay0.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
default: | ||
} | ||
switch (id) { | ||
case 'G2': | ||
id = 'Relay0.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
default: | ||
} | ||
if (shellyStates.hasOwnProperty(deviceId + '.' + id) && shellyStates[deviceId + '.' + id] == value) { | ||
continue; | ||
} | ||
shellyStates[deviceId + '.' + id] = value; | ||
if (shellyStates.hasOwnProperty(deviceId + '.' + id) && shellyStates[deviceId + '.' + id] == value) { | ||
continue; | ||
} | ||
shellyStates[deviceId + '.' + id] = value; | ||
if (devices.hasOwnProperty(id)) { | ||
let stateId = deviceId + '.' + id; | ||
let common = devices[id]; | ||
objectHelper.setOrUpdateObject(stateId, { | ||
type: 'state', | ||
common: common | ||
}, ['name'], value, controlFunction); | ||
if (devices.hasOwnProperty(id)) { | ||
let stateId = deviceId + '.' + id; | ||
let common = devices[id]; | ||
objectHelper.setOrUpdateObject(stateId, { | ||
type: 'state', | ||
common: common | ||
}, ['name'], value, controlFunction); | ||
} | ||
} | ||
// return callback && callback(); | ||
} | ||
@@ -685,34 +698,38 @@ | ||
// CoAP Messages - switches on/on | ||
let ids = getIoBrokerStatesFromObj(status); | ||
for (let i in ids) { | ||
let id = i; | ||
let value = ids[i]; | ||
let controlFunction; | ||
// historical mapping | ||
// if (status && knownDevices[deviceId].mode === 'relay') { | ||
if (status) { | ||
let ids = getIoBrokerStatesFromObj(status); | ||
for (let i in ids) { | ||
let id = i; | ||
let value = ids[i]; | ||
let controlFunction; | ||
// historical mapping | ||
switch (id) { | ||
case 'G02': | ||
id = 'Relay0.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
case 'G12': | ||
id = 'Relay1.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
default: | ||
} | ||
switch (id) { | ||
case 'G02': | ||
id = 'Relay0.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
case 'G12': | ||
id = 'Relay1.Switch'; | ||
value = value === 1 || value === true ? true : false; | ||
break; | ||
default: | ||
} | ||
if (shellyStates.hasOwnProperty(deviceId + '.' + id) && shellyStates[deviceId + '.' + id] == value) { | ||
continue; | ||
} | ||
shellyStates[deviceId + '.' + id] = value; | ||
if (shellyStates.hasOwnProperty(deviceId + '.' + id) && shellyStates[deviceId + '.' + id] == value) { | ||
continue; | ||
} | ||
shellyStates[deviceId + '.' + id] = value; | ||
if (devices.hasOwnProperty(id)) { | ||
let stateId = deviceId + '.' + id; | ||
let common = devices[id]; | ||
objectHelper.setOrUpdateObject(stateId, { | ||
type: 'state', | ||
common: common | ||
}, ['name'], value, controlFunction); | ||
if (devices.hasOwnProperty(id)) { | ||
let stateId = deviceId + '.' + id; | ||
let common = devices[id]; | ||
objectHelper.setOrUpdateObject(stateId, { | ||
type: 'state', | ||
common: common | ||
}, ['name'], value, controlFunction); | ||
} | ||
} | ||
// return callback && callback(); | ||
} | ||
@@ -727,12 +744,14 @@ | ||
let value = ids[i]; | ||
let rollerValue; | ||
let rollerModus; | ||
let rollerValue = ids['rollers.state']; | ||
let rollerModus = ids['mode']; | ||
let controlFunction; | ||
// historical mapping | ||
knownDevices[deviceId].mode = rollerModus; | ||
switch (id) { | ||
case 'relays0.ison': | ||
id = 'Relay0.Switch'; | ||
rollerValue = ids['rollers.state']; | ||
rollerModus = ids['mode']; | ||
// rollerValue = ids['rollers.state']; | ||
// rollerModus = ids['mode']; | ||
if (rollerModus == 'roller' && (rollerValue == 'stop' || rollerValue == 'close')) { value = false; } | ||
@@ -749,4 +768,4 @@ if (rollerModus == 'roller' && rollerValue == 'open') { value = true; } | ||
id = 'Relay1.Switch'; | ||
rollerValue = ids['rollers.state']; | ||
rollerModus = ids['mode']; | ||
// rollerValue = ids['rollers.state']; | ||
// rollerModus = ids['mode']; | ||
if (rollerModus == 'roller' && (rollerValue == 'stop' || rollerValue == 'open')) { value = false; } | ||
@@ -1635,2 +1654,6 @@ if (rollerModus == 'roller' && rollerValue == 'close') { value = true; } | ||
shelly.getDeviceDescription(deviceId, (err, deviceId, description, ip) => { | ||
knownDevices[deviceId] = { | ||
ts: 0, | ||
mode: undefined | ||
}; | ||
createShellyStates(deviceId, description, ip, status); | ||
@@ -1644,3 +1667,2 @@ updateShellyStates(deviceId, status); | ||
}); // if device is added later, create all objects | ||
knownDevices[deviceId] = true; | ||
}); | ||
@@ -1647,0 +1669,0 @@ return; |
270702
14
2588
124
7