ADD: auto_topic switch
This commit is contained in:
@@ -16,6 +16,7 @@ export class GeneratorService {
|
|||||||
@Input() device_id: string = "";
|
@Input() device_id: string = "";
|
||||||
@Input() device_standalone: boolean = false;
|
@Input() device_standalone: boolean = false;
|
||||||
@Input() upperTopic: string = "";
|
@Input() upperTopic: string = "";
|
||||||
|
@Input() auto_topic: number = 2;
|
||||||
updateObserver: EventEmitter<boolean> = new EventEmitter<boolean>();
|
updateObserver: EventEmitter<boolean> = new EventEmitter<boolean>();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,3 @@
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
/* width: 100%; */
|
/* width: 100%; */
|
||||||
}
|
}
|
||||||
|
|
||||||
.buttonOff path{
|
|
||||||
fill:#535353;
|
|
||||||
}
|
|
||||||
@@ -36,22 +36,31 @@ export class EntityComponent {
|
|||||||
@Input() entity_val_tpl: string = "";
|
@Input() entity_val_tpl: string = "";
|
||||||
@Input() entity_dev_cla: string = "";
|
@Input() entity_dev_cla: string = "";
|
||||||
|
|
||||||
updateStateTopic() {
|
update() {
|
||||||
if (!this.auto_stat_t) return
|
if (this.generatorService.auto_topic == 2) {
|
||||||
this.state_topic = ""
|
this.state_topic = this.updateTopic('stat');
|
||||||
if (this.generatorService.upperTopic != "") this.state_topic += this.generatorService.upperTopic + "/";
|
this.entity_cmd_t = this.updateTopic('cmd');
|
||||||
if (this.entity_type != 0) this.state_topic += entity_types[this.entity_type][0] + "/"
|
this.entity_bri_cmd_t = this.updateTopic('bri_cmd');
|
||||||
if (this.generatorService.device_name != "") this.state_topic += this.generatorService.device_name + "/"
|
}
|
||||||
if (this.entity_name != "" && this.entity_uniq_id != "") this.state_topic += this.entity_name + "_" + this.entity_uniq_id + "/stat"
|
|
||||||
else if (this.entity_name != "") this.state_topic += this.entity_name + "/stat"
|
|
||||||
this.state_topic = this.state_topic.toLocaleLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
basemodelProperty(property: string) {
|
updateTopic(topic: string) {
|
||||||
if (this.basemodel?.hasOwnProperty(property)) console.log(property)
|
let topic_str = join(
|
||||||
return this.basemodel?.stat_t
|
'/',
|
||||||
|
this.generatorService.upperTopic,
|
||||||
|
entity_types[this.entity_type][0],
|
||||||
|
this.generatorService.device_name,
|
||||||
|
this.display_name,
|
||||||
|
topic
|
||||||
|
).toLowerCase();
|
||||||
|
return topic_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// basemodelProperty(property: string) {
|
||||||
|
// if (this.basemodel?.hasOwnProperty(property)) console.log(property)
|
||||||
|
// return this.basemodel?.stat_t
|
||||||
|
// }
|
||||||
|
|
||||||
select_type(event: unknown) {
|
select_type(event: unknown) {
|
||||||
let ent_type = entity_types[event as keyof typeof entity_types]
|
let ent_type = entity_types[event as keyof typeof entity_types]
|
||||||
let ent_class = ent_type[1];
|
let ent_class = ent_type[1];
|
||||||
@@ -64,7 +73,7 @@ export class EntityComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lockStateTopic(event: any) {
|
lockStateTopic(event: any) {
|
||||||
this.auto_stat_t = false;
|
this.generatorService.auto_topic = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
create_entity() {
|
create_entity() {
|
||||||
|
|||||||
@@ -3,3 +3,26 @@
|
|||||||
border-radius: 1rem;
|
border-radius: 1rem;
|
||||||
padding: 1rem .8rem ;
|
padding: 1rem .8rem ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.customCheckboxContainer{
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customCheckboxContainer input[type="radio"]{
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customCheckbox{
|
||||||
|
width: 100%;
|
||||||
|
padding: .25rem 0;
|
||||||
|
text-align: center;
|
||||||
|
background: #B3B3B3;
|
||||||
|
transition: background .25s ease-in-out, color .25s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.customCheckboxContainer input:checked + label{
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--secondary);
|
||||||
|
}
|
||||||
@@ -23,6 +23,16 @@
|
|||||||
<p>Bereich</p>
|
<p>Bereich</p>
|
||||||
<input type="text" [ngModel]="generatorService.upperTopic"
|
<input type="text" [ngModel]="generatorService.upperTopic"
|
||||||
(ngModelChange)="generatorService.upperTopic = $event; generatorService.update()" />
|
(ngModelChange)="generatorService.upperTopic = $event; generatorService.update()" />
|
||||||
|
<p>Automatische Topics</p>
|
||||||
|
<div class="customCheckboxContainer">
|
||||||
|
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_0" type="radio" name="auto_topic" value="2">
|
||||||
|
<label class="customCheckbox" for="auto_topic_0">Alles</label>
|
||||||
|
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_1" type="radio" name="auto_topic" value="1">
|
||||||
|
<label class="customCheckbox" for="auto_topic_1">Änderungen übernehmen</label>
|
||||||
|
<input [ngModel]="auto_topic" (ngModelChange)="auto_topic=$event" id="auto_topic_2" type="radio" name="auto_topic" value="0">
|
||||||
|
<label class="customCheckbox" for="auto_topic_2">Aus</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,7 +20,18 @@ export class GeneratorComponent {
|
|||||||
readonly useObject = Object;
|
readonly useObject = Object;
|
||||||
readonly useRandomString = randomString;
|
readonly useRandomString = randomString;
|
||||||
|
|
||||||
|
set auto_topic(value: number) {
|
||||||
|
this.generatorService.auto_topic = value;
|
||||||
|
console.log(this.generatorService.auto_topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
get auto_topic(): string {
|
||||||
|
return String(this.generatorService.auto_topic);
|
||||||
|
}
|
||||||
|
|
||||||
|
log(event:any){
|
||||||
|
console.log(Number(event));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user