export class MQTTEntity { name: string = ''; stat_t: string = ''; uniq_id: string = ''; // dev: MQTTDevice | null = null; // entity_type: ENTITY_TYPE = 0; setProperty(name: unknown, value: any): void { if (!this.hasOwnProperty(String(name))) return; this[name as keyof this] = value; } getProperty(name: string): any { if (!this.hasOwnProperty(name)) return; return this[name as keyof this]; } toJSON(): any { let jsonObject: { [key: string]: string } = {}; for (let prop_name of Object.getOwnPropertyNames(this)) { let property = this[prop_name as keyof this]; if (property == '') continue; jsonObject[prop_name] = String(property); } return jsonObject; } // toJSON(): any { // return { // name: this.name, // stat_t: this.stat_t, // uniq_id: this.uniq_id, // }; // } } export class MQTTDevice { name: string = ''; identifiers: string[] = ['MQTT']; serial_number: string = ''; configuration_url: string = ''; } export class DeviceClass { value: number = 0; choices: string[] = ['None']; constructor(choices: string[]) { this.choices = choices; } toString(): string { return this.choices[this.value]; } }