This commit is contained in:
sebseb7
2025-12-25 05:48:56 +01:00
parent c794dbaab8
commit a09da9a835

View File

@@ -141,6 +141,8 @@ export class ACInfinityClient {
.replace(/[^a-z0-9]+/g, '-') .replace(/[^a-z0-9]+/g, '-')
.replace(/^-|-$/g, ''); .replace(/^-|-$/g, '');
console.log(`[AC] Debug: Device ${deviceId} (${device.devName}) Type: ${device.devType}`);
// --- Device Level Sensors --- // --- Device Level Sensors ---
// Temperature (Celsius * 100) // Temperature (Celsius * 100)
@@ -272,6 +274,10 @@ export class ACInfinityClient {
const settings = await this.getDeviceModeSettings(devId, port); const settings = await this.getDeviceModeSettings(devId, port);
if (!settings) throw new Error('Could not fetch existing settings'); if (!settings) throw new Error('Could not fetch existing settings');
console.log(`[AC] Debug: Device Settings for ${devId}:${port}`, JSON.stringify(settings));
// Log device info if available to check type? We don't have devType here easily without passing it or fetching list again.
// But settings usually contains some info.
// 2. Prepare updates // 2. Prepare updates
// Constrain level 0-10 // Constrain level 0-10
const safeLevel = Math.max(0, Math.min(10, Math.round(level))); const safeLevel = Math.max(0, Math.min(10, Math.round(level)));
@@ -306,6 +312,18 @@ export class ACInfinityClient {
const speakValue = mode === AtType.OFF ? 0 : safeLevel; const speakValue = mode === AtType.OFF ? 0 : safeLevel;
params.append('speak', speakValue.toString()); params.append('speak', speakValue.toString());
// CRITICAL FIX: Explicitly set atType to match the mode!
// atType: 1 = OFF, 2 = ON, 3 = AUTO
params.append('atType', mode.toString());
// Ensure onSpead (Max Speed) matches target if in ON mode
if (mode === AtType.ON) {
params.append('onSpead', safeLevel.toString());
} else {
// In OFF mode, ensure onSpead is at least present (maybe 10 or 0? Leaving existing or default)
if (!params.has('onSpead')) params.append('onSpead', '10');
}
// Copy other relevant fields from settings if they exist to maintain state // Copy other relevant fields from settings if they exist to maintain state
// Common fields seen in other implementations: // Common fields seen in other implementations:
// transitionType, surplus, backup, trigger related fields... // transitionType, surplus, backup, trigger related fields...
@@ -327,7 +345,10 @@ export class ACInfinityClient {
if (!params.has('transitionType')) params.append('transitionType', '0'); if (!params.has('transitionType')) params.append('transitionType', '0');
// 3. Send update // 3. Send update
const response = await fetch(`${this.host}/api/dev/addDevMode?${params.toString()}`, { const requestUrl = `${this.host}/api/dev/addDevMode?${params.toString()}`;
console.log(`[AC] Debug: Sending request to ${requestUrl}`);
const response = await fetch(requestUrl, {
method: 'POST', method: 'POST',
headers: { headers: {
'User-Agent': 'ACController/1.9.7 (com.acinfinity.humiture; build:533; iOS 18.5.0) Alamofire/5.10.2', 'User-Agent': 'ACController/1.9.7 (com.acinfinity.humiture; build:533; iOS 18.5.0) Alamofire/5.10.2',