@reactsaaskit/hue-node-integration
Version:
A TypeScript package for Philips Hue Bridge Api v2 integration for Node.js. Supports esm and cjs
141 lines (137 loc) • 4.35 kB
TypeScript
interface EntertainmentArea {
id: string;
id_v1?: string;
metadata: {
name: string;
};
configuration_type: "screen" | "monitor" | "music" | "3dspace" | "other";
status: "active" | "inactive";
active_streamer?: {
rid: string;
rtype: string;
};
stream_proxy: {
mode: "auto" | "manual";
node: {
rid: string;
rtype: string;
};
};
channels: Array<{
channel_id: number;
position: {
x: number;
y: number;
z: number;
};
members: Array<{
rid: string;
rtype: string;
index: number;
}>;
}>;
service_locations: Array<{
service: {
rid: string;
rtype: string;
};
positions: Array<{
x: number;
y: number;
z: number;
}>;
equalization_factor: number;
}>;
}
declare class HueIntegration {
private apiKey;
private bridgeIp;
private axiosInstance;
private eventSource?;
constructor(apiKey: string, bridgeIp?: string);
connectBridge(appName: string): Promise<any>;
getBridgeInfo(): Promise<any>;
getTemperature(): Promise<any>;
getMLightLevel(): Promise<any>;
getLight(lightId: string): Promise<any>;
getLights(): Promise<any>;
getRooms(): Promise<any[]>;
getScenes(): Promise<any[]>;
setScene(sceneId: string): Promise<boolean>;
setLight(lightId: string, xyColor?: {
x: number;
y: number;
}, isOn?: boolean, brightness?: number, transition?: number): Promise<boolean>;
setGradient(lightId: string, gradientColors: {
x: number;
y: number;
}[], isOn: boolean, brightness: number, transition: number): Promise<boolean>;
setLightPower(lightId: string, isOn: boolean): Promise<boolean>;
setLightColorGradient(lightId: string, gradientColors: {
x: number;
y: number;
}[], brightness: number, transition: number): Promise<boolean>;
setLightColor(lightId: string, xyColor?: {
x: number;
y: number;
}, brightness?: number, transition?: number): Promise<boolean>;
getGroups(): Promise<any[]>;
setGroups(groupIds: string[], brightness?: number, xyColor?: {
x: number;
y: number;
}, isOn?: boolean): Promise<boolean>;
setGroup(groupId: string, brightness?: number, xyColor?: {
x: number;
y: number;
}, isOn?: boolean): Promise<boolean>;
turnOffAllLights(): Promise<boolean>;
turnOffAllLightsExceptPlugs(): Promise<boolean>;
startEventStream(onMessage: (data: any) => void, onError?: (error: any) => void): void;
stopEventStream(): void;
/**
* Retrieve all entertainment-area configurations.
*/
getEntertainmentAreas(): Promise<EntertainmentArea[]>;
}
/**
* HueIntegrationV1 class for Hue API v1.
*
* This class creates an Axios instance pointed to the V1 endpoint
* (http://<bridge_ip>/api/<username>) and exposes methods like connectBridge,
* getLights, getLight, setLight, and setLightPower.
*/
declare class HueIntegrationV1 {
private apiKey;
private bridgeIp;
private axiosInstance;
constructor(apiKey: string, bridgeIp?: string);
/**
* Connects to the Hue Bridge by registering the application.
* This will POST to /api and return the generated username.
*/
connectBridge(appName: string): Promise<string>;
getBridgeInfo(): Promise<any>;
getLights(): Promise<any>;
getLight(lightId: string): Promise<any>;
/**
* Sets the light state using the V1 API.
* Transforms values as needed for Hue API v1.
*/
setLight(lightId: string, xyColor?: {
x: number;
y: number;
}, isOn?: boolean, brightness?: number, transition?: number): Promise<boolean>;
/**
* Sets the gradient on a light using the V1 API.
* Transforms values as needed.
*/
setGradient(lightId: string, gradientColors: {
x: number;
y: number;
}[], isOn: boolean, brightness: number, transition: number): Promise<boolean>;
/**
* Sets the power (on/off) state of a light.
*/
setLightPower(lightId: string, isOn: boolean): Promise<boolean>;
}
export { HueIntegration, HueIntegrationV1 };