homebridge-klikaanklikuit
Advanced tools
Comparing version 1.0.0 to 1.1.0
17
index.js
@@ -49,7 +49,16 @@ 'use strict'; | ||
this.service = new Service[config.type](config.name); | ||
let lastCall = null; | ||
let previousState = null; | ||
this.service.getCharacteristic(Characteristic.On).on('set', (value, callback) => { | ||
if (value === previousState) return callback(); | ||
previousState = value; | ||
// If a device is dimmable, we have to prevent the `on` command to be | ||
// sent too often. Otherwise, the device may end up in dimming mode | ||
// (which we don't want). | ||
if (config.dimmable && value) { | ||
// Wait at least two seconds between `on` calls to accept a new one. | ||
if (lastCall && Date.now() - lastCall < 2000) { | ||
log(`throttling "on" calls for dimmable '${ config.name }'`); | ||
return callback(); | ||
} | ||
lastCall = Date.now(); | ||
} | ||
log(`switching ${ config.type.toLowerCase() } '${ config.name }' (address = ${ config.address }, device = ${ config.device }) ${ value ? 'on' : 'off' }`); | ||
@@ -71,3 +80,3 @@ driver.switch(config.address, config.device, value); | ||
previousLevel = level; | ||
// Dim the device. | ||
@@ -74,0 +83,0 @@ log(`dimming ${ config.type.toLowerCase() } '${ config.name }' (address = ${ config.address }, device = ${ config.device }) to level ${ level }`); |
{ | ||
"name": "homebridge-klikaanklikuit", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Homebridge plugin for KlikAanKlikUit™", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
# Homebridge KlikAanKlikUit plugin | ||
This is a plugin for [Homebridge](https://github.com/nfarina/homebridge) to allow controlling your KlikAanKlikUit devices. This plugin is meant to run on Raspberry Pi's (or boards with a similar GPIO setup). My own setup is based [on this blogpost](http://weejewel.tweakblogs.net/blog/8665/lampen-schakelen-met-een-raspberry-pi). | ||
This is a plugin for [Homebridge](https://github.com/nfarina/homebridge) to allow controlling your KlikAanKlikUit devices. This plugin is meant to run on Raspberry Pi's (or boards with a similar GPIO setup), using a cheap 433Mhz transmitter (see [this page](http://shop.ninjablocks.com/blogs/how-to/7506204-adding-433-to-your-raspberry-pi) for more information on how to connect the transmitter to your Raspberry Pi). | ||
**DISCLAIMER**: this plugin is not in any way endorsed by, or related to, COCO International B.V. or Trust International B.V. | ||
## Installation | ||
@@ -6,0 +8,0 @@ |
7554
128
60