import { DaikinBRP069 } from './brp069.js'; import type { TranslationMap } from '../types.js'; export class DaikinAirBase extends DaikinBRP069 { static TRANSLATIONS: TranslationMap = { ...DaikinBRP069.TRANSLATIONS, mode: { '0': 'fan', '1': 'hot', '2': 'cool', '3': 'auto', '7': 'dry', }, f_rate: { '0': 'auto', '1': 'low', '3': 'mid', '5': 'high', '1a': 'low/auto', '3a': 'mid/auto', '5a': 'high/auto', }, }; static HTTP_RESOURCES = [ 'common/basic_info', 'aircon/get_control_info', 'aircon/get_model_info', 'aircon/get_sensor_info', 'aircon/get_zone_setting', ]; private static DEFAULTS = { htemp: '-', otemp: '-', shum: '--' }; constructor(deviceId: string) { super(deviceId); (this.constructor as typeof DaikinAirBase).TRANSLATIONS = DaikinAirBase.TRANSLATIONS; } parseResponse(responseBody: string): Record { const response = super.parseResponse(responseBody); if (response['f_auto'] === '1') { response['f_rate'] = `${response['f_rate']}a`; } return response; } async init(): Promise { await super.init(); if (this.values.size === 0) { throw new Error('Empty values.'); } for (const [key, value] of Object.entries(DaikinAirBase.DEFAULTS)) { if (!this.values.has(key)) { this.values.set(key, value); } } if (this.values.get('model') === 'NOTSUPPORT') { this.values.set('model', 'Airbase BRP15B61'); } } async getResource(path: string, params?: Record): Promise> { return super.getResource(`skyfi/${path}`, params); } get supportAwayMode(): boolean { return false; } get supportOutsideTemperature(): boolean { return this.values.has('otemp') && this.values.get('otemp') !== '-'; } get supportSwingMode(): boolean { return false; } get outsideTemperature(): number | null { const value = this.values.get('otemp'); if (value === '-') return null; return this.parseNumber('otemp'); } }