Compare commits

...

10 Commits

Author SHA1 Message Date
Darius
4ed43fc8a0 1.9.5 2026-02-08 14:49:04 +01:00
Darius
78f5e4a313 fix ha update ....... build 2026-02-08 14:48:58 +01:00
Darius
e32afa0f70 fix ha update 2026-02-08 14:48:44 +01:00
Darius
405ebe1e8e 1.9.4 2026-02-08 14:36:16 +01:00
Darius
1fb937973c add HA Update 2026-02-08 14:36:11 +01:00
Darius
9688c9581a 1.9.3 2026-02-08 12:52:36 +01:00
Darius
6b4bd73b14 build... 2026-02-08 12:52:31 +01:00
Darius
e834725b1a make stuff more refined 2026-02-08 12:52:19 +01:00
Darius
e6a7262cf7 1.9.2 2026-02-08 10:16:43 +01:00
Darius
850eb74210 forgot build 2026-02-08 10:16:38 +01:00
12 changed files with 55 additions and 24 deletions

2
dist/fastify.d.ts vendored
View File

@@ -17,6 +17,6 @@ export declare abstract class BaseService<T> {
constructor(client: T); constructor(client: T);
getClient(): T; getClient(): T;
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>; getSuccessfulResult<R = unknown>(result: R): ServiceResult<R>;
getErrorResult(error: string): ServiceResult<string>; getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string>;
} }
//# sourceMappingURL=fastify.d.ts.map //# sourceMappingURL=fastify.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,SAAS;IACF,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,8BAAsB,UAAU;IAC/B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAIxC,QAAQ,IAAI,aAAa;CAGzB;AAED,8BAAsB,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,SAAS,IAAI,CAAC;IAId,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC;CAOpD"} {"version":3,"file":"fastify.d.ts","sourceRoot":"","sources":["../src/fastify.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,MAAM,EAAE,CAAC,CAAC;IACV,UAAU,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,qBAAa,SAAS;IACF,KAAK,EAAE,MAAM;gBAAb,KAAK,EAAE,MAAM;CAChC;AAED,8BAAsB,UAAU;IAC/B,OAAO,CAAC,aAAa,CAAgB;gBAEzB,aAAa,EAAE,aAAa;IAIxC,QAAQ,IAAI,aAAa;CAGzB;AAED,8BAAsB,WAAW,CAAC,CAAC;IAClC,OAAO,CAAC,MAAM,CAAI;gBAEN,MAAM,EAAE,CAAC;IAIrB,SAAS,IAAI,CAAC;IAId,mBAAmB,CAAC,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC;IAO7D,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC;CAO5E"}

6
dist/fastify.js vendored
View File

@@ -28,10 +28,10 @@ export class BaseService {
successful: true, successful: true,
}; };
} }
getErrorResult(error) { getErrorResult(errorMessage, error) {
logWarning(error); logWarning(errorMessage);
return { return {
result: error, result: errorMessage,
successful: false, successful: false,
}; };
} }

View File

@@ -28,4 +28,16 @@ export type API_HA_DeskPosition = {
last_changed: string; last_changed: string;
last_changed_seconds: number; last_changed_seconds: number;
}; };
export type HA_Update = {
entity_id: string;
state: string;
attributes: {
state_class?: string;
unit_of_measurement?: string;
icon?: string;
friendly_name?: string;
[key: string]: unknown;
};
timestamp: string;
};
//# sourceMappingURL=homeassistant.d.ts.map //# sourceMappingURL=homeassistant.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAEhD,MAAM,MAAM,mBAAmB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACX,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACR,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACF,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC/C,GAAG,EAAE,mBAAmB,CAAC;IACzB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,WAAW,CAAC;CAC1B;AAED,MAAM,MAAM,mBAAmB,GAAG;IACjC,WAAW,EAAE,OAAO,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,oBAAoB,EAAE,MAAM,CAAC;CAC7B,CAAC"} {"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassist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,CAAC;CAClB,CAAC"}

View File

@@ -11,5 +11,6 @@ export interface TimeBetween {
toReadable: (roundToMinutes?: boolean) => string; toReadable: (roundToMinutes?: boolean) => string;
} }
export declare function calculateSecondsBetween(start: number, end: number): TimeBetween; export declare function calculateSecondsBetween(start: number, end: number): TimeBetween;
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string; export declare function formatSecondsToDHMS(secs: number, roundToMinutes?: boolean): string;
export declare function formatSecondsToMS(s: number): string;
//# sourceMappingURL=timehelper.d.ts.map //# sourceMappingURL=timehelper.d.ts.map

View File

@@ -1 +1 @@
{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACpB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBjD;AAED,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CACjD;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,WAAW,CAOb;AAED,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC7B,MAAM,CAmBR"} {"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACpB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;IAChD,OAAO,CAAC,QAAQ,CAAC;gBAEL,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAOjD,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAqBjD;AAED,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CACjD;AAED,wBAAgB,uBAAuB,CACtC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACT,WAAW,CAOb;AAED,wBAAgB,mBAAmB,CAClC,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC7B,MAAM,CAmBR;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAInD"}

25
dist/timehelper.js vendored
View File

@@ -36,18 +36,23 @@ export function calculateSecondsBetween(start, end) {
const seconds = Math.max(60, (end - start) / 1000); const seconds = Math.max(60, (end - start) / 1000);
return { return {
seconds, seconds,
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes), toReadable: (roundToMinutes) => formatSecondsToDHMS(seconds, roundToMinutes),
}; };
} }
export function secondsToReadable(secs, roundToMinutes = false) { export function formatSecondsToDHMS(secs, roundToMinutes = false) {
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs; const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
var days = Math.floor(totalSeconds / (3600 * 24)); const days = Math.floor(totalSeconds / (3600 * 24));
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600); const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
var minutes = Math.floor((totalSeconds % 3600) / 60); const minutes = Math.floor((totalSeconds % 3600) / 60);
var seconds = Math.floor(totalSeconds % 60); const seconds = Math.floor(totalSeconds % 60);
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : ""; const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
var hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : ""; const hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
var minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : ""; const minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
var secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : ""; const secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, ""); return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
} }
export function formatSecondsToMS(s) {
const mins = Math.floor(s / 60);
const secs = s % 60;
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
}

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.9.1", "version": "1.9.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.9.1", "version": "1.9.5",
"dependencies": { "dependencies": {
"@types/ws": "^8.18.1", "@types/ws": "^8.18.1",
"axios": "^1.7.9", "axios": "^1.7.9",

View File

@@ -1,6 +1,6 @@
{ {
"name": "@dpu/shared", "name": "@dpu/shared",
"version": "1.9.1", "version": "1.9.5",
"description": "", "description": "",
"main": "dist/index.js", "main": "dist/index.js",
"types": "dist/index.d.ts", "types": "dist/index.d.ts",

View File

@@ -40,10 +40,10 @@ export abstract class BaseService<T> {
}; };
} }
getErrorResult(error: string): ServiceResult<string> { getErrorResult(errorMessage: string, error?: unknown): ServiceResult<string> {
logWarning(error); logWarning(errorMessage);
return { return {
result: error, result: errorMessage,
successful: false, successful: false,
}; };
} }

View File

@@ -31,3 +31,16 @@ export type API_HA_DeskPosition = {
last_changed: string; last_changed: string;
last_changed_seconds: number; last_changed_seconds: number;
}; };
export type HA_Update = {
entity_id: string;
state: string;
attributes: {
state_class?: string;
unit_of_measurement?: string;
icon?: string;
friendly_name?: string;
[key: string]: unknown;
};
timestamp: string; // datetime string
};