Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16c262f2c4 | ||
|
|
dfa93723ef | ||
|
|
59900bf294 | ||
|
|
1ab38c4c87 | ||
|
|
b47db3cf05 | ||
|
|
32c21f82eb |
7
dist/homeassistant.d.ts
vendored
7
dist/homeassistant.d.ts
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
import { TimeBetween } from "./timehelper";
|
||||||
export type HomeAssistantEntity = {
|
export type HomeAssistantEntity = {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
state: string;
|
state: string;
|
||||||
@@ -21,5 +22,11 @@ export interface HomeAssistantDeskPositionResult {
|
|||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
asBoolean: boolean;
|
asBoolean: boolean;
|
||||||
asText: () => string;
|
asText: () => string;
|
||||||
|
standingTime: TimeBetween;
|
||||||
}
|
}
|
||||||
|
export type API_HA_DeskPosition = {
|
||||||
|
position: string;
|
||||||
|
isStanding: boolean;
|
||||||
|
standingTime: string;
|
||||||
|
};
|
||||||
//# sourceMappingURL=homeassistant.d.ts.map
|
//# sourceMappingURL=homeassistant.d.ts.map
|
||||||
2
dist/homeassistant.d.ts.map
vendored
2
dist/homeassistant.d.ts.map
vendored
@@ -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,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C;IACjB,UAAU,EAAE,OAAO,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
||||||
5
dist/timehelper.d.ts
vendored
5
dist/timehelper.d.ts
vendored
@@ -5,5 +5,10 @@ export declare class TimeSpan {
|
|||||||
private parseTime;
|
private parseTime;
|
||||||
contains(timestamp?: number): boolean;
|
contains(timestamp?: number): boolean;
|
||||||
}
|
}
|
||||||
|
export interface TimeBetween {
|
||||||
|
seconds: number;
|
||||||
|
toReadable: (roundToMinutes?: boolean) => string;
|
||||||
|
}
|
||||||
|
export declare function calculateSecondsBetween(start: number, end: number): TimeBetween;
|
||||||
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
|
export declare function secondsToReadable(secs: number, roundToMinutes?: boolean): string;
|
||||||
//# sourceMappingURL=timehelper.d.ts.map
|
//# sourceMappingURL=timehelper.d.ts.map
|
||||||
2
dist/timehelper.d.ts.map
vendored
2
dist/timehelper.d.ts.map
vendored
@@ -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"}
|
{"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,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,KAAK,MAAM,CAAC;CAClD;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,GACV,WAAW,CAOb;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,cAAc,GAAE,OAAe,GAC9B,MAAM,CAmBR"}
|
||||||
8
dist/timehelper.js
vendored
8
dist/timehelper.js
vendored
@@ -1,6 +1,7 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.TimeSpan = void 0;
|
exports.TimeSpan = void 0;
|
||||||
|
exports.calculateSecondsBetween = calculateSecondsBetween;
|
||||||
exports.secondsToReadable = secondsToReadable;
|
exports.secondsToReadable = secondsToReadable;
|
||||||
class TimeSpan {
|
class TimeSpan {
|
||||||
constructor(timeSpanStr) {
|
constructor(timeSpanStr) {
|
||||||
@@ -28,6 +29,13 @@ class TimeSpan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.TimeSpan = 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) {
|
function secondsToReadable(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));
|
var days = Math.floor(totalSeconds / (3600 * 24));
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.7",
|
"version": "1.0.10",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.7",
|
"version": "1.0.10",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.7.9",
|
"axios": "^1.7.9",
|
||||||
"chalk": "^5.6.2"
|
"chalk": "^5.6.2"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@dpu/shared",
|
"name": "@dpu/shared",
|
||||||
"version": "1.0.7",
|
"version": "1.0.10",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { TimeBetween } from "./timehelper";
|
||||||
|
|
||||||
export type HomeAssistantEntity = {
|
export type HomeAssistantEntity = {
|
||||||
entity_id: string;
|
entity_id: string;
|
||||||
state: string;
|
state: string;
|
||||||
@@ -22,4 +24,11 @@ export interface HomeAssistantDeskPositionResult {
|
|||||||
raw: HomeAssistantEntity;
|
raw: HomeAssistantEntity;
|
||||||
asBoolean: boolean;
|
asBoolean: boolean;
|
||||||
asText: () => string;
|
asText: () => string;
|
||||||
|
standingTime: TimeBetween;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type API_HA_DeskPosition = {
|
||||||
|
position: string;
|
||||||
|
isStanding: boolean;
|
||||||
|
standingTime: string;
|
||||||
|
};
|
||||||
|
|||||||
@@ -31,6 +31,23 @@ export class TimeSpan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface TimeBetween {
|
||||||
|
seconds: number;
|
||||||
|
toReadable: (roundToMinutes?: boolean) => string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function calculateSecondsBetween(
|
||||||
|
start: number,
|
||||||
|
end: number,
|
||||||
|
): TimeBetween {
|
||||||
|
const seconds = Math.max(60, (end - start) / 1000);
|
||||||
|
return {
|
||||||
|
seconds,
|
||||||
|
toReadable: (roundToMinutes?: boolean) =>
|
||||||
|
secondsToReadable(seconds, roundToMinutes),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function secondsToReadable(
|
export function secondsToReadable(
|
||||||
secs: number,
|
secs: number,
|
||||||
roundToMinutes: boolean = false,
|
roundToMinutes: boolean = false,
|
||||||
|
|||||||
Reference in New Issue
Block a user