homebridge-tryfi 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/types.ts ADDED
@@ -0,0 +1,119 @@
1
+ import { PlatformConfig } from 'homebridge';
2
+
3
+ /**
4
+ * TryFi Platform Configuration
5
+ */
6
+ export interface TryFiPlatformConfig extends PlatformConfig {
7
+ username: string;
8
+ password: string;
9
+ pollingInterval?: number; // seconds, default 60
10
+ escapeAlertType?: 'leak' | 'motion'; // default 'leak'
11
+ ignoredPets?: string[]; // pet names to ignore (case-insensitive)
12
+ }
13
+
14
+ /**
15
+ * TryFi Session Information
16
+ */
17
+ export interface TryFiSession {
18
+ userId: string;
19
+ sessionId: string;
20
+ }
21
+
22
+ /**
23
+ * TryFi Pet Data (processed from API response)
24
+ */
25
+ export interface TryFiPet {
26
+ petId: string;
27
+ name: string;
28
+ breed: string;
29
+ moduleId: string;
30
+ batteryPercent: number;
31
+ isCharging: boolean;
32
+ ledEnabled: boolean;
33
+ mode: string; // 'NORMAL' or 'LOST_DOG'
34
+ connectedToUser: string | null; // firstName of user, null if not connected
35
+ latitude: number;
36
+ longitude: number;
37
+ areaName: string | null;
38
+ placeName: string | null; // Safe zone name, null when not in safe zone
39
+ placeAddress: string | null;
40
+ }
41
+
42
+ /**
43
+ * GraphQL Response Wrapper
44
+ */
45
+ export interface GraphQLResponse<T> {
46
+ data?: T;
47
+ errors?: Array<{
48
+ message: string;
49
+ locations?: Array<{ line: number; column: number }>;
50
+ path?: string[];
51
+ }>;
52
+ }
53
+
54
+ /**
55
+ * CurrentUser Query Response - matches pytryfi structure
56
+ */
57
+ export interface CurrentUserResponse {
58
+ currentUser: {
59
+ __typename: string;
60
+ id: string;
61
+ email: string;
62
+ firstName: string;
63
+ lastName: string;
64
+ userHouseholds: Array<{
65
+ __typename: string;
66
+ household: {
67
+ __typename: string;
68
+ pets: Array<{
69
+ __typename: string;
70
+ id: string;
71
+ name: string;
72
+ homeCityState?: string;
73
+ gender?: string;
74
+ breed?: {
75
+ __typename: string;
76
+ id: string;
77
+ name: string;
78
+ };
79
+ device?: {
80
+ __typename: string;
81
+ id: string;
82
+ moduleId: string;
83
+ info: any; // JSON object with batteryPercent, isCharging, etc.
84
+ operationParams?: {
85
+ __typename: string;
86
+ mode: string;
87
+ ledEnabled: boolean;
88
+ ledOffAt?: string;
89
+ };
90
+ lastConnectionState?: {
91
+ __typename: string;
92
+ date: string;
93
+ } | {
94
+ __typename: 'ConnectedToUser';
95
+ date: string;
96
+ user: {
97
+ __typename: string;
98
+ id: string;
99
+ firstName: string;
100
+ lastName: string;
101
+ };
102
+ } | {
103
+ __typename: 'ConnectedToBase';
104
+ date: string;
105
+ chargingBase: {
106
+ __typename: string;
107
+ id: string;
108
+ };
109
+ } | {
110
+ __typename: 'ConnectedToCellular';
111
+ date: string;
112
+ signalStrengthPercent: number;
113
+ };
114
+ };
115
+ }>;
116
+ };
117
+ }>;
118
+ };
119
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "lib": ["ES2022"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "declaration": true,
9
+ "declarationMap": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "esModuleInterop": true,
13
+ "skipLibCheck": true,
14
+ "forceConsistentCasingInFileNames": true,
15
+ "resolveJsonModule": true,
16
+ "moduleResolution": "node"
17
+ },
18
+ "include": [
19
+ "src/**/*"
20
+ ],
21
+ "exclude": [
22
+ "node_modules",
23
+ "dist"
24
+ ]
25
+ }