From 32c21f82eb50cd5a4abc3dd01adc82485dea8798 Mon Sep 17 00:00:00 2001 From: Darius Date: Tue, 18 Nov 2025 01:03:24 +0100 Subject: [PATCH] Generic Commit; Most likely a fix or small feature --- dist/homeassistant.d.ts | 5 +++++ dist/homeassistant.d.ts.map | 2 +- dist/timehelper.d.ts | 4 ++++ dist/timehelper.d.ts.map | 2 +- dist/timehelper.js | 8 ++++++++ src/homeassistant.ts | 6 ++++++ src/timehelper.ts | 12 ++++++++++++ 7 files changed, 37 insertions(+), 2 deletions(-) diff --git a/dist/homeassistant.d.ts b/dist/homeassistant.d.ts index 4032f4b..8add6d5 100644 --- a/dist/homeassistant.d.ts +++ b/dist/homeassistant.d.ts @@ -22,4 +22,9 @@ export interface HomeAssistantDeskPositionResult { asBoolean: boolean; asText: () => string; } +export type API_HA_DeskPosition = { + position: string; + isStanding: boolean; + standingTime: string; +}; //# sourceMappingURL=homeassistant.d.ts.map \ No newline at end of file diff --git a/dist/homeassistant.d.ts.map b/dist/homeassistant.d.ts.map index 5fcc155..3aed51b 100644 --- a/dist/homeassistant.d.ts.map +++ b/dist/homeassistant.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACV,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;KACxB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB"} \ No newline at end of file +{"version":3,"file":"homeassistant.d.ts","sourceRoot":"","sources":["../src/homeassistant.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE;QACV,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;KACxB,CAAC;IACF,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE;QACP,EAAE,EAAE,MAAM,CAAC;QACX,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;KACxB,CAAC;CACH,CAAC;AAEF,MAAM,WAAW,+BAA+B;IAC9C,GAAG,EAAE,mBAAmB,CAAC;IACzB,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"} \ No newline at end of file diff --git a/dist/timehelper.d.ts b/dist/timehelper.d.ts index ff1a0be..1a69c6d 100644 --- a/dist/timehelper.d.ts +++ b/dist/timehelper.d.ts @@ -5,5 +5,9 @@ export declare class TimeSpan { private parseTime; contains(timestamp?: number): boolean; } +export declare function calculateSecondsBetween(start: number, end: number): { + seconds: number; + toReadable: (roundToMinutes?: boolean) => string; +}; export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string; //# sourceMappingURL=timehelper.d.ts.map \ No newline at end of file diff --git a/dist/timehelper.d.ts.map b/dist/timehelper.d.ts.map index b339475..0ae5c77 100644 --- a/dist/timehelper.d.ts.map +++ b/dist/timehelper.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"} \ No newline at end of file +{"version":3,"file":"timehelper.d.ts","sourceRoot":"","sources":["../src/timehelper.ts"],"names":[],"mappings":"AAAA,qBAAa,QAAQ;IACnB,OAAO,CAAC,KAAK,CAAqC;IAClD,OAAO,CAAC,GAAG,CAAqC;gBAEpC,WAAW,EAAE,MAAM;IAM/B,OAAO,CAAC,SAAS;IAKjB,QAAQ,CAAC,SAAS,GAAE,MAAmB,GAAG,OAAO;CAgBlD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAA;CAAE,CAOvE;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"} \ No newline at end of file diff --git a/dist/timehelper.js b/dist/timehelper.js index 83ced22..97792e4 100644 --- a/dist/timehelper.js +++ b/dist/timehelper.js @@ -1,6 +1,7 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TimeSpan = void 0; +exports.calculateSecondsBetween = calculateSecondsBetween; exports.secondsToReadable = secondsToReadable; class TimeSpan { constructor(timeSpanStr) { @@ -28,6 +29,13 @@ class TimeSpan { } } exports.TimeSpan = TimeSpan; +function calculateSecondsBetween(start, end) { + const seconds = Math.max(60, (end - start) / 1000); + return { + seconds, + toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes), + }; +} function secondsToReadable(secs, roundToMinutes = false) { const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs; var days = Math.floor(totalSeconds / (3600 * 24)); diff --git a/src/homeassistant.ts b/src/homeassistant.ts index 10d1922..09bd621 100644 --- a/src/homeassistant.ts +++ b/src/homeassistant.ts @@ -23,3 +23,9 @@ export interface HomeAssistantDeskPositionResult { asBoolean: boolean; asText: () => string; } + +export type API_HA_DeskPosition = { + position: string; + isStanding: boolean; + standingTime: string; +}; diff --git a/src/timehelper.ts b/src/timehelper.ts index e84c8d6..2b9e301 100644 --- a/src/timehelper.ts +++ b/src/timehelper.ts @@ -31,6 +31,18 @@ export class TimeSpan { } } +export function calculateSecondsBetween( + start: number, + end: number, +): { seconds: number; toReadable: (roundToMinutes?: boolean) => string } { + const seconds = Math.max(60, (end - start) / 1000); + return { + seconds, + toReadable: (roundToMinutes?: boolean) => + secondsToReadable(seconds, roundToMinutes), + }; +} + export function secondsToReadable( secs: number, roundToMinutes: boolean = false,