diff --git a/README.md b/README.md index 8ecdd5e..f90300e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,34 @@ # MqttCreator -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.3.4. +This project is a simple and incomplete generator to create a Homeassinstant compatible MQTT Autodiscovery Entity + +## Limited Coverage +By now only the these entities (binary_sensor, light, sensor, switch) are supported by the generator, because they are the most commmonly used entities for my own needs + +## Usage +The UI is seperated into two parts, the global generator with settings and upper Topic and the entity itselt + +### Generator: +Automated Topic Settings: +- all: the topics will be generated automatically from the other supplied inputs, all changes will be wiped +- only changes: user inputs will be synced accross all topics (only works if the general structure stays the same and changes are not to large at once) +- none: everything is done manually + +### Entity: +After choosing an entity type, change and input the corresponding values as you like and if automated topics is actived the topics will be populated automatically + +Once done, you can press the DiscoveryString button. + +### Discovery String: +First you see the discovery string formatted, there you can check for any errors in the configuration + +Below there will be a discovery string with escaped perentecies to input into print statements or similar + +The last field Discovery Topic is the automatically generated Discovery Topic for default Homeassistant MQTT Autodiscovery + + + + diff --git a/src/app/app.component.html b/src/app/app.component.html index d63a16c..0b0951f 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1,3 +1,10 @@ -
Discovery String
-{{discoveryString | json}}
- {{JSONdiscoveryString}}
+ {{discoveryString | json}}
+ {{JSONdiscoveryString}}
+ Discovery Topic
diff --git a/src/app/entity/entity.component.ts b/src/app/entity/entity.component.ts index 11f1ad9..9045f97 100644 --- a/src/app/entity/entity.component.ts +++ b/src/app/entity/entity.component.ts @@ -79,13 +79,28 @@ export class EntityComponent { this[model] = value as (typeof this)[keyof this]; return; } - let sync_topic = new_list.slice(0, -1).join('/'); - this.stat_t = sync_topic + '/stat'; - this.entity_cmd_t = sync_topic + '/cmd'; - this.entity_bri_cmd_t = sync_topic + '/bri_cmd'; + let missing_index = new_list.indexOf(missing[0]); + this.stat_t = this.replaceComponent(this.stat_t, missing[0], missing_index); + this.entity_cmd_t = this.replaceComponent( + this.entity_cmd_t, + missing[0], + missing_index + ); + this.entity_bri_cmd_t = this.replaceComponent( + this.entity_bri_cmd_t, + missing[0], + missing_index + ); + return; } + replaceComponent(object: string, value: string, index: number) { + let param_list = object.split('/'); + param_list[index] = value; + return param_list.join('/'); + } + updateTopic(topic: string) { let topic_str = join( '/', diff --git a/src/app/generator/generator.component.css b/src/app/generator/generator.component.css index 48c792f..cd945ae 100644 --- a/src/app/generator/generator.component.css +++ b/src/app/generator/generator.component.css @@ -2,6 +2,9 @@ background: #9D9D9D; border-radius: 1rem; padding: 1rem .8rem ; + display: flex; + flex-direction: column; + gap: 1rem; } .customCheckboxContainer{ diff --git a/src/app/generator/generator.component.html b/src/app/generator/generator.component.html index 88e5240..2032dbb 100644 --- a/src/app/generator/generator.component.html +++ b/src/app/generator/generator.component.html @@ -1,28 +1,15 @@ -Bereich
- Data Channel --> + +Bereich
+ +Automatische Topics