New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iobroker.shelly

Package Overview
Dependencies
Maintainers
1
Versions
107
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.shelly - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

.eslintignore

6

io-package.json
{
"common": {
"name": "shelly",
"version": "2.0.1",
"version": "2.0.2",
"news": {
"2.0.2": {
"en": "Add Shelly H&T",
"de": "Shelly H&T Unterstützung"
},
"2.0.1": {

@@ -7,0 +11,0 @@ "en": "Major update because of problems with CoAP messages",

@@ -527,2 +527,63 @@ /* jshint -W097 */

let shellyht = {
"tmp.value": {
"name": "Temperature",
"type": "number",
"role": "value.temperature",
"read": true,
"write": false,
"min": -100,
"max": 100
},
"hum.value": {
"name": "Relative humidity",
"type": "number",
"role": "value.humidity",
"read": true,
"write": false,
"min": 0,
"max": 100,
"unit": "%"
},
"bat.value": {
"name": "Battery capacity",
"type": "number",
"role": "value.battery",
"read": true,
"write": false,
"min": 0,
"max": 100,
"unit": "%"
},
};
let shellysmoke = {
"tmp.value": {
"name": "Temperature",
"type": "number",
"role": "value.temperature",
"read": true,
"write": false,
"min": -100,
"max": 100
},
"smoke.value": {
"name": "Smoke detected",
"type": "boolean",
"role": "sensor.alarm.fire",
"read": true,
"write": false
},
"bat.value": {
"name": "Battery capacity",
"type": "number",
"role": "value.battery",
"read": true,
"write": false,
"min": 0,
"max": 100,
"unit": "%"
}
};
let allShellys = {

@@ -533,3 +594,5 @@ 'shelly1': shelly1,

'shplg1': shplg1,
'shellyrgbww': shellyrgbww
'shellyrgbww': shellyrgbww,
'shellyht': shellyht,
'shellysmoke': shellysmoke
};

@@ -558,3 +621,2 @@

module.exports = {

@@ -561,0 +623,0 @@ getAll: getAll,

11

package.json
{
"name": "iobroker.shelly",
"version": "2.0.1",
"version": "2.0.2",
"description": "Shelly",

@@ -32,10 +32,13 @@ "author": {

"dependencies": {
"@apollon/iobroker-tools": "^0.1.0",
"@iobroker/adapter-core": "^1.0.1",
"ping": "^0.2.1",
"request": "^2.79.0",
"shelly-iot": "^1.0.1",
"@iobroker/adapter-core": "^1.0.1",
"@apollon/iobroker-tools": "^0.1.0"
"shelly-iot": "^1.0.2"
},
"devDependencies": {
"chai": "^4.2.0",
"eslint": "^5.11.1",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.14.0",
"gulp": "^3.9.1",

@@ -42,0 +45,0 @@ "mocha": "^4.1.0"

@@ -34,2 +34,3 @@ ![Logo](admin/shelly.png)

* ShellyRGBW (SHRGBWW-01, not verified and tested)
* Shelly H&T (SHHT-1, verified)

@@ -41,2 +42,5 @@ ## More details needed to implement (Debug log)

### 2.0.2 (22.12.2018)
* Add Shelly H&T.
### 2.0.1 (22.12.2018)

@@ -43,0 +47,0 @@ * Major update because of problems with CoAP messages.

@@ -10,3 +10,3 @@ /* jshint -W097 */

const dns = require('dns');
const utils = require('@iobroker/adapter-core');
const utils = require('@iobroker/adapter-core');
const adapter = new utils.Adapter('shelly');

@@ -16,12 +16,14 @@ const objectHelper = require('@apollon/iobroker-tools').objectHelper; // Get common adapter utils

const Shelly = require('shelly-iot');
let shelly;
let knownDevices = {};
let shellyStates = {};
const knownDevices = {};
const shellyStates = {};
let isStopped = false;
let connected = null;
function decrypt(key, value) {
let result = '';
for (let i = 0; i < value.length; ++i) {

@@ -35,3 +37,3 @@ result += String.fromCharCode(key[i % key.length].charCodeAt(0) ^ value.charCodeAt(i));

// is called when adapter shuts down - callback has to be called under any circumstances!
adapter.on('unload', function (callback) {
adapter.on('unload', (callback) => {
try {

@@ -51,3 +53,3 @@ setConnected(false);

process.on('SIGINT', function () {
process.on('SIGINT', () => {
if (shelly) {

@@ -60,3 +62,3 @@ isStopped = true;

process.on('uncaughtException', function (err) {
process.on('uncaughtException', (err) => {
console.log('Exception: ' + err + '/' + err.toString());

@@ -75,3 +77,3 @@ if (adapter && adapter.log) {

// is called if a subscribed state changes
adapter.on('stateChange', function (id, state) {
adapter.on('stateChange', (id, state) => {
// Warning, state can be null if it was deleted

@@ -92,4 +94,4 @@ if (state && !state.ack) {

if (iobrokerId) {
let res = iobrokerId.replace(adapter.namespace + '.', '');
let arr = res.split('.');
const res = iobrokerId.replace(adapter.namespace + '.', '');
const arr = res.split('.');
deviceId = arr[0];

@@ -192,3 +194,3 @@ }

} catch (err) {
let hostname = '';
let hostname = ip || '';
adapter.log.debug('Create state object for ' + deviceId + '.hostname' + ' if not exist');

@@ -208,4 +210,11 @@ objectHelper.setOrUpdateObject(deviceId + '.hostname', {

function createShellyStates(deviceId, description, ip, callback) {
function createShellyStates(deviceId, description, ip, status, callback) {
if (typeof status === 'function') {
callback = status;
status = undefined;
}
if (deviceId) {
createDevice(deviceId, description, ip);

@@ -222,3 +231,5 @@ if (deviceId.startsWith('SHSW-1')) {

createShellyRGBWWStates(deviceId);
} else {
} else if (deviceId.startsWith('SHHT')) {
createShellyHTStates(deviceId);
}else {
displaySettings(deviceId);

@@ -232,3 +243,9 @@ callback && callback();

function updateShellyStates(deviceId, callback) {
function updateShellyStates(deviceId, status, callback) {
if (typeof status === 'function') {
callback = status;
status = undefined;
}
if (deviceId) {

@@ -245,2 +262,4 @@ if (deviceId.startsWith('SHSW-1')) {

updateShellyRGBWWStates(deviceId, callback);
} else if (deviceId.startsWith('SHHT')) {
updateShellyHTStates(deviceId, status, callback);
} else {

@@ -272,3 +291,3 @@ callback && callback();

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -298,3 +317,3 @@ let timer = 0;

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -311,3 +330,3 @@ params = {

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -338,4 +357,5 @@ params = {

let devices = datapoints.getObjectByName('shelly1');
let parameter = {};
shelly.callDevice(deviceId, '/settings', (error, data) => {
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -401,3 +421,3 @@ let ids = getIoBrokerStatesFromObj(data);

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -427,3 +447,3 @@ let timer = 0;

const pos = i.substr(8);
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -471,3 +491,3 @@ let duration = 0;

if (i == 'Shutter.state') { // Implement all needed action stuff here based on the names
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -496,3 +516,3 @@ let duration = 0;

if (i == 'Shutter.Position') { // Implement all needed action stuff here based on the names
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -511,3 +531,3 @@ let position = value;

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => (value) =>{
let params;

@@ -524,3 +544,3 @@ params = {

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -536,3 +556,3 @@ params = {

if (i == 'mode') {
controlFunction = function (value) {
controlFunction = (value) =>(value) => {
let params;

@@ -567,4 +587,5 @@ params = {

let devices = datapoints.getObjectByName('shelly2');
let parameter = {};
shelly.callDevice(deviceId, '/settings', (error, data) => {
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -636,3 +657,3 @@ let ids = getIoBrokerStatesFromObj(data);

shelly.callDevice(deviceId, '/status', (error, data) => {
shelly.callDevice(deviceId, '/status', parameter, (error, data) => {
if (!error && data) {

@@ -694,3 +715,3 @@ let ids = getIoBrokerStatesFromObj(data);

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -720,3 +741,3 @@ let timer = 0;

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -733,3 +754,3 @@ params = {

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -760,4 +781,5 @@ params = {

let devices = datapoints.getObjectByName('shelly4');
let parameter = {};
shelly.callDevice(deviceId, '/settings', (error, data) => {
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -862,3 +884,3 @@ let ids = getIoBrokerStatesFromObj(data);

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -888,3 +910,3 @@ let timer = 0;

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -901,3 +923,3 @@ params = {

const relayId = parseInt(i.substr(5), 10);
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -928,4 +950,5 @@ params = {

let devices = datapoints.getObjectByName('shplg1');
let parameter = {};
shelly.callDevice(deviceId, '/settings', (error, data) => {
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -993,3 +1016,3 @@ let ids = getIoBrokerStatesFromObj(data);

if (i == 'lights.Switch') { // Implement all needed action stuff here based on the names
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -1019,3 +1042,3 @@ let timer = 0;

let id = i.replace('lights.', '');
controlFunction = function (value) {
controlFunction = (value) => {
let params = {};

@@ -1029,3 +1052,3 @@ params[id] = value;

if (i == 'lights.AutoTimerOff') {
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -1041,3 +1064,3 @@ params = {

if (i == 'lights.AutoTimerOn') {
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -1053,3 +1076,3 @@ params = {

if (i == 'mode') {
controlFunction = function (value) {
controlFunction = (value) => {
let params;

@@ -1080,4 +1103,5 @@ params = {

let devices = datapoints.getObjectByName('shellyrgbww');
let parameter = {};
shelly.callDevice(deviceId, '/settings', (error, data) => {
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -1126,6 +1150,77 @@ let ids = getIoBrokerStatesFromObj(data);

// *******************************************************************************
// Shelly H&T
// *******************************************************************************
function createShellyHTStates(deviceId, callback) {
let devices = datapoints.getObjectByName('shellyht');
for (let i in devices) {
let common = devices[i];
let stateId = deviceId + '.' + i;
let controlFunction;
let value;
createChannel(deviceId, i);
adapter.log.debug("Creating State " + stateId);
objectHelper.setOrUpdateObject(stateId, {
type: 'state',
common: common
}, ['name'], value, controlFunction);
}
}
function updateShellyHTStates(deviceId, status, callback) {
let devices = datapoints.getObjectByName('shellyht');
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 = 'tmp.value';
break;
case 'G12':
id = 'hum.value';
value = value / 2;
break;
case 'G22':
id = 'bat.value';
break;
default:
}
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);
}
}
callback && callback();
}
// *******************************************************************************
// Display Settings
// *******************************************************************************
function displaySettings(deviceId) {
shelly.callDevice(deviceId, '/settings', (error, data) => {
let parameter = {};
shelly.callDevice(deviceId, '/settings', parameter, (error, data) => {
if (!error && data) {

@@ -1136,3 +1231,3 @@ adapter.log.debug("New Device Settings for " + deviceId + " : " + JSON.stringify(data));

shelly.callDevice(deviceId, '/status', (error, data) => {
shelly.callDevice(deviceId, '/status', parameter, (error, data) => {
if (!error && data) {

@@ -1145,2 +1240,13 @@ adapter.log.debug("New Device Status for " + deviceId + " : " + JSON.stringify(data));

function isShellyOnine() {
adapter.getAdapterObjects((obj) => {
for(let id in obj) {
if(id.endsWith('.online') && obj[id].type == 'state') {
}
}
});
}
// *******************************************************************************

@@ -1176,2 +1282,3 @@ //

main();
isShellyOnine();
});

@@ -1221,3 +1328,2 @@ });

function main() {
objectHelper.init(adapter);

@@ -1247,5 +1353,7 @@ setConnected(false);

shelly.getDeviceDescription(deviceId, (err, deviceId, description, ip) => {
createShellyStates(deviceId, description, ip);
updateShellyStates(deviceId);
pollStates(deviceId);
createShellyStates(deviceId, description, ip, status);
updateShellyStates(deviceId, status);
if(!deviceId.startsWith('SHHT')) {
pollStates(deviceId);
}
objectHelper.processObjectQueue(() => {

@@ -1258,4 +1366,4 @@ adapter.log.debug('Initialize device ' + deviceId + ' (' + Object.keys(knownDevices).length + ' now known)');

}
updateShellyStates(deviceId);
// objectHelper.processObjectQueue(() => { });
updateShellyStates(deviceId, status);
objectHelper.processObjectQueue(() => { });
});

@@ -1262,0 +1370,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc