Only updating wiz bulb if pilot is not undefined
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				continuous-integration/drone/push Build is passing
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	continuous-integration/drone/push Build is passing
				
			This commit is contained in:
		| @@ -130,6 +130,8 @@ export class FluxAccessory { | |||||||
|             .on("set", this.onSetEnabled) |             .on("set", this.onSetEnabled) | ||||||
|             //@ts-ignore |             //@ts-ignore | ||||||
|             .on("get", this.onGetEnabled); |             .on("get", this.onGetEnabled); | ||||||
|  |  | ||||||
|  |         this.test(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public name: string = "Flux"; |     public name: string = "Flux"; | ||||||
| @@ -320,6 +322,9 @@ export class FluxAccessory { | |||||||
|         } catch (err: any) { |         } catch (err: any) { | ||||||
|             this._platform.log.error(err.message); |             this._platform.log.error(err.message); | ||||||
|         } |         } | ||||||
|  |         if (!pilot) { | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|         this._platform.log.info(`Adjusting wiz bulb: ${wizBulb.getMac()}`); |         this._platform.log.info(`Adjusting wiz bulb: ${wizBulb.getMac()}`); | ||||||
|         wizBulb.set(this._wizRGB, pilot?.state ? pilot.dimming : 0, this._fade); |         wizBulb.set(this._wizRGB, pilot?.state ? pilot.dimming : 0, this._fade); | ||||||
|     }; |     }; | ||||||
| @@ -359,4 +364,23 @@ export class FluxAccessory { | |||||||
|     private disable() { |     private disable() { | ||||||
|         this._tasks.forEach((task) => task.stop()); |         this._tasks.forEach((task) => task.stop()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private test = async () => { | ||||||
|  |         for (let i = 2500; i > 0; i--) { | ||||||
|  |             this._platform.log.info(`i: ${i}`); | ||||||
|  |             for (const wizBulb of this._wizLights) { | ||||||
|  |                 let pilot; | ||||||
|  |                 try { | ||||||
|  |                     pilot = await wizBulb.get(); | ||||||
|  |                 } catch (err: any) { | ||||||
|  |                     this._platform.log.error(err.message); | ||||||
|  |                 } | ||||||
|  |                 this._platform.log.info( | ||||||
|  |                     `Adjusting wiz bulb: ${wizBulb.getMac()}` | ||||||
|  |                 ); | ||||||
|  |                 wizBulb.set(colorTemperature2rgb(i), 100, this._fade); | ||||||
|  |             } | ||||||
|  |             await Sleep(100); | ||||||
|  |         } | ||||||
|  |     }; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user