iobroker.shelly
Advanced tools
Comparing version 0.2.5 to 1.0.0
{ | ||
"common": { | ||
"name": "shelly", | ||
"version": "0.2.5", | ||
"version": "1.0.0", | ||
"news": { | ||
"1.0.0": { | ||
"en": "Optimizations and Online status fixed", | ||
"de": "Fehelr bei Anzeige des Online-Status behoben, Optimierungen" | ||
}, | ||
"0.2.6": { | ||
"en": "Two new datapoints (AutoTimerOn and AutoTimerOff) for Shelly 1/2", | ||
"de": "Datapoints AutoTimerOn und AutoTimerOff für Shelly 1/2 hinzugefügt" | ||
}, | ||
"0.2.5": { | ||
@@ -7,0 +15,0 @@ "en": "Hostname instead of ip address will be shown", |
@@ -106,2 +106,22 @@ /* jshint -W097 */ | ||
}, | ||
'AutoTimerOn': { | ||
type: 'number', | ||
role: 'level.timer', | ||
id: 'AutoTimerOn', | ||
name: 'Auto Timer On', | ||
read: true, | ||
write: true, | ||
unit: 's', | ||
def: 0 | ||
}, | ||
'AutoTimerOff': { | ||
type: 'number', | ||
role: 'level.timer', | ||
id: 'AutoTimerOff', | ||
name: 'Auto Timer Off', | ||
read: true, | ||
write: true, | ||
unit: 's', | ||
def: 0 | ||
}, | ||
'Shutter': { | ||
@@ -133,3 +153,3 @@ type: 'number', | ||
name: 'Pause', | ||
read: false, | ||
read: false, | ||
write: true | ||
@@ -136,0 +156,0 @@ }, |
@@ -253,3 +253,11 @@ /* jshint -W097 */ | ||
if (adapterObjects[id] && adapterObjects[id].common && adapterObjects[id].common.type && adapterObjects[id].common.type !== 'mixed') { | ||
if (adapterObjects[id].common.type === 'boolean' && adapterObjects[id].common.role && adapterObjects[id].common.role.startsWith('button')) state.val = !!state.val; | ||
if (adapterObjects[id].common.type === 'boolean') { | ||
if (state.val === 'true') { | ||
state.val = true; | ||
} | ||
else if (state.val === 'false') { | ||
state.val = false; | ||
} | ||
state.val = !!state.val; | ||
} | ||
if (typeof state.val !== adapterObjects[id].common.type) { | ||
@@ -256,0 +264,0 @@ adapter.log.error('Datatype for ' + id + ' differs from expected, ignore state change! Please write correct datatype (' + adapterObjects[id].common.type + ')'); |
{ | ||
"name": "iobroker.shelly", | ||
"version": "0.2.5", | ||
"version": "1.0.0", | ||
"description": "Shelly", | ||
@@ -34,3 +34,3 @@ "author": { | ||
"request": "^2.79.0", | ||
"shelly-iot": "^0.2.0" | ||
"shelly-iot": "^1.0.1" | ||
}, | ||
@@ -37,0 +37,0 @@ "devDependencies": { |
@@ -40,2 +40,8 @@ ![Logo](admin/shelly.png) | ||
### 1.0.0 (10.11.2018) | ||
* Optimizations and Online status fixed | ||
### 0.2.6 (31.10.2018) | ||
* Two new datapoints (AutoTimerOn and AutoTimerOn) for Shelly 1/2 | ||
### 0.2.5 (13.10.2018) | ||
@@ -42,0 +48,0 @@ * Hostname instead of ip address will be shown |
223
shelly.js
@@ -34,3 +34,3 @@ /* jshint -W097 */ | ||
// is called when adapter shuts down - callback has to be called under any circumstances! | ||
adapter.on('unload', function(callback) { | ||
adapter.on('unload', function (callback) { | ||
try { | ||
@@ -50,3 +50,3 @@ setConnected(false); | ||
process.on('SIGINT', function() { | ||
process.on('SIGINT', function () { | ||
if (shelly) { | ||
@@ -59,3 +59,3 @@ isStopped = true; | ||
process.on('uncaughtException', function(err) { | ||
process.on('uncaughtException', function (err) { | ||
console.log('Exception: ' + err + '/' + err.toString()); | ||
@@ -74,3 +74,3 @@ if (adapter && adapter.log) { | ||
// is called if a subscribed state changes | ||
adapter.on('stateChange', function(id, state) { | ||
adapter.on('stateChange', function (id, state) { | ||
// Warning, state can be null if it was deleted | ||
@@ -95,3 +95,3 @@ adapter.log.debug('stateChange ' + id + ' ' + JSON.stringify(state)); | ||
// start here! | ||
adapter.on('ready', function() { | ||
adapter.on('ready', function () { | ||
// main(); | ||
@@ -159,7 +159,7 @@ adapter.getForeignObject('system.config', (err, obj) => { | ||
} | ||
adapter.getAdapterObjects(function(obj) { | ||
adapter.getAdapterObjects(function (obj) { | ||
for (let id in obj) { | ||
let o = obj[id]; | ||
if (id.startsWith(channel)) { | ||
adapter.delObject(id, function() { | ||
adapter.delObject(id, function () { | ||
adapter.log.debug("Delete old object " + id); | ||
@@ -195,5 +195,5 @@ }); | ||
if (sen && blk) { | ||
sen.forEach(function(s) { | ||
sen.forEach(function (s) { | ||
let found = false; | ||
blk.forEach(function(b) { | ||
blk.forEach(function (b) { | ||
if (b.I == s.L) { | ||
@@ -217,3 +217,3 @@ found = true; | ||
if (sen) { | ||
sen.forEach(function(s) { | ||
sen.forEach(function (s) { | ||
if (blockId == s.L) { | ||
@@ -232,3 +232,3 @@ arr[++cnt] = s; | ||
if (act) { | ||
act.forEach(function(a) { | ||
act.forEach(function (a) { | ||
if (blockId == a.L) { | ||
@@ -286,5 +286,9 @@ arr[++cnt] = a; | ||
if (dp) { | ||
let tmpId; | ||
if (dp.id) { | ||
tmpId = b ? deviceId + '.' + b.D + '.' + dp.id : deviceId + '.' + dp.id; // Status ID in ioBroker | ||
let tmpId = b ? deviceId + '.' + b.D + '.' + dp.name : deviceId + '.' + dp.name; // Status ID in ioBroker | ||
} else { | ||
tmpId = b ? deviceId + '.' + b.D + '.' + dp.name : deviceId + '.' + dp.name; // Status ID in ioBroker | ||
} | ||
let value = getStateBySenId(s.I, data); // Status for Sensor ID | ||
@@ -304,3 +308,3 @@ if (!getSensorIoBrokerIDs(deviceId, s.I)) { | ||
const relayId = parseInt(b.D.substr(5), 10); | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
let params; | ||
@@ -328,3 +332,3 @@ let timer = 0; | ||
if (b && b.D.startsWith('Relay') && s.T === 'SwitchTimer') { | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
setSensorIoBrokerIDs(deviceId, s.I, { | ||
@@ -343,3 +347,3 @@ value: value || 0 | ||
let sen = getSensorIoBrokerIDs(deviceId, s.I); | ||
adapter.getState(sen.id, function(err, state) { | ||
adapter.getState(sen.id, function (err, state) { | ||
if (!err && state) { | ||
@@ -352,4 +356,86 @@ controlFunction(state.val); | ||
} | ||
if (b && b.D.startsWith('Relay') && s.T === 'AutoTimerOn') { | ||
const relayId = parseInt(b.D.substr(5), 10); | ||
let turn = 0; | ||
let sensorIoBrokerID; | ||
for (let i in sensorIoBrokerIDs) { | ||
if (sensorIoBrokerIDs[i].id == deviceId + '.' + b.D + '.Switch') { | ||
sensorIoBrokerID = sensorIoBrokerIDs[i]; | ||
break; | ||
} | ||
} | ||
if (sensorIoBrokerID) { | ||
turn = sensorIoBrokerID.value; | ||
} | ||
controlFunction = function (value) { | ||
setSensorIoBrokerIDs(deviceId, s.I, { | ||
value: value || 0 | ||
}); | ||
let sen = getSensorIoBrokerIDs(deviceId, s.I); | ||
if (sen && sen.id) { | ||
adapter.setState(sen.id, { | ||
val: value || 0, | ||
ack: true | ||
}); | ||
} | ||
let params; | ||
params = { | ||
'auto_on': value | ||
}; | ||
adapter.log.debug("Auto Timer on: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/settings/relay/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
// call once at start | ||
let sen = getSensorIoBrokerIDs(deviceId, s.I); | ||
adapter.getState(sen.id, function (err, state) { | ||
if (!err && state) { | ||
controlFunction(state.val); | ||
} else { | ||
controlFunction(value || 0); | ||
} | ||
}); | ||
} | ||
if (b && b.D.startsWith('Relay') && s.T === 'AutoTimerOff') { | ||
const relayId = parseInt(b.D.substr(5), 10); | ||
let turn = 0; | ||
let sensorIoBrokerID; | ||
for (let i in sensorIoBrokerIDs) { | ||
if (sensorIoBrokerIDs[i].id == deviceId + '.' + b.D + '.Switch') { | ||
sensorIoBrokerID = sensorIoBrokerIDs[i]; | ||
break; | ||
} | ||
} | ||
if (sensorIoBrokerID) { | ||
turn = sensorIoBrokerID.value; | ||
} | ||
controlFunction = function (value) { | ||
setSensorIoBrokerIDs(deviceId, s.I, { | ||
value: value || 0 | ||
}); | ||
let sen = getSensorIoBrokerIDs(deviceId, s.I); | ||
if (sen && sen.id) { | ||
adapter.setState(sen.id, { | ||
val: value || 0, | ||
ack: true | ||
}); | ||
} | ||
let params; | ||
params = { | ||
'auto_off': value | ||
}; | ||
adapter.log.debug("Auto Timer off: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/settings/relay/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
// call once at start | ||
let sen = getSensorIoBrokerIDs(deviceId, s.I); | ||
adapter.getState(sen.id, function (err, state) { | ||
if (!err && state) { | ||
controlFunction(state.val); | ||
} else { | ||
controlFunction(value || 0); | ||
} | ||
}); | ||
} | ||
if (b && b.D.startsWith('Shutter') && s.T === 'ShutterUp') { | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
if (value === true || value === 1) { | ||
@@ -389,3 +475,3 @@ // only do something if value is true | ||
if (b && b.D.startsWith('Shutter') && s.T === 'ShutterDown') { | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
// only do something if value is true | ||
@@ -425,3 +511,3 @@ if (value === true || value === 1) { | ||
if (b && b.D.startsWith('Shutter') && s.T === 'ShutterStop') { | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
if (value === true || value === 1) { | ||
@@ -449,3 +535,3 @@ // only do something if value is true | ||
if (b && b.D.startsWith('Shutter') && s.T === 'ShutterDuration') { | ||
controlFunction = function(value) { | ||
controlFunction = function (value) { | ||
setSensorIoBrokerIDs(deviceId, s.I, { | ||
@@ -465,2 +551,57 @@ value: value || 0 | ||
} | ||
if (b && b.D.startsWith('RGBW') && s.T === 'Red') { // Implement all needed action stuff here based on the names | ||
const relayId = b.I; | ||
controlFunction = function (value) { | ||
let params; | ||
params = { | ||
'red': value | ||
}; | ||
adapter.log.debug("RGBW Red: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/light/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
} | ||
if (b && b.D.startsWith('RGBW') && s.T === 'Green') { // Implement all needed action stuff here based on the names | ||
const relayId = b.I; | ||
controlFunction = function (value) { | ||
let params; | ||
params = { | ||
'green': value | ||
}; | ||
adapter.log.debug("RGBW Green: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/light/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
} | ||
if (b && b.D.startsWith('RGBW') && s.T === 'Blue') { // Implement all needed action stuff here based on the names | ||
const relayId = b.I; | ||
controlFunction = function (value) { | ||
let params; | ||
params = { | ||
'blue': value | ||
}; | ||
adapter.log.debug("RGBW Blue: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/light/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
} | ||
if (b && b.D.startsWith('RGBW') && s.T === 'White') { // Implement all needed action stuff here based on the names | ||
const relayId = b.I; | ||
controlFunction = function (value) { | ||
let params; | ||
params = { | ||
'white': value | ||
}; | ||
adapter.log.debug("RGBW White: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/light/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
} | ||
if (b && b.D.startsWith('RGBW') && s.T === 'VSwitch') { // Implement all needed action stuff here based on the names | ||
const relayId = b.I; | ||
controlFunction = function (value) { | ||
let params; | ||
params = { | ||
'turn': (value === true || value === 1) ? 'on' : 'off' | ||
}; | ||
adapter.log.debug("RGBW Switch: " + JSON.stringify(params)); | ||
shelly.callDevice(deviceId, '/light/' + relayId, params); // send REST call to devices IP with the given path and parameters | ||
}; | ||
} | ||
} | ||
@@ -512,3 +653,3 @@ if (dp.type === 'boolean') { | ||
// get hostname for ip adresss | ||
dns.reverse(ip, function(err, hostnames) { | ||
dns.reverse(ip, function (err, hostnames) { | ||
let hostname = (!err && hostnames.length > 0) ? hostnames[0] : ip; | ||
@@ -531,5 +672,11 @@ adapter.log.debug('Create state object for ' + deviceId + '.hostname' + ' if not exist'); | ||
// Loop over block | ||
blk.forEach(function(b) { | ||
blk.forEach(function (b) { | ||
// Block ID: b.I | ||
// Block Descrition: b.D | ||
// Workaround, because, the block ID is wrong | ||
if (b.D == 'RGBW' && b.I == 1) { | ||
b.I = 0; | ||
} | ||
let sen = getSenByBlkID(b.I, description.sen); // Sensoren for this Block | ||
@@ -548,3 +695,3 @@ let act = getActByBlkID(b.I, description.act); // Actions for this Block | ||
// Loop over sensor for a block device | ||
sen.forEach(function(s) { | ||
sen.forEach(function (s) { | ||
createSensorStates(deviceId, b, s, data); | ||
@@ -559,4 +706,7 @@ | ||
*/ | ||
let sI = s.I; | ||
s = { | ||
'I': 'switchtimer' + s.I, | ||
'I': 'switchtimer' + sI, | ||
'T': 'SwitchTimer', | ||
@@ -567,2 +717,19 @@ 'D': 'Timer', | ||
createSensorStates(deviceId, b, s, data); | ||
s = { | ||
'I': 'autotimeron' + sI, | ||
'T': 'AutoTimerOn', | ||
'D': 'Auto Timer On', | ||
'L': b.I | ||
}; | ||
createSensorStates(deviceId, b, s, data); | ||
s = { | ||
'I': 'autotimeroff' + sI, | ||
'T': 'AutoTimerOff', | ||
'D': 'Auto Timer Off', | ||
'L': b.I | ||
}; | ||
createSensorStates(deviceId, b, s, data); | ||
} | ||
@@ -572,3 +739,3 @@ | ||
// loop over action for block device | ||
act.forEach(function(a) {}); | ||
act.forEach(function (a) { }); | ||
}); | ||
@@ -578,3 +745,3 @@ // looking for sensor with no link to a block device | ||
// loop over sensor with no link to a block device | ||
sen.forEach(function(s) { | ||
sen.forEach(function (s) { | ||
createSensorStates(deviceId, null, s, data); | ||
@@ -643,3 +810,3 @@ }); | ||
if (data && data.G) { | ||
data.G.forEach(function(g) { | ||
data.G.forEach(function (g) { | ||
obj[g[1]] = g[2]; // id = val | ||
@@ -844,1 +1011,3 @@ }); | ||
} | ||
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
238042
12
1594
0
93
+ Added@types/bl@5.1.4(transitive)
+ Added@types/node@16.18.125(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbl@5.1.0(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedcapitalize@2.0.4(transitive)
+ Addedcoap@0.26.0(transitive)
+ Addedcoap-packet@1.1.1(transitive)
+ Addeddebug@4.4.0(transitive)
+ Addedfastseries@2.0.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedlru-cache@6.0.0(transitive)
+ Addedreadable-stream@3.6.2(transitive)
+ Addedshelly-iot@1.1.2(transitive)
+ Addedstring_decoder@1.3.0(transitive)
+ Addedyallist@4.0.0(transitive)
- Removedbl@1.2.3(transitive)
- Removedcapitalize@1.0.0(transitive)
- Removedcoap@0.22.0(transitive)
- Removedcoap-packet@0.1.14(transitive)
- Removedcore-util-is@1.0.3(transitive)
- Removeddebug@2.6.9(transitive)
- Removedfastseries@1.7.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedms@2.0.0(transitive)
- Removedprocess-nextick-args@2.0.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedreadable-stream@2.3.8(transitive)
- Removedreusify@1.0.4(transitive)
- Removedsafe-buffer@5.1.2(transitive)
- Removedshelly-iot@0.2.0(transitive)
- Removedstring_decoder@1.1.1(transitive)
- Removedxtend@4.0.2(transitive)
- Removedyallist@2.1.2(transitive)
Updatedshelly-iot@^1.0.1