Version 1.0 working Entity creation and string generator

This commit is contained in:
2024-05-28 07:44:21 +02:00
parent 46eee5d726
commit 13e15a24b7
50 changed files with 13956 additions and 128 deletions

View File

@@ -0,0 +1,43 @@
export class MQTTEntity {
name: string = "";
stat_t: string = "state/topic";
uniq_id: string = "unique_id";
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;
}
createString() : string{
let string: string = "";
for(let property of Object.getOwnPropertyNames(this)){
if(this[property as keyof this] == null) continue;
string += `"${property}": "${this[property as keyof this]}",`
}
console.log(string);
return string;
}
}
export class MQTTDevice {
name: string = "";
identifiers: string[] = ["MQTT"];
serial_number: string = "";
configuration_url: string = "";
}
// export enum ENTITY_TYPE {
// light = 0,
// switch = 1,
// sensor = 2,
// binary_sensor = 3,
// button = 4,
// }
export enum DEVICE_CLASS {
motion = 0,
movement = 1,
outlet = 2
}