Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Erikvl87 committed Sep 27, 2024
1 parent 84ca023 commit 4142205
Show file tree
Hide file tree
Showing 5 changed files with 102 additions and 6 deletions.
50 changes: 50 additions & 0 deletions @types/my-extensions/homey-lib.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
declare module 'homey-lib' {
export class HomeyLib {
static getLocales(): unknown;
static getCategories(): unknown;
static getPermissions(): unknown;
static getBrandColor(): unknown;
}

export class Device {
static getClasses(): Record<string, unknown>;
static getClass(id: string): unknown;
static getCapabilities(): unknown;
}

export class Capability {
static getCapabilities(): unknown;
static getCapability(id: string): unknown;
static hasCapability(id: string): boolean;
}

export class Signal {
// Define Signal class methods and properties if available
}

export class Media {
static getCodecs(): unknown;
}

export class Energy {
static getCurrencies(): unknown;
static getBatteries(): unknown;
}

export function getDeviceClasses(): Record<string, unknown>;
export function getDeviceClass(id: string): unknown;

export function getCapabilities(): unknown;
export function getCapability(id: string): unknown;
export function hasCapability(id: string): boolean;

export function getAppLocales(): unknown;
export function getAppCategories(): unknown;
export function getAppPermissions(): unknown;
export function getAppBrandColor(): unknown;

export function getMediaCodecs(): unknown;

export function getCurrencies(): unknown;
export function getBatteries(): unknown;
}
3 changes: 3 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ConditionCardEvaluateSensorCapabilities from './lib/ConditionCardEvaluate
import ConditionCardZoneActiveForMinutes from './lib/ConditionCardZoneActiveForMinutes';
import TriggerCardAnyDeviceTurnedOn from './lib/TriggerCardAnyDeviceOnOff';
import ZonesDb from './lib/ZonesDb';
import { DeviceClassManager } from './lib/DeviceClassManager';

class ZoneActivity extends Homey.App {
/**
Expand All @@ -28,6 +29,8 @@ class ZoneActivity extends Homey.App {
homey: this.homey,
});

const deviceClasses = DeviceClassManager.getAllDeviceClasses2();
this.log('Device classes:', deviceClasses);
const zonesDb = await ZonesDb.initialize(this.homeyApi, this.log);
await ConditionCardAnyDeviceTurnedOn.initialize(this.homey, this.homeyApi, zonesDb, this.log);
await ConditionCardZoneInactiveForMinutes.initialize(this.homey, this.homeyApi, zonesDb, this.log); // Deprecated
Expand Down
5 changes: 5 additions & 0 deletions lib/DeviceClassManager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import HomeyLib from 'homey-lib';
type DeviceClass = {
id: string;
friendlyName: string;
Expand Down Expand Up @@ -301,4 +302,8 @@ export class DeviceClassManager {
static getAllDeviceClasses(): { [key: string]: DeviceClass } {
return this.deviceClasses;
}

static getAllDeviceClasses2(): Record<string, unknown> {
return HomeyLib.Device.getClasses();
}
}
49 changes: 43 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"homey-api": "^3.6.2",
"homey-lib": "^2.32.5",
"homey-log": "^2.1.0"
}
}

0 comments on commit 4142205

Please sign in to comment.