Skip to content

Commit 88cefe9

Browse files
committed
Added value template to entity
1 parent 5fcb6f1 commit 88cefe9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/app/specification/entity/entity.component.html

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,15 @@
138138
</mat-form-field>
139139

140140
</div>
141+
<div class="flexcols">
142+
<mat-form-field class="smallfield">
143+
<mat-label>Value Template</mat-label>
144+
<input matInput formControlName="value_template" [placeholder]="getValueTemplate()"
145+
(change)="form2Entity()"/>
146+
</mat-form-field>
147+
148+
</div>
149+
141150
</form>
142151
</mat-expansion-panel>
143152

src/app/specification/entity/entity.component.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ export class EntityComponent
229229
entityCategory: [""],
230230
icon: [null as string | null],
231231
forceUpdate: [false],
232+
value_template: [null as string | null],
232233
});
233234
this.variableFormGroup = this.fb.group({
234235
variableType: [null as VariableTargetParameters | null],
@@ -397,6 +398,7 @@ export class EntityComponent
397398

398399
this.entityFormGroup.get("icon")!.setValue(entity.icon);
399400
this.entityFormGroup.get("forceUpdate")!.setValue(entity.forceUpdate);
401+
this.entityFormGroup.get("value_template")!.setValue(entity.value_template);
400402
this.entityFormGroup.get("entityCategory")!.setValue(entity.entityCategory);
401403
this.entityFormGroup.get("readonly")!.setValue(entity.readonly);
402404
this.entityFormGroup
@@ -535,6 +537,9 @@ export class EntityComponent
535537
return (this.entity.converterParameters as Iselect).options!;
536538
return [];
537539
}
540+
getValueTemplate():string{
541+
return this.entity.value_template ? this.entity.value_template: "{{ value_json." + this.entity.mqttname + "}}"
542+
}
538543
isTouched(): boolean {
539544
if (!this.entityFormGroup.pristine) return true;
540545
if (!this.variableFormGroup!.pristine) return true;
@@ -672,6 +677,8 @@ export class EntityComponent
672677
this.entity.icon = this.entityFormGroup.get("icon")!.value;
673678
if (this.entityFormGroup.get("forceUpdate")!.value != null)
674679
this.entity.forceUpdate = this.entityFormGroup.get("forceUpdate")!.value;
680+
if (this.entityFormGroup.get("value_template")!.value != null)
681+
this.entity.value_template = this.entityFormGroup.get("value_template")!.value;
675682
if (this.entityFormGroup.get("readonly")!.value != null)
676683
this.entity.readonly = this.entityFormGroup.get("readonly")!.value;
677684
if (

0 commit comments

Comments
 (0)