@@ -180,6 +180,30 @@ Light.prototype.colorRgbHex = function(hexString, duration, callback) {
180180 this . color ( hsbObj . h , hsbObj . s , hsbObj . b , 3500 , duration , callback ) ;
181181} ;
182182
183+ /**
184+ * Sets the Maximum Infrared brightness
185+ * @param {Number } brightness infrared brightness from 0 - 100 (in %)
186+ * @param {Function } [callback] called when light did receive message
187+ */
188+ Light . prototype . maxIR = function ( brightness , callback ) {
189+ if ( typeof brightness !== 'number' || brightness < constants . IR_MINIMUM_BRIGHTNESS || brightness > constants . IR_MAXIMUM_BRIGHTNESS ) {
190+ throw new RangeError ( 'LIFX light setMaxIR method expects brightness to be a number between ' +
191+ constants . IR_MINIMUM_BRIGHTNESS + ' and ' + constants . IR_MAXIMUM_BRIGHTNESS
192+ ) ;
193+ }
194+ brightness = Math . round ( brightness / constants . IR_MAXIMUM_BRIGHTNESS * 65535 ) ;
195+
196+ if ( callback !== undefined && typeof callback !== 'function' ) {
197+ throw new TypeError ( 'LIFX light setMaxIR method expects callback to be a function' ) ;
198+ }
199+
200+ var packetObj = packet . create ( 'setInfrared' , {
201+ brightness : brightness
202+ } , this . client . source ) ;
203+ packetObj . target = this . id ;
204+ this . client . send ( packetObj , callback ) ;
205+ } ;
206+
183207/**
184208 * Requests the current state of the light
185209 * @param {Function } callback a function to accept the data
@@ -211,6 +235,28 @@ Light.prototype.getState = function(callback) {
211235 } , sqnNumber ) ;
212236} ;
213237
238+ /**
239+ * Requests the current maximum setting for the infrared channel
240+ * @param {Function } callback a function to accept the data
241+ */
242+ Light . prototype . getMaxIR = function ( callback ) {
243+ if ( typeof callback !== 'function' ) {
244+ throw new TypeError ( 'LIFX light getMaxIR method expects callback to be a function' ) ;
245+ }
246+ var packetObj = packet . create ( 'getInfrared' , { } , this . client . source ) ;
247+ packetObj . target = this . id ;
248+ var sqnNumber = this . client . send ( packetObj ) ;
249+ this . client . addMessageHandler ( 'stateInfrared' , function ( err , msg ) {
250+ if ( err ) {
251+ return callback ( err , null ) ;
252+ }
253+
254+ msg . brightness = Math . round ( msg . brightness * ( constants . HSBK_MAXIMUM_BRIGHTNESS / 65535 ) ) ;
255+
256+ callback ( null , msg . brightness ) ;
257+ } , sqnNumber ) ;
258+ } ;
259+
214260/**
215261 * Requests hardware info from the light
216262 * @param {Function } callback a function to accept the data with error and
@@ -227,13 +273,15 @@ Light.prototype.getHardwareVersion = function(callback) {
227273 if ( err ) {
228274 return callback ( err , null ) ;
229275 }
230- callback ( null , _ . pick ( msg , [
276+ var versionInfo = _ . pick ( msg , [
231277 'vendorId' ,
232- 'vendorName' ,
233278 'productId' ,
234- 'productName' ,
235279 'version'
236- ] ) ) ;
280+ ] ) ;
281+ callback ( null , _ . assign (
282+ versionInfo ,
283+ utils . getHardwareDetails ( versionInfo . vendorId , versionInfo . productId )
284+ ) ) ;
237285 } , sqnNumber ) ;
238286} ;
239287
0 commit comments