Skip to content

Commit

Permalink
chore: prettify code
Browse files Browse the repository at this point in the history
  • Loading branch information
milo526 committed May 18, 2021
1 parent a75fc70 commit 41c7303
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
37 changes: 18 additions & 19 deletions src/api/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,21 @@ export type TuyaApiMethod =
| "temperatureSet"
| "turnOnOff"
| "windSpeedSet";
export type TuyaApiPayload<
Method extends TuyaApiMethod
> = Method extends "brightnessSet"
? { value: number }
: Method extends "colorSet"
? { color: { hue: number; saturation: number; brightness: number } }
: Method extends "colorTemperatureSet"
? { value: number }
: Method extends "modeSet"
? { value: ClimateMode }
: Method extends "startStop"
? { value: 0 }
: Method extends "temperatureSet"
? { value: number }
: Method extends "turnOnOff"
? { value: 0 | 1 }
: Method extends "windSpeedSet"
? { value: number }
: never;
export type TuyaApiPayload<Method extends TuyaApiMethod> =
Method extends "brightnessSet"
? { value: number }
: Method extends "colorSet"
? { color: { hue: number; saturation: number; brightness: number } }
: Method extends "colorTemperatureSet"
? { value: number }
: Method extends "modeSet"
? { value: ClimateMode }
: Method extends "startStop"
? { value: 0 }
: Method extends "temperatureSet"
? { value: number }
: Method extends "turnOnOff"
? { value: 0 | 1 }
: Method extends "windSpeedSet"
? { value: number }
: never;
7 changes: 4 additions & 3 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ export type HomebridgeAccessory = PlatformAccessory<
*/
export class TuyaWebPlatform implements DynamicPlatformPlugin {
public readonly Service: typeof Service = this.api.hap.Service;
public readonly Characteristic: typeof Characteristic = this.api.hap
.Characteristic;
public readonly Characteristic: typeof Characteristic =
this.api.hap.Characteristic;

// this is used to track restored cached accessories
public readonly accessories: Map<string, HomebridgeAccessory> = new Map();
Expand Down Expand Up @@ -343,7 +343,8 @@ export class TuyaWebPlatform implements DynamicPlatformPlugin {
continue;
}

configOverwrite.device_type = configOverwrite.device_type.toLowerCase() as TuyaDeviceType;
configOverwrite.device_type =
configOverwrite.device_type.toLowerCase() as TuyaDeviceType;

const device = devices.find(
(device) =>
Expand Down

0 comments on commit 41c7303

Please sign in to comment.