Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing types to client events, light properties, product details #45

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 48 additions & 2 deletions src/lifx.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
import { RemoteInfo } from "dgram";
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved

export class Client {

on(event: 'error', listener: (err: Error) => void): this;
on(event: 'message', listener: (msg: Buffer, info: RemoteInfo) => void): this;
on(event: 'listening'): this;
on(event: 'light-offline', listener: (info: Light) => void): this;
on(event: 'light-online', listener: (info: Light) => void): this;
on(event: 'light-new', listener: (info: Light) => void): this;
on(event: 'discovery-completed'): this;

AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved
/**
* Creates a lifx client
* @extends EventEmitter
Expand Down Expand Up @@ -133,6 +143,14 @@ export class Client {

export class Light {

public client : Client;
public id : string;
public address : string;
public port : number;
public label : string;
public status : string;
public seenOnDiscovery : number;
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved

/**
* A representation of a light bulb
* @class
Expand Down Expand Up @@ -317,6 +335,34 @@ export class Light {
reboot(callback: any): void;
}

export interface Product {
vendorName: string;
productName: string;
productFeatures: Features;
productUpgrades: Upgrade[];
}

export interface Features {
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved
hev?: boolean;
color: boolean;
chain: boolean;
matrix: boolean;
relays?: boolean;
buttons?: boolean;
infrared: boolean;
multizone: boolean;
temperature_range?: number[] | null;
extended_multizone?: boolean;
min_ext_mz_firmware?: number;
min_ext_mz_firmware_components?: number[];
}
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved

export interface Upgrade {
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved
major: number;
minor: number;
features: Features;
}

export const constants: {
ACK_REQUIRED_BIT: number;
ADDRESSABLE_BIT: number;
Expand Down Expand Up @@ -457,9 +503,9 @@ export namespace utils {
* hsb integer object
* @param {Number} vendorId id of the vendor
* @param {Number} productId id of the product
* @return {Object|Boolean} product and details vendor details or false if not found
* @return {Product|Boolean} product and details vendor details or false if not found
*/
function getHardwareDetails(vendorId: number, productId: number): Object | boolean;
function getHardwareDetails(vendorId: number, productId: number): Product | boolean;
AdamCoulterOz marked this conversation as resolved.
Show resolved Hide resolved

/**
* Return all ip addresses of the machine
Expand Down
3 changes: 2 additions & 1 deletion src/lifx/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ utils.getHardwareDetails = function(vendorId, productId) {
return {
vendorName: productDetailList[i].name,
productName: productDetailList[i].products[j].name,
productFeatures: productDetailList[i].products[j].features
productFeatures: productDetailList[i].products[j].features,
productUpgrades: productDetailList[i].products[j].upgrades
};
}
}
Expand Down