Skip to content

Commit

Permalink
Updating gateway to use setRawProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
aholstenson committed May 14, 2017
1 parent 07d65c1 commit 16e4933
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions lib/devices/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
}

Expand Down

0 comments on commit 16e4933

Please sign in to comment.