matterbridge-lg-thinq-plugin 0.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/.claude/CLAUDE.md +43 -0
- package/.claude/agents/compiler.md +91 -0
- package/.claude/agents/direct-executor.md +98 -0
- package/.claude/agents/documenter.md +78 -0
- package/.claude/agents/finalizer.md +233 -0
- package/.claude/agents/implementer.md +112 -0
- package/.claude/agents/investigator.md +100 -0
- package/.claude/agents/release-manager.md +203 -0
- package/.claude/agents/reviewer.md +131 -0
- package/.claude/agents/technical-architect.md +403 -0
- package/.claude/agents/test-writer.md +159 -0
- package/.claude/agents/wiki-manager.md +147 -0
- package/.claude/instructions/agent-prompts.md +90 -0
- package/.claude/instructions/shared-rules.md +11 -0
- package/.claude/instructions/team-orchestrator-policy.md +165 -0
- package/.claude/memory.md +186 -0
- package/.claude/output-styles/engineer-manager.md +38 -0
- package/.claude/settings.json +40 -0
- package/.claude/settings.local.json +30 -0
- package/.claude/skills/load-policy/SKILL.md +13 -0
- package/.claude/skills/ref-idea/SKILL.md +44 -0
- package/.claude/skills/status-of/SKILL.md +38 -0
- package/.claude/skills/workspace-console/SKILL.md +49 -0
- package/.claude/statusline-command.sh +130 -0
- package/.claude/statusline.md +53 -0
- package/.claude/templates/approval-packet.template.html +171 -0
- package/.claude/templates/reference-workspaces.md +16 -0
- package/.claude/tools/cli-runner-server.cjs +220 -0
- package/.claude/tools/discord-send-server.cjs +188 -0
- package/.claude/tools/github-release-server.cjs +181 -0
- package/.claude/tools/glob-grep-server.cjs +267 -0
- package/.claude/tools/read-log-server.cjs +175 -0
- package/.github/codeql/codeql-config.yml +14 -0
- package/.github/workflows/build.yml +54 -0
- package/.github/workflows/codeql.yml +59 -0
- package/.github/workflows/coverage.yml +70 -0
- package/.github/workflows/publish.yml +103 -0
- package/.mcp.json +34 -0
- package/CHANGELOG.md +195 -0
- package/LICENSE +21 -0
- package/dist/cli/commands/devices.js +52 -0
- package/dist/cli/commands/energy.js +122 -0
- package/dist/cli/commands/login.js +54 -0
- package/dist/cli/help.js +50 -0
- package/dist/cli/main.js +56 -0
- package/dist/cli/session.js +13 -0
- package/dist/cli/types.js +1 -0
- package/dist/cli/utils.js +29 -0
- package/dist/cli.js +2 -0
- package/dist/constants/index.js +1 -0
- package/dist/core/domain/entities/ThinqDevice.js +43 -0
- package/dist/core/domain/value-objects/AirConditionerCapabilities.js +22 -0
- package/dist/core/domain/value-objects/ThinqFilterState.js +35 -0
- package/dist/core/domain/value-objects/ThinqSnapshot.js +125 -0
- package/dist/errors/AuthenticationError.js +26 -0
- package/dist/errors/BaseError.js +23 -0
- package/dist/errors/index.js +2 -0
- package/dist/model/LgThinkqPluginPlatformConfig.js +23 -0
- package/dist/model/LgThinqPluginPlatformConfig.js +23 -0
- package/dist/module.js +212 -0
- package/dist/platform/deviceRegistry.js +26 -0
- package/dist/platform/platformConfigManager.js +89 -0
- package/dist/platform/platformState.js +9 -0
- package/dist/platform/thinq/thinqAirConditionerCommandHandlers.js +190 -0
- package/dist/platform/thinq/thinqAirConditionerEndpointFactory.js +53 -0
- package/dist/platform/thinq/thinqAirConditionerFilterResetCommandHandler.js +54 -0
- package/dist/platform/thinq/thinqAirConditionerFilterStateSync.js +19 -0
- package/dist/platform/thinq/thinqAirConditionerStateSync.js +205 -0
- package/dist/platform/thinq/thinqDeviceConfigReconciler.js +26 -0
- package/dist/platform/thinq/thinqDeviceConfigurator.js +124 -0
- package/dist/platform/thinq/thinqDeviceDiscovery.js +33 -0
- package/dist/platform/thinq/thinqWasherCommandHandlers.js +54 -0
- package/dist/platform/thinq/thinqWasherEndpointFactory.js +6 -0
- package/dist/platform/thinq/thinqWasherStateSync.js +31 -0
- package/dist/platform/thinq/thinqWasherStopCommandResolver.js +38 -0
- package/dist/services/authentication/AccountAuthStrategy.js +135 -0
- package/dist/services/authentication/AuthContext.js +1 -0
- package/dist/services/authentication/AuthenticationCoordinator.js +29 -0
- package/dist/services/authentication/IAuthStrategy.js +1 -0
- package/dist/services/authentication/TokenAuthStrategy.js +27 -0
- package/dist/services/authentication/UserDataRepository.js +32 -0
- package/dist/services/thinq/gateway.js +61 -0
- package/dist/services/thinq/mqtt/mqttCertificate.js +63 -0
- package/dist/services/thinq/mqtt/mqttConnectionEvents.js +37 -0
- package/dist/services/thinq/mqtt/mqttKeyRepository.js +33 -0
- package/dist/services/thinq/mqtt/mqttRetry.js +25 -0
- package/dist/services/thinq/mqtt/thinqMqttListener.js +97 -0
- package/dist/services/thinq/serviceContainer.js +73 -0
- package/dist/services/thinq/session.js +48 -0
- package/dist/services/thinq/thinqApiClient.js +258 -0
- package/dist/services/thinq/thinqDeviceService.js +75 -0
- package/dist/services/thinq/thinqFilterMonitoringService.js +40 -0
- package/dist/settings.js +9 -0
- package/dist/tests/helpers/testUtils.js +87 -0
- package/dist/utils/mask.js +39 -0
- package/docs/README_CLI.md +166 -0
- package/eslint.config.js +194 -0
- package/matterbridge-lg-thinq-plugin.config.json +27 -0
- package/matterbridge-lg-thinq-plugin.schema.json +520 -0
- package/package.json +107 -0
- package/prettier.config.js +49 -0
- package/scripts/parse-junit-failures.mjs +45 -0
- package/scripts/parse-tsc-failures.mjs +48 -0
- package/scripts/run-build-local-summary.mjs +29 -0
- package/scripts/run-format-summary.mjs +36 -0
- package/scripts/run-lint-fix-summary.mjs +38 -0
- package/scripts/run-precommit-summary.mjs +94 -0
- package/src/cli/commands/devices.ts +67 -0
- package/src/cli/commands/energy.ts +160 -0
- package/src/cli/commands/login.ts +74 -0
- package/src/cli/help.ts +53 -0
- package/src/cli/main.ts +66 -0
- package/src/cli/session.ts +15 -0
- package/src/cli/types.ts +10 -0
- package/src/cli/utils.ts +30 -0
- package/src/cli.ts +3 -0
- package/src/constants/index.ts +8 -0
- package/src/core/domain/entities/ThinqDevice.test.ts +224 -0
- package/src/core/domain/entities/ThinqDevice.ts +74 -0
- package/src/core/domain/value-objects/AirConditionerCapabilities.ts +50 -0
- package/src/core/domain/value-objects/ThinqFilterState.ts +50 -0
- package/src/core/domain/value-objects/ThinqSnapshot.ts +162 -0
- package/src/errors/AuthenticationError.ts +37 -0
- package/src/errors/BaseError.ts +38 -0
- package/src/errors/index.ts +24 -0
- package/src/model/LgThinqPluginPlatformConfig.ts +94 -0
- package/src/module.ts +298 -0
- package/src/platform/deviceRegistry.ts +58 -0
- package/src/platform/platformConfigManager.ts +133 -0
- package/src/platform/platformState.ts +16 -0
- package/src/platform/thinq/thinqAirConditionerCommandHandlers.ts +291 -0
- package/src/platform/thinq/thinqAirConditionerEndpointFactory.ts +145 -0
- package/src/platform/thinq/thinqAirConditionerFilterResetCommandHandler.ts +96 -0
- package/src/platform/thinq/thinqAirConditionerFilterStateSync.ts +42 -0
- package/src/platform/thinq/thinqAirConditionerStateSync.ts +343 -0
- package/src/platform/thinq/thinqDeviceConfigReconciler.ts +42 -0
- package/src/platform/thinq/thinqDeviceConfigurator.test.ts +90 -0
- package/src/platform/thinq/thinqDeviceConfigurator.ts +191 -0
- package/src/platform/thinq/thinqDeviceDiscovery.test.ts +173 -0
- package/src/platform/thinq/thinqDeviceDiscovery.ts +51 -0
- package/src/platform/thinq/thinqWasherCommandHandlers.ts +120 -0
- package/src/platform/thinq/thinqWasherEndpointFactory.ts +37 -0
- package/src/platform/thinq/thinqWasherStateSync.ts +60 -0
- package/src/platform/thinq/thinqWasherStopCommandResolver.ts +62 -0
- package/src/services/authentication/AccountAuthStrategy.test.ts +358 -0
- package/src/services/authentication/AccountAuthStrategy.ts +209 -0
- package/src/services/authentication/AuthContext.ts +19 -0
- package/src/services/authentication/AuthenticationCoordinator.test.ts +217 -0
- package/src/services/authentication/AuthenticationCoordinator.ts +59 -0
- package/src/services/authentication/IAuthStrategy.ts +10 -0
- package/src/services/authentication/TokenAuthStrategy.test.ts +167 -0
- package/src/services/authentication/TokenAuthStrategy.ts +40 -0
- package/src/services/authentication/UserDataRepository.test.ts +149 -0
- package/src/services/authentication/UserDataRepository.ts +46 -0
- package/src/services/thinq/gateway.ts +86 -0
- package/src/services/thinq/mqtt/mqttCertificate.test.ts +344 -0
- package/src/services/thinq/mqtt/mqttCertificate.ts +102 -0
- package/src/services/thinq/mqtt/mqttConnectionEvents.test.ts +276 -0
- package/src/services/thinq/mqtt/mqttConnectionEvents.ts +76 -0
- package/src/services/thinq/mqtt/mqttKeyRepository.test.ts +164 -0
- package/src/services/thinq/mqtt/mqttKeyRepository.ts +43 -0
- package/src/services/thinq/mqtt/mqttRetry.test.ts +239 -0
- package/src/services/thinq/mqtt/mqttRetry.ts +43 -0
- package/src/services/thinq/mqtt/thinqMqttListener.test.ts +349 -0
- package/src/services/thinq/mqtt/thinqMqttListener.ts +120 -0
- package/src/services/thinq/serviceContainer.test.ts +203 -0
- package/src/services/thinq/serviceContainer.ts +105 -0
- package/src/services/thinq/session.test.ts +287 -0
- package/src/services/thinq/session.ts +69 -0
- package/src/services/thinq/thinqApiClient.test.ts +702 -0
- package/src/services/thinq/thinqApiClient.ts +418 -0
- package/src/services/thinq/thinqDeviceService.test.ts +415 -0
- package/src/services/thinq/thinqDeviceService.ts +101 -0
- package/src/services/thinq/thinqFilterMonitoringService.test.ts +264 -0
- package/src/services/thinq/thinqFilterMonitoringService.ts +53 -0
- package/src/settings.ts +18 -0
- package/src/tests/cli/commands/devices.test.ts +293 -0
- package/src/tests/cli/commands/login.test.ts +240 -0
- package/src/tests/cli/help.test.ts +46 -0
- package/src/tests/cli/main.test.ts +214 -0
- package/src/tests/cli/session.test.ts +198 -0
- package/src/tests/cli/utils.test.ts +194 -0
- package/src/tests/core/domain/value-objects/AirConditionerCapabilities.test.ts +685 -0
- package/src/tests/core/domain/value-objects/ThinqFilterState.test.ts +210 -0
- package/src/tests/core/domain/value-objects/ThinqSnapshot.test.ts +1035 -0
- package/src/tests/helpers/testUtils.ts +118 -0
- package/src/tests/model/LgThinqPluginPlatformConfig.test.ts +81 -0
- package/src/tests/platform/deviceRegistry.test.ts +177 -0
- package/src/tests/platform/platformConfigManager.test.ts +790 -0
- package/src/tests/platform/platformState.test.ts +41 -0
- package/src/tests/platform/thinq/thinqAirConditionerCommandHandlers.test.ts +879 -0
- package/src/tests/platform/thinq/thinqAirConditionerEndpointFactory.test.ts +993 -0
- package/src/tests/platform/thinq/thinqAirConditionerFilterResetCommandHandler.test.ts +508 -0
- package/src/tests/platform/thinq/thinqAirConditionerFilterStateSync.test.ts +212 -0
- package/src/tests/platform/thinq/thinqAirConditionerStateSync.test.ts +1586 -0
- package/src/tests/platform/thinq/thinqDeviceConfigReconciler.test.ts +269 -0
- package/src/tests/platform/thinq/thinqDeviceConfigurator.test.ts +492 -0
- package/src/tests/platform/thinq/thinqWasherCommandHandlers.test.ts +594 -0
- package/src/tests/platform/thinq/thinqWasherEndpointFactory.test.ts +84 -0
- package/src/tests/platform/thinq/thinqWasherStateSync.test.ts +373 -0
- package/src/tests/platform/thinq/thinqWasherStopCommandResolver.test.ts +392 -0
- package/src/tests/settings.test.ts +33 -0
- package/src/utils/mask.ts +50 -0
- package/tsconfig.base.json +25 -0
- package/tsconfig.json +9 -0
- package/tsconfig.production.json +13 -0
- package/tsconfig.vitest.json +5 -0
- package/vite.config.ts +43 -0
- package/wiki/memory-archive.md +12 -0
- package/wiki/reference-workspaces.md +23 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { ThinqFilterState } from '../../../../core/domain/value-objects/ThinqFilterState.js';
|
|
4
|
+
|
|
5
|
+
describe('ThinqFilterState', () => {
|
|
6
|
+
describe('fromRaw', () => {
|
|
7
|
+
it('should create instance with valid data', () => {
|
|
8
|
+
const data = {
|
|
9
|
+
'airState.filterMngStates.useTime': 11,
|
|
10
|
+
'airState.filterMngStates.maxTime': 720,
|
|
11
|
+
'airState.filterMngStates.changeDate': 20260919,
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
15
|
+
|
|
16
|
+
expect(result).toBeDefined();
|
|
17
|
+
expect(result?.remainingPercent).toBe(98);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should return undefined when useTime is missing', () => {
|
|
21
|
+
const data = {
|
|
22
|
+
'airState.filterMngStates.maxTime': 720,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
26
|
+
|
|
27
|
+
expect(result).toBeUndefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should return undefined when maxTime is missing', () => {
|
|
31
|
+
const data = {
|
|
32
|
+
'airState.filterMngStates.useTime': 11,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
36
|
+
|
|
37
|
+
expect(result).toBeUndefined();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should return undefined when maxTime is zero', () => {
|
|
41
|
+
const data = {
|
|
42
|
+
'airState.filterMngStates.useTime': 11,
|
|
43
|
+
'airState.filterMngStates.maxTime': 0,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
47
|
+
|
|
48
|
+
expect(result).toBeUndefined();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('should return undefined when maxTime is negative', () => {
|
|
52
|
+
const data = {
|
|
53
|
+
'airState.filterMngStates.useTime': 11,
|
|
54
|
+
'airState.filterMngStates.maxTime': -100,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
58
|
+
|
|
59
|
+
expect(result).toBeUndefined();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should return undefined when data is undefined', () => {
|
|
63
|
+
const result = ThinqFilterState.fromRaw(undefined);
|
|
64
|
+
|
|
65
|
+
expect(result).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('should return undefined when useTime is not a number', () => {
|
|
69
|
+
const data = {
|
|
70
|
+
'airState.filterMngStates.useTime': '11',
|
|
71
|
+
'airState.filterMngStates.maxTime': 720,
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
75
|
+
|
|
76
|
+
expect(result).toBeUndefined();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should return undefined when maxTime is not a number', () => {
|
|
80
|
+
const data = {
|
|
81
|
+
'airState.filterMngStates.useTime': 11,
|
|
82
|
+
'airState.filterMngStates.maxTime': '720',
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
86
|
+
|
|
87
|
+
expect(result).toBeUndefined();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it('should accept changeDate as optional', () => {
|
|
91
|
+
const data = {
|
|
92
|
+
'airState.filterMngStates.useTime': 11,
|
|
93
|
+
'airState.filterMngStates.maxTime': 720,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
97
|
+
|
|
98
|
+
expect(result).toBeDefined();
|
|
99
|
+
expect(result?.changeDate).toBeUndefined();
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('should store changeDate when present', () => {
|
|
103
|
+
const data = {
|
|
104
|
+
'airState.filterMngStates.useTime': 11,
|
|
105
|
+
'airState.filterMngStates.maxTime': 720,
|
|
106
|
+
'airState.filterMngStates.changeDate': 20260920,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
110
|
+
|
|
111
|
+
expect(result?.changeDate).toBe(20260920);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
describe('remainingPercent', () => {
|
|
116
|
+
it('should calculate remaining percent correctly', () => {
|
|
117
|
+
const data = {
|
|
118
|
+
'airState.filterMngStates.useTime': 100,
|
|
119
|
+
'airState.filterMngStates.maxTime': 500,
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
123
|
+
|
|
124
|
+
// (500 - 100) / 500 * 100 = 80%
|
|
125
|
+
expect(result?.remainingPercent).toBe(80);
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('should return 100 when useTime is zero', () => {
|
|
129
|
+
const data = {
|
|
130
|
+
'airState.filterMngStates.useTime': 0,
|
|
131
|
+
'airState.filterMngStates.maxTime': 720,
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
135
|
+
|
|
136
|
+
expect(result?.remainingPercent).toBe(100);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it('should clamp to 0 when useTime exceeds maxTime', () => {
|
|
140
|
+
const data = {
|
|
141
|
+
'airState.filterMngStates.useTime': 800,
|
|
142
|
+
'airState.filterMngStates.maxTime': 720,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
146
|
+
|
|
147
|
+
expect(result?.remainingPercent).toBe(0);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
it('should round to nearest integer', () => {
|
|
151
|
+
const data = {
|
|
152
|
+
'airState.filterMngStates.useTime': 75,
|
|
153
|
+
'airState.filterMngStates.maxTime': 720,
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
157
|
+
|
|
158
|
+
// (720 - 75) / 720 * 100 = 89.583... rounds to 90
|
|
159
|
+
expect(result?.remainingPercent).toBe(90);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('should round down for .4 and below', () => {
|
|
163
|
+
const data = {
|
|
164
|
+
'airState.filterMngStates.useTime': 432,
|
|
165
|
+
'airState.filterMngStates.maxTime': 720,
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
169
|
+
|
|
170
|
+
// (720 - 432) / 720 * 100 = 40
|
|
171
|
+
expect(result?.remainingPercent).toBe(40);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it('should handle very small remaining percentages', () => {
|
|
175
|
+
const data = {
|
|
176
|
+
'airState.filterMngStates.useTime': 715,
|
|
177
|
+
'airState.filterMngStates.maxTime': 720,
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
181
|
+
|
|
182
|
+
// (720 - 715) / 720 * 100 = 0.694... rounds to 1
|
|
183
|
+
expect(result?.remainingPercent).toBe(1);
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('ratedMaxTimeHours', () => {
|
|
188
|
+
it('should return the maxTime value that was passed to fromRaw', () => {
|
|
189
|
+
const data = {
|
|
190
|
+
'airState.filterMngStates.useTime': 11,
|
|
191
|
+
'airState.filterMngStates.maxTime': 720,
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
195
|
+
|
|
196
|
+
expect(result?.ratedMaxTimeHours).toBe(720);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('should return different maxTime values correctly', () => {
|
|
200
|
+
const data = {
|
|
201
|
+
'airState.filterMngStates.useTime': 100,
|
|
202
|
+
'airState.filterMngStates.maxTime': 500,
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
const result = ThinqFilterState.fromRaw(data);
|
|
206
|
+
|
|
207
|
+
expect(result?.ratedMaxTimeHours).toBe(500);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
});
|