homebridge-homeconnect
Version:
A Homebridge plugin that connects Home Connect appliances to Apple HomeKit
295 lines • 21.9 kB
TypeScript
import { Characteristic, Service } from 'homebridge';
import { ApplianceBase } from './appliance-generic.js';
import { Constructor, Optional } from './utils.js';
import { SettingKV } from './api-value.js';
import { SerialisedOperation } from './serialised.js';
export interface HSV {
hue: number;
saturation: number;
brightness: number;
}
export interface UpdateLightHCValue extends Partial<HSV> {
on?: boolean;
mirek?: number;
}
type UpdateLightHC = SerialisedOperation<UpdateLightHCValue>;
declare const LIGHT_KEY: {
readonly 'Functional Light': {
readonly on: "Cooking.Common.Setting.Lighting";
readonly brightness: "Cooking.Common.Setting.LightingBrightness";
readonly colourtempenum: "Cooking.Hood.Setting.ColorTemperature";
readonly colourtempperc: "Cooking.Hood.Setting.ColorTemperaturePercent";
};
readonly 'Ambient Light': {
readonly on: "BSH.Common.Setting.AmbientLightEnabled";
readonly brightness: "BSH.Common.Setting.AmbientLightBrightness";
readonly colour: "BSH.Common.Setting.AmbientLightColor";
readonly custom: "BSH.Common.Setting.AmbientLightCustomColor";
};
readonly 'Internal Light': {
readonly on: "Refrigeration.Common.Setting.Light.Internal.Power";
readonly brightness: "Refrigeration.Common.Setting.Light.Internal.Brightness";
};
readonly 'External Light': {
readonly on: "Refrigeration.Common.Setting.Light.External.Power";
readonly brightness: "Refrigeration.Common.Setting.Light.External.Brightness";
};
};
type LightType = keyof typeof LIGHT_KEY;
type LightKey<TypeKey extends LightType = LightType> = TypeKey extends TypeKey ? keyof (typeof LIGHT_KEY)[TypeKey] : never;
type LightKeyOptional<Key extends LightKey = LightKey, TypeKey extends LightType = LightType> = TypeKey extends TypeKey ? (Key extends Key ? (Key extends LightKey<TypeKey> ? never : Key) : never) : never;
type LightKeyRequired<Key extends LightKey = LightKey> = Key extends LightKeyOptional ? never : Key;
type LightValue<Key extends LightKey, TypeKey extends LightType = LightType> = TypeKey extends TypeKey ? (Key extends LightKey<TypeKey> ? (typeof LIGHT_KEY)[TypeKey][Key] : never) : never;
type LightKeyDefinition = {
[Key in LightKeyRequired]: LightValue<Key>;
} & {
[Key in LightKeyOptional]?: LightValue<Key>;
};
type LightSettingsBase = {
[Key in LightKey]?: Optional<SettingKV<LightValue<Key>>, 'value'> | null;
};
export type LightSettings<Keys extends LightKey = never> = LightSettingsBase & {
[P in Keys]-?: NonNullable<LightSettingsBase[P]>;
};
export declare function HasLight<TBase extends Constructor<ApplianceBase>>(Base: TBase, lightTypes: LightType[]): {
new (...args: any[]): {
lightService: Service[];
initHasLight(): Promise<void>;
addLightIfSupported(type: string, keys: LightKeyDefinition): Promise<Service | undefined>;
refreshLight(type: string, keys: LightKeyDefinition, settings: LightSettings, active?: boolean): Promise<void>;
addLight(type: string, settings: LightSettings): Service;
updateLightHC(type: string, settings: LightSettings, service: Service, value: UpdateLightHCValue): Promise<void>;
addLightOn(type: string, settings: LightSettings<"on">, service: Service, updateLightHC: UpdateLightHC): void;
setLightOn(type: string, settings: LightSettings<"on">, on: boolean): Promise<void>;
addLightBrightness(type: string, settings: LightSettings<"brightness"> | LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightBrightness(type: string, settings: LightSettings<"brightness">, brightness: number): Promise<void>;
addLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, mirek: number): Promise<void>;
addLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, hue?: number, saturation?: number, value?: number): Promise<void>;
toRGB(hue: number, saturation: number, value: number): string;
fromRGB(rgbHex: string): HSV;
readonly Service: typeof Service;
readonly Characteristic: typeof Characteristic;
readonly config: import("./config-types.js").ApplianceConfig;
readonly schema: import("./homebridge-ui/schema-data.js").ConfigSchemaData;
readonly optionalFeatures: import("./homebridge-ui/schema-data.js").SchemaOptionalFeature[];
readonly cache: import("./persist-cache.js").PersistCache;
readonly cachedOperation: Record<string, string>;
readonly cachedPromise: Map<string, Promise<unknown>>;
readonly asyncInitTasks: {
name: string;
promise: Promise<void>;
}[];
serviceNames: import("./service-name.js").ServiceNames;
readonly accessoryInformationService: Service;
readonly obsoleteServices: Service[];
readonly log: import("homebridge").Logger;
readonly platform: import("./platform.js").HomeConnectPlatform;
readonly device: import("./homeconnect-device.js").HomeConnectDevice;
readonly accessory: import("homebridge").PlatformAccessory;
asyncInitialise(name: string, promise: Promise<void>): void;
waitAsyncInitialisation(): Promise<void>;
makeService(serviceConstructor: typeof Service & {
new (displayName?: string, subtype?: string): Service;
UUID: string;
}, suffix?: string, subtype?: string): Service;
cleanupServices(): void;
cleanupOldVersions(): void;
unregister(): void;
identify(): Promise<void>;
hasOptionalFeature(service: string, name: string, group?: string, enableByDefault?: boolean): boolean;
setOptionalFeatures(): void;
getCached<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
doCachedOperation<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
makeSerialised<Value extends import("./serialised.js").SerialisedValue, Returns = void>(operation: SerialisedOperation<Value, Returns>, defaultValue?: Value): (value?: Value) => Promise<Returns>;
makeSerialisedObject<Value extends object, Returns = void>(operation: SerialisedOperation<Value, Returns>): (value?: Value) => Promise<Returns>;
onSet<Type>(handler: import("./appliance-generic.js").OnSetHandler<Type>, assertIsType: (value: unknown) => asserts value is Type): import("homebridge").CharacteristicSetHandler;
onSetBoolean(handler: import("./appliance-generic.js").OnSetHandler<boolean>): import("homebridge").CharacteristicSetHandler;
onSetNumber(handler: import("./appliance-generic.js").OnSetHandler<number>): import("homebridge").CharacteristicSetHandler;
onSetString(handler: import("./appliance-generic.js").OnSetHandler<string>): import("homebridge").CharacteristicSetHandler;
trap<Type>(when: string, promise: Promise<Type> | Type, canThrow?: boolean): Promise<Type | undefined>;
};
} & TBase;
export declare const HasCleaningLight: <TBase extends Constructor<ApplianceBase>>(Base: TBase) => {
new (...args: any[]): {
lightService: Service[];
initHasLight(): Promise<void>;
addLightIfSupported(type: string, keys: LightKeyDefinition): Promise<Service | undefined>;
refreshLight(type: string, keys: LightKeyDefinition, settings: LightSettings, active?: boolean): Promise<void>;
addLight(type: string, settings: LightSettings): Service;
updateLightHC(type: string, settings: LightSettings, service: Service, value: UpdateLightHCValue): Promise<void>;
addLightOn(type: string, settings: LightSettings<"on">, service: Service, updateLightHC: UpdateLightHC): void;
setLightOn(type: string, settings: LightSettings<"on">, on: boolean): Promise<void>;
addLightBrightness(type: string, settings: LightSettings<"brightness"> | LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightBrightness(type: string, settings: LightSettings<"brightness">, brightness: number): Promise<void>;
addLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, mirek: number): Promise<void>;
addLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, hue?: number, saturation?: number, value?: number): Promise<void>;
toRGB(hue: number, saturation: number, value: number): string;
fromRGB(rgbHex: string): HSV;
readonly Service: typeof Service;
readonly Characteristic: typeof Characteristic;
readonly config: import("./config-types.js").ApplianceConfig;
readonly schema: import("./homebridge-ui/schema-data.js").ConfigSchemaData;
readonly optionalFeatures: import("./homebridge-ui/schema-data.js").SchemaOptionalFeature[];
readonly cache: import("./persist-cache.js").PersistCache;
readonly cachedOperation: Record<string, string>;
readonly cachedPromise: Map<string, Promise<unknown>>;
readonly asyncInitTasks: {
name: string;
promise: Promise<void>;
}[];
serviceNames: import("./service-name.js").ServiceNames;
readonly accessoryInformationService: Service;
readonly obsoleteServices: Service[];
readonly log: import("homebridge").Logger;
readonly platform: import("./platform.js").HomeConnectPlatform;
readonly device: import("./homeconnect-device.js").HomeConnectDevice;
readonly accessory: import("homebridge").PlatformAccessory;
asyncInitialise(name: string, promise: Promise<void>): void;
waitAsyncInitialisation(): Promise<void>;
makeService(serviceConstructor: typeof Service & {
new (displayName?: string, subtype?: string): Service;
UUID: string;
}, suffix?: string, subtype?: string): Service;
cleanupServices(): void;
cleanupOldVersions(): void;
unregister(): void;
identify(): Promise<void>;
hasOptionalFeature(service: string, name: string, group?: string, enableByDefault?: boolean): boolean;
setOptionalFeatures(): void;
getCached<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
doCachedOperation<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
makeSerialised<Value extends import("./serialised.js").SerialisedValue, Returns = void>(operation: SerialisedOperation<Value, Returns>, defaultValue?: Value): (value?: Value) => Promise<Returns>;
makeSerialisedObject<Value extends object, Returns_1 = void>(operation: SerialisedOperation<Value, Returns_1>): (value?: Value) => Promise<Returns_1>;
onSet<Type>(handler: import("./appliance-generic.js").OnSetHandler<Type>, assertIsType: (value: unknown) => asserts value is Type): import("homebridge").CharacteristicSetHandler;
onSetBoolean(handler: import("./appliance-generic.js").OnSetHandler<boolean>): import("homebridge").CharacteristicSetHandler;
onSetNumber(handler: import("./appliance-generic.js").OnSetHandler<number>): import("homebridge").CharacteristicSetHandler;
onSetString(handler: import("./appliance-generic.js").OnSetHandler<string>): import("homebridge").CharacteristicSetHandler;
trap<Type>(when: string, promise: Promise<Type> | Type, canThrow?: boolean): Promise<Type | undefined>;
};
} & TBase;
export declare const HasHoodLight: <TBase extends Constructor<ApplianceBase>>(Base: TBase) => {
new (...args: any[]): {
lightService: Service[];
initHasLight(): Promise<void>;
addLightIfSupported(type: string, keys: LightKeyDefinition): Promise<Service | undefined>;
refreshLight(type: string, keys: LightKeyDefinition, settings: LightSettings, active?: boolean): Promise<void>;
addLight(type: string, settings: LightSettings): Service;
updateLightHC(type: string, settings: LightSettings, service: Service, value: UpdateLightHCValue): Promise<void>;
addLightOn(type: string, settings: LightSettings<"on">, service: Service, updateLightHC: UpdateLightHC): void;
setLightOn(type: string, settings: LightSettings<"on">, on: boolean): Promise<void>;
addLightBrightness(type: string, settings: LightSettings<"brightness"> | LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightBrightness(type: string, settings: LightSettings<"brightness">, brightness: number): Promise<void>;
addLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, mirek: number): Promise<void>;
addLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, hue?: number, saturation?: number, value?: number): Promise<void>;
toRGB(hue: number, saturation: number, value: number): string;
fromRGB(rgbHex: string): HSV;
readonly Service: typeof Service;
readonly Characteristic: typeof Characteristic;
readonly config: import("./config-types.js").ApplianceConfig;
readonly schema: import("./homebridge-ui/schema-data.js").ConfigSchemaData;
readonly optionalFeatures: import("./homebridge-ui/schema-data.js").SchemaOptionalFeature[];
readonly cache: import("./persist-cache.js").PersistCache;
readonly cachedOperation: Record<string, string>;
readonly cachedPromise: Map<string, Promise<unknown>>;
readonly asyncInitTasks: {
name: string;
promise: Promise<void>;
}[];
serviceNames: import("./service-name.js").ServiceNames;
readonly accessoryInformationService: Service;
readonly obsoleteServices: Service[];
readonly log: import("homebridge").Logger;
readonly platform: import("./platform.js").HomeConnectPlatform;
readonly device: import("./homeconnect-device.js").HomeConnectDevice;
readonly accessory: import("homebridge").PlatformAccessory;
asyncInitialise(name: string, promise: Promise<void>): void;
waitAsyncInitialisation(): Promise<void>;
makeService(serviceConstructor: typeof Service & {
new (displayName?: string, subtype?: string): Service;
UUID: string;
}, suffix?: string, subtype?: string): Service;
cleanupServices(): void;
cleanupOldVersions(): void;
unregister(): void;
identify(): Promise<void>;
hasOptionalFeature(service: string, name: string, group?: string, enableByDefault?: boolean): boolean;
setOptionalFeatures(): void;
getCached<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
doCachedOperation<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
makeSerialised<Value extends import("./serialised.js").SerialisedValue, Returns = void>(operation: SerialisedOperation<Value, Returns>, defaultValue?: Value): (value?: Value) => Promise<Returns>;
makeSerialisedObject<Value extends object, Returns_1 = void>(operation: SerialisedOperation<Value, Returns_1>): (value?: Value) => Promise<Returns_1>;
onSet<Type>(handler: import("./appliance-generic.js").OnSetHandler<Type>, assertIsType: (value: unknown) => asserts value is Type): import("homebridge").CharacteristicSetHandler;
onSetBoolean(handler: import("./appliance-generic.js").OnSetHandler<boolean>): import("homebridge").CharacteristicSetHandler;
onSetNumber(handler: import("./appliance-generic.js").OnSetHandler<number>): import("homebridge").CharacteristicSetHandler;
onSetString(handler: import("./appliance-generic.js").OnSetHandler<string>): import("homebridge").CharacteristicSetHandler;
trap<Type>(when: string, promise: Promise<Type> | Type, canThrow?: boolean): Promise<Type | undefined>;
};
} & TBase;
export declare const HasRefrigerationLight: <TBase extends Constructor<ApplianceBase>>(Base: TBase) => {
new (...args: any[]): {
lightService: Service[];
initHasLight(): Promise<void>;
addLightIfSupported(type: string, keys: LightKeyDefinition): Promise<Service | undefined>;
refreshLight(type: string, keys: LightKeyDefinition, settings: LightSettings, active?: boolean): Promise<void>;
addLight(type: string, settings: LightSettings): Service;
updateLightHC(type: string, settings: LightSettings, service: Service, value: UpdateLightHCValue): Promise<void>;
addLightOn(type: string, settings: LightSettings<"on">, service: Service, updateLightHC: UpdateLightHC): void;
setLightOn(type: string, settings: LightSettings<"on">, on: boolean): Promise<void>;
addLightBrightness(type: string, settings: LightSettings<"brightness"> | LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightBrightness(type: string, settings: LightSettings<"brightness">, brightness: number): Promise<void>;
addLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColourTemp(type: string, settings: LightSettings<"colourtempperc"> | LightSettings<"colourtempenum">, mirek: number): Promise<void>;
addLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, updateLightHC: UpdateLightHC): void;
setLightColour(type: string, settings: LightSettings<"colour" | "custom">, service: Service, hue?: number, saturation?: number, value?: number): Promise<void>;
toRGB(hue: number, saturation: number, value: number): string;
fromRGB(rgbHex: string): HSV;
readonly Service: typeof Service;
readonly Characteristic: typeof Characteristic;
readonly config: import("./config-types.js").ApplianceConfig;
readonly schema: import("./homebridge-ui/schema-data.js").ConfigSchemaData;
readonly optionalFeatures: import("./homebridge-ui/schema-data.js").SchemaOptionalFeature[];
readonly cache: import("./persist-cache.js").PersistCache;
readonly cachedOperation: Record<string, string>;
readonly cachedPromise: Map<string, Promise<unknown>>;
readonly asyncInitTasks: {
name: string;
promise: Promise<void>;
}[];
serviceNames: import("./service-name.js").ServiceNames;
readonly accessoryInformationService: Service;
readonly obsoleteServices: Service[];
readonly log: import("homebridge").Logger;
readonly platform: import("./platform.js").HomeConnectPlatform;
readonly device: import("./homeconnect-device.js").HomeConnectDevice;
readonly accessory: import("homebridge").PlatformAccessory;
asyncInitialise(name: string, promise: Promise<void>): void;
waitAsyncInitialisation(): Promise<void>;
makeService(serviceConstructor: typeof Service & {
new (displayName?: string, subtype?: string): Service;
UUID: string;
}, suffix?: string, subtype?: string): Service;
cleanupServices(): void;
cleanupOldVersions(): void;
unregister(): void;
identify(): Promise<void>;
hasOptionalFeature(service: string, name: string, group?: string, enableByDefault?: boolean): boolean;
setOptionalFeatures(): void;
getCached<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
doCachedOperation<Type>(key: string, operation: () => Promise<Type>): Promise<Type>;
makeSerialised<Value extends import("./serialised.js").SerialisedValue, Returns = void>(operation: SerialisedOperation<Value, Returns>, defaultValue?: Value): (value?: Value) => Promise<Returns>;
makeSerialisedObject<Value extends object, Returns_1 = void>(operation: SerialisedOperation<Value, Returns_1>): (value?: Value) => Promise<Returns_1>;
onSet<Type>(handler: import("./appliance-generic.js").OnSetHandler<Type>, assertIsType: (value: unknown) => asserts value is Type): import("homebridge").CharacteristicSetHandler;
onSetBoolean(handler: import("./appliance-generic.js").OnSetHandler<boolean>): import("homebridge").CharacteristicSetHandler;
onSetNumber(handler: import("./appliance-generic.js").OnSetHandler<number>): import("homebridge").CharacteristicSetHandler;
onSetString(handler: import("./appliance-generic.js").OnSetHandler<string>): import("homebridge").CharacteristicSetHandler;
trap<Type>(when: string, promise: Promise<Type> | Type, canThrow?: boolean): Promise<Type | undefined>;
};
} & TBase;
export {};
//# sourceMappingURL=has-light.d.ts.map