diff --git a/src/app/entity/entity.component.html b/src/app/entity/entity.component.html index 4430c7c..cf2f9e2 100644 --- a/src/app/entity/entity.component.html +++ b/src/app/entity/entity.component.html @@ -74,7 +74,7 @@

Discovery Topic

- +
\ No newline at end of file diff --git a/src/app/entity/entity.component.ts b/src/app/entity/entity.component.ts index 9045f97..cd6ecec 100644 --- a/src/app/entity/entity.component.ts +++ b/src/app/entity/entity.component.ts @@ -24,6 +24,7 @@ export class EntityComponent { readonly useRandomString = randomString; showDiscovery: boolean = false; + _discoveryTopic: string = ''; @Input() entity_type: number = 0; @Input() stat_t: string = ''; @@ -133,7 +134,6 @@ export class EntityComponent { create_entity() { this.basemodel?.setProperty('stat_t', this.stat_t); - this.basemodel?.setProperty('name', this.entity_name); this.basemodel?.setProperty('cmd_t', this.entity_cmd_t); this.basemodel?.setProperty('bri_cmd_t', this.entity_bri_cmd_t); @@ -142,36 +142,27 @@ export class EntityComponent { this.basemodel?.setProperty('unit_of_meas', this.entity_unit_of_meas); this.basemodel?.setProperty('val_tpl', this.entity_val_tpl); this.basemodel?.setProperty('dev_cla', this.entity_dev_cla); + this._discoveryTopic = this.discoveryTopic; this.showDiscovery = true; return; } get discoveryString() { - // this.basemodel?.createString(); return this.basemodel?.toJSON(); - // let discString = this.basemodel?.toJ(); - // if (discString == '' || discString == undefined) return ''; } get JSONdiscoveryString() { return JSON.stringify(this.basemodel?.toJSON()).replaceAll('"', '\\"'); - // let discString = this.basemodel?.createString(); - // if (discString == '' || discString == undefined) return ''; - // discString = discString.replaceAll('"', '\\"'); } get discoveryTopic() { if (this.entity_type == 0) return ''; - if (this.entity_name == '') return ''; - let discTopic = - 'homeassistant/' + - entity_types[this.entity_type][0] + - '/' + - this.entity_name + - '_' + - this.entity_uniq_id + - '/config'; - return discTopic; + return join( + '/', + 'homeassistant', + entity_types[this.entity_type][0], + this.display_name + ).toLowerCase(); } }