diff --git a/lib/devices/gateway.js b/lib/devices/gateway.js index 5c9637e..82d7c62 100644 --- a/lib/devices/gateway.js +++ b/lib/devices/gateway.js @@ -71,28 +71,29 @@ class Gateway extends Device { this.type = Gateway.TYPE; this._devices = {}; + + this.defineProperty('illumination', { + name: 'illuminance' + }); + + this.defineProperty('rgb', { + handler: (result, rgba) => { + result['rgb'] = { + red: 0xff & (rgba >> 16), + green: 0xff & (rgba >> 8), + blue: 0xff & rgba + }; + result['brightness'] = Math.round(0xff & (rgba >> 24)); + } + }); + + // Monitor every minute right now + this._monitorInterval = 60 * 1000; } _report(properties) { Object.keys(properties).forEach(key => { - switch(key) { - case 'illumination': - // TODO: What scale does this actually have? Lux? - this.setProperty('illuminance', properties[key]); - break; - case 'rgb': - { - const rgba = properties[key]; - - this.setProperty('rgb', { - red: 0xff & (rgba >> 16), - green: 0xff & (rgba >> 8), - blue: 0xff & rgba - }); - this.setProperty('brightness', Math.round((0xff & (rgba >> 24)) )); - break; - } - } + this.setRawProperty(key, properties[key]); }); }