Socket
Socket
Sign inDemoInstall

@tritter/homebridge-shelly

Package Overview
Dependencies
110
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.19.6 to 0.20.0

abilities/stateless-window-covering.js

13

accessories/factory.js

@@ -55,2 +55,3 @@

Shelly2WindowCoveringAccessory,
ShellyUniWindowCoveringAccessory
} = require('./window-coverings')(homebridge)

@@ -575,4 +576,16 @@

get numberOfAccessories() {
if (this.config.type === 'windowCovering') {
return 1
}
return 2
}
_createAccessory(accessoryType, index, config, log) {
if (this.config.type === 'windowCovering') {
return new ShellyUniWindowCoveringAccessory(
this.device, config, log)
}
return super._createAccessory(accessoryType, index, config, log)
}
}

@@ -579,0 +592,0 @@ FACTORIES.set('SHUNI-1', ShellyUniFactory)

44

accessories/window-coverings.js

@@ -6,3 +6,6 @@

require('../abilities/window-covering')(homebridge)
const { ShellyAccessory } = require('./base')(homebridge)
const StatelessWindowCoveringAbility =
require('../abilities/stateless-window-covering')(homebridge)
const { ShellyAccessory } =
require('./base')(homebridge)

@@ -34,5 +37,44 @@ class Shelly2WindowCoveringAccessory extends ShellyAccessory {

class ShellyUniWindowCoveringAccessory extends ShellyAccessory {
constructor(device, config, log) {
super('windowCovering', device, null, config, log)
this._relayDownIndex = 0
this._relayUpIndex = 1
const clearTimeout = config.clearTimeout || 60
this.abilities.push(new StatelessWindowCoveringAbility(
'relay' + this._relayDownIndex,
'relay' + this._relayUpIndex,
this.setPosition.bind(this),
clearTimeout
))
}
get category() {
return Accessory.Categories.WINDOW_COVERING
}
/**
* Sets the current position to the new value.
* @returns {Promise} A Promise that resolves when the position has been
* updated.
*/
setPosition(newValue) {
if (newValue < 50) {
return Promise.all([this.device.setRelay(this._relayUpIndex, false),
this.device.setRelay(this._relayDownIndex, true)])
} else if (newValue > 50) {
return Promise.all([this.device.setRelay(this._relayDownIndex, false),
this.device.setRelay(this._relayUpIndex, true)])
} else {
return Promise.all([this.device.setRelay(this._relayUpIndex, false),
this.device.setRelay(this._relayDownIndex, false)])
}
}
}
return {
Shelly2WindowCoveringAccessory,
ShellyUniWindowCoveringAccessory
}
}

@@ -146,2 +146,8 @@ {

},
"clearTimeout": {
"title": "Stateless Clear Timeout",
"type": "number",
"default": 60,
"description": "Sets a timeout at which the position of stateless windowCovering will be resetted to 50% (only windowCovering with Shelly Uni)."
},
"username": {

@@ -229,2 +235,6 @@ "title": "Username",

{
"key": "devices[].clearTimeout",
"condition": { "functionBody": "return model.devices && model.devices[arrayIndices[0]].type === 'windowCovering'" }
},
{
"key": "devices[]",

@@ -231,0 +241,0 @@ "type": "section",

2

package.json
{
"name": "@tritter/homebridge-shelly",
"version": "0.19.6",
"version": "0.20.0",
"description": "Shelly plugin for Homebridge",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc